Update of /cvsroot/playerstage/code/player/utils/xmms-plugin
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24685

Modified Files:
        playerxmms.c 
Log Message:
patch to xmm plugin from Geoff


Index: playerxmms.c
===================================================================
RCS file: /cvsroot/playerstage/code/player/utils/xmms-plugin/playerxmms.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** playerxmms.c        16 Jul 2006 11:53:47 -0000      1.1
--- playerxmms.c        12 Feb 2007 08:40:05 -0000      1.2
***************
*** 24,27 ****
--- 24,28 ----
  #include <stdio.h>
  #include <string.h>
+ #include <math.h>
  
  #include <xmms/plugin.h>
***************
*** 46,58 ****
  static playerc_client_t *client;
  static playerc_audio_t *audio_proxy;
! static guint64 written = 0;
  static AFormat afmt;
  static guint32 sampleRate = 44100;
  static guint8 numChannels = 2;
! static guint32 bytesPerSecond = 176400;
  static guint8 *buffer = NULL;
  static guint32 bufferTime = 5000;
  static guint32 bufferLength = 0;
  static guint32 bufferPos = 0;
  gint ctrlsocket_get_session_id(void);         /* FIXME */
  
--- 47,62 ----
  static playerc_client_t *client;
  static playerc_audio_t *audio_proxy;
! static guint32 written = 0;
  static AFormat afmt;
  static guint32 sampleRate = 44100;
  static guint8 numChannels = 2;
! static gint bytesPerSecond = 176400;
  static guint8 *buffer = NULL;
  static guint32 bufferTime = 5000;
  static guint32 bufferLength = 0;
  static guint32 bufferPos = 0;
+ static double startTime = 0.0f;
+ static double pauseStartTime = 0.0f;
+ static double pausedTime = 0.0f;
  gint ctrlsocket_get_session_id(void);         /* FIXME */
  
***************
*** 146,149 ****
--- 150,155 ----
        sampleRate = rate;
        numChannels = nch;
+       startTime = 0.0f;
+       pausedTime = 0.0f;
  
        if (xmms_check_realtime_priority())
***************
*** 175,179 ****
        }
  
!       bytesPerSecond = sampleRate * numChannels;
        if (fmt == FMT_S16_LE || fmt == FMT_S16_BE || fmt == FMT_S16_NE ||
                   fmt == FMT_U16_LE || fmt == FMT_U16_BE || fmt == FMT_U16_NE)
--- 181,197 ----
        }
  
!       // Set to PULL data mode
!       if (playerc_client_datamode (client, PLAYERC_DATAMODE_PULL) != 0)
!       {
!               fprintf(stderr, "error: %s\n", playerc_error_str());
!               return 0;
!       }
!       if (playerc_client_set_replace_rule (client, -1, -1, 
PLAYER_MSGTYPE_DATA, -1, 1) != 0)
!       {
!               fprintf(stderr, "error: %s\n", playerc_error_str());
!               return 0;
!       }
! 
!       bytesPerSecond = rate * nch;
        if (fmt == FMT_S16_LE || fmt == FMT_S16_BE || fmt == FMT_S16_NE ||
                   fmt == FMT_U16_LE || fmt == FMT_U16_BE || fmt == FMT_U16_NE)
***************
*** 246,249 ****
--- 264,273 ----
        unsigned int format = 0;
  
+       if (startTime == 0.0f)
+       {
+               struct timeval timeVal;
+               gettimeofday (&timeVal, NULL);
+               startTime = (double) timeVal.tv_sec + ((double) 
timeVal.tv_usec) / 1e6;
+       }
  
        // Add to buffer if there is space
***************
*** 290,293 ****
--- 314,318 ----
        bufferPos += length;
        written += length;
+ 
  }
  
***************
*** 316,321 ****
  static void playerout_pause(short p)
  {
!       // Don't really need to do anything for pausing/unpausing
!       printf ("Told to %s\n", p ? "pause" : "unpause");
  }
  
--- 341,363 ----
  static void playerout_pause(short p)
  {
!       // Audio protocol doesn't support pausing playback
! /*    printf ("Told to %s\n", p ? "pause" : "unpause");
!       if (p)
!       {
!               struct timeval timeVal;
!               gettimeofday (&timeVal, NULL);
!               pauseStartTime = (double) timeVal.tv_sec + ((double) 
timeVal.tv_usec) / 1e6;
!               printf ("started pause at %f\n", pauseStartTime);
!       }
!       else
!       {
!               double thisPausedTime = 0.0f;
!               struct timeval timeVal;
!               gettimeofday (&timeVal, NULL);
!               thisPausedTime = (double) timeVal.tv_sec + ((double) 
timeVal.tv_usec) / 1e6;
!               thisPausedTime -= pauseStartTime;
!               pausedTime += thisPausedTime;
!               printf ("paused for %f\n", thisPausedTime);
!       }*/
  }
  
***************
*** 328,351 ****
  static gint playerout_playing(void)
  {
!       return TRUE;
  }
  
  static gint playerout_get_written_time(void)
  {
! /*    double bps = -1, result = -1;
!       printf ("written = %d\tsr = %d\tnch = %d\tbps = %f\tresult = %f\n", 
written, sampleRate, numChannels, 44100 * 2, result);
!       bps = 44100 * 2;
!       result = ((double) written) / bps;
!       printf ("written = %d\tsr = %d\tnch = %d\tbps = %f\tresult = %f\n", 
written, sampleRate, numChannels, 44100 * 2, result);
        if (afmt == FMT_S16_LE || afmt == FMT_S16_BE || afmt == FMT_S16_NE ||
                        afmt == FMT_U16_LE || afmt == FMT_U16_BE || afmt == 
FMT_U16_NE)
                result /= 2.0f;
!       return (gint) result;*/
!       return 0;
  }
  
  static gint playerout_get_output_time(void)
  {
!       return playerout_get_written_time();
  }
  
--- 370,399 ----
  static gint playerout_playing(void)
  {
!       playerc_client_read (client);
!       if (audio_proxy->state & PLAYER_AUDIO_STATE_PLAYING)
!               return 1;
!       else
!               return 0;
  }
  
  static gint playerout_get_written_time(void)
  {
!       double result = 0;
!       result = ((double) written) / (sampleRate * numChannels);
        if (afmt == FMT_S16_LE || afmt == FMT_S16_BE || afmt == FMT_S16_NE ||
                        afmt == FMT_U16_LE || afmt == FMT_U16_BE || afmt == 
FMT_U16_NE)
                result /= 2.0f;
!       return result;
  }
  
  static gint playerout_get_output_time(void)
  {
!       if (startTime == 0.0f)
!               return 0;
! 
!       struct timeval timeVal;
!       gettimeofday (&timeVal, NULL);
!       double currentTime = (double) timeVal.tv_sec + ((double) 
timeVal.tv_usec) / 1e6;
!       return (currentTime - startTime);// - pausedTime);
  }
  


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Playerstage-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/playerstage-commit

Reply via email to