changeset 562:997496d252d4 trunk

[svn] Use InputPlayback standard flags in mpg123, drop set_time().
author iabervon
date Sun, 28 Jan 2007 22:14:55 -0800
parents 914c96de3244
children ccf952b07c77
files ChangeLog src/mpg123/common.c src/mpg123/layer1.c src/mpg123/layer3.c src/mpg123/mpg123.c src/mpg123/mpg123.h
diffstat 6 files changed, 80 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sun Jan 28 21:09:12 2007 -0800
+++ b/ChangeLog	Sun Jan 28 22:14:55 2007 -0800
@@ -1,3 +1,36 @@
+2007-01-29 05:09:12 +0000  Daniel Barkalow <barkalow@iabervon.org>
+  revision [1208]
+  Convert plugins to use InputPlayback.output instead of InputPlugin.output
+  
+  trunk/src/aac/src/libmp4.c             |   64 ++++++++++++++++----------------
+  trunk/src/adplug/adplug-xmms.cc        |   38 ++++++++++---------
+  trunk/src/alac/plugin.c                |    9 +++-
+  trunk/src/amidi-plug/amidi-plug.c      |   64 +++++++++++++++++---------------
+  trunk/src/amidi-plug/amidi-plug.h      |    4 +-
+  trunk/src/cdaudio/cdaudio.c            |   55 ++++++++++++++-------------
+  trunk/src/console/Audacious_Driver.cxx |   27 +++++++------
+  trunk/src/flac112/plugin.c             |   52 +++++++++++++-------------
+  trunk/src/flac113/plugin.c             |   40 ++++++++++----------
+  trunk/src/metronom/metronom.c          |   34 +++++++++--------
+  trunk/src/modplug/plugin.cxx           |    2 -
+  trunk/src/mpg123/layer1.c              |    4 +-
+  trunk/src/mpg123/layer2.c              |    4 +-
+  trunk/src/mpg123/layer3.c              |    4 +-
+  trunk/src/mpg123/mpg123.c              |   44 +++++++++++-----------
+  trunk/src/mpg123/mpg123.h              |    8 ++--
+  trunk/src/sexypsf/xmms.c               |   37 ++++++++++--------
+  trunk/src/sid/xmms-sid.c               |   36 +++++++++---------
+  trunk/src/sid/xmms-sid.h               |   10 ++---
+  trunk/src/tonegen/tonegen.c            |   35 +++++++++--------
+  trunk/src/tta/aud-tta.c                |   42 +++++++++++----------
+  trunk/src/vorbis/vorbis.c              |   66 ++++++++++++++++-----------------
+  trunk/src/wav/wav-sndfile.c            |   26 +++++++------
+  trunk/src/wav/wav-sndfile.h            |    8 ++--
+  trunk/src/wav/wav.c                    |   33 ++++++++--------
+  trunk/src/wma/wma.c                    |   43 +++++++++++----------
+  26 files changed, 408 insertions(+), 381 deletions(-)
+
+
 2007-01-29 01:41:50 +0000  Kiyoshi Aman <kiyoshi.aman@gmail.com>
   revision [1206]
   made null always build
--- a/src/mpg123/common.c	Sun Jan 28 21:09:12 2007 -0800
+++ b/src/mpg123/common.c	Sun Jan 28 22:14:55 2007 -0800
@@ -167,7 +167,8 @@
 */
 
 int
-mpgdec_stream_jump_to_frame(struct frame *fr, int frame)
+mpgdec_stream_jump_to_frame(InputPlayback *playback, struct frame *fr,
+			    int frame)
 {
     if (filept == NULL)
     {
@@ -175,7 +176,7 @@
 
         r = frame * (fr->framesize + 4);
         mpgdec_stream_close();
-        mpgdec_open_stream(mpgdec_filename, -1, r);
+        mpgdec_open_stream(playback, mpgdec_filename, -1, r);
     }
     else
     {
@@ -187,12 +188,12 @@
 }
 
 int
-mpgdec_stream_jump_to_byte(struct frame *fr, int byte)
+mpgdec_stream_jump_to_byte(InputPlayback *playback, struct frame *fr, int byte)
 {
     if (filept == NULL)
     {
         mpgdec_stream_close();
-        mpgdec_open_stream(mpgdec_filename, -1, (unsigned long)byte);
+        mpgdec_open_stream(playback, mpgdec_filename, -1, (unsigned long)byte);
     }
     else
     {
@@ -403,12 +404,13 @@
 }
 
 void
-mpgdec_open_stream(char *bs_filenam, int fd, unsigned long range)
+mpgdec_open_stream(InputPlayback *playback,
+		   char *bs_filenam, int fd, unsigned long range)
 {
     filept_opened = 1;
     filept = vfs_fopen(bs_filenam, "rb");
     if (filept != NULL) {
-        if (stream_init() == -1) mpgdec_info->eof = TRUE;
+        if (stream_init() == -1) playback->eof = TRUE;
     } else
 #ifdef HAVE_NEMESI
     if (!strncasecmp(bs_filenam, "rtsp://", 7)) {
@@ -416,11 +418,11 @@
         mpgdec_info->filesize = 0;
         mpgdec_info->network_stream = TRUE;
         mpgdec_info->stream_type = STREAM_RTSP;
-        if (mpgdec_rtsp_open(bs_filenam)) mpgdec_info->eof = TRUE;
+        if (mpgdec_rtsp_open(bs_filenam)) playback->eof = TRUE;
     } else 
 #endif
     {
-        mpgdec_info->eof = TRUE;
+        playback->eof = TRUE;
     }
 }
 
--- a/src/mpg123/layer1.c	Sun Jan 28 21:09:12 2007 -0800
+++ b/src/mpg123/layer1.c	Sun Jan 28 22:14:55 2007 -0800
@@ -157,7 +157,7 @@
                           16 ? FMT_S16_NE : FMT_U8,
                           mpgdec_cfg.channels ==
                           2 ? fr->stereo : 1, mpgdec_pcm_point,
-                          mpgdec_pcm_sample, &mpgdec_info->going);
+                          mpgdec_pcm_sample, &playback->playing);
         }
 
         mpgdec_pcm_point = 0;
--- a/src/mpg123/layer3.c	Sun Jan 28 21:09:12 2007 -0800
+++ b/src/mpg123/layer3.c	Sun Jan 28 22:14:55 2007 -0800
@@ -1854,7 +1854,7 @@
                           16 ? FMT_S16_NE : FMT_U8,
                           mpgdec_cfg.channels ==
                           2 ? fr->stereo : 1, mpgdec_pcm_point,
-                          mpgdec_pcm_sample, &mpgdec_info->going);
+                          mpgdec_pcm_sample, &playback->playing);
         }
 
         mpgdec_pcm_point = 0;
--- a/src/mpg123/mpg123.c	Sun Jan 28 21:09:12 2007 -0800
+++ b/src/mpg123/mpg123.c	Sun Jan 28 22:14:55 2007 -0800
@@ -33,7 +33,7 @@
 PlayerInfo *mpgdec_info = NULL;
 static GThread *decode_thread;
 
-static gboolean audio_error = FALSE, output_opened = FALSE, dopause = FALSE;
+static gboolean output_opened = FALSE, dopause = FALSE;
 gint mpgdec_bitrate, mpgdec_frequency, mpgdec_length, mpgdec_layer,
     mpgdec_lsf;
 gchar *mpgdec_title = NULL, *mpgdec_filename = NULL;
@@ -645,7 +645,8 @@
 
 
 static int
-mpgdec_seek(struct frame *fr, xing_header_t * xh, gboolean vbr, int time)
+mpgdec_seek(InputPlayback *playback, struct frame *fr, xing_header_t * xh, 
+	    gboolean vbr, int time)
 {
     int jumped = -1;
 
@@ -653,16 +654,16 @@
         int percent = ((double) time * 100.0) /
             (mpgdec_info->num_frames * mpgdec_info->tpf);
         int byte = mpgdec_seek_point(xh, percent);
-        jumped = mpgdec_stream_jump_to_byte(fr, byte);
+        jumped = mpgdec_stream_jump_to_byte(playback, fr, byte);
     }
     else if (vbr && mpgdec_length > 0) {
         int byte = ((guint64) time * 1000 * mpgdec_info->filesize) /
             mpgdec_length;
-        jumped = mpgdec_stream_jump_to_byte(fr, byte);
+        jumped = mpgdec_stream_jump_to_byte(playback, fr, byte);
     }
     else {
         int frame = time / mpgdec_info->tpf;
-        jumped = mpgdec_stream_jump_to_frame(fr, frame);
+        jumped = mpgdec_stream_jump_to_frame(playback, fr, frame);
     }
 
     return jumped;
@@ -688,12 +689,12 @@
 
     mpgdec_read_frame_init();
 
-    mpgdec_open_stream(filename, -1, 0);
+    mpgdec_open_stream(playback, filename, -1, 0);
 
-    if (mpgdec_info->eof || !mpgdec_read_frame(&fr))
-        mpgdec_info->eof = TRUE;
+    if (playback->eof || !mpgdec_read_frame(&fr))
+        playback->eof = TRUE;
 
-    if (!mpgdec_info->eof && mpgdec_info->going) {
+    if (!playback->eof && playback->playing) {
         if (mpgdec_cfg.channels == 2)
             fr.single = -1;
         else
@@ -715,7 +716,7 @@
         for (;;) {
             memcpy(&temp_fr, &fr, sizeof(struct frame));
             if (!mpgdec_read_frame(&temp_fr)) {
-                mpgdec_info->eof = TRUE;
+                playback->eof = TRUE;
                 break;
             }
             if (fr.lay != temp_fr.lay ||
@@ -788,26 +789,27 @@
         output_opened = TRUE;
 
         if (!open_output(playback)) {
-            audio_error = TRUE;
-            mpgdec_info->eof = TRUE;
+	    playback->error = TRUE;
+            playback->eof = TRUE;
         }
         else
             play_frame(playback, &fr);
     }
 
     mpgdec_info->first_frame = FALSE;
-    while (mpgdec_info->going) {
+    while (playback->playing) {
         if (mpgdec_info->jump_to_time != -1) {
             void *xp = NULL;
             if (have_xing_header)
                 xp = &xing_header;
-            if (mpgdec_seek(&fr, xp, vbr, mpgdec_info->jump_to_time) > -1) {
+            if (mpgdec_seek(playback, &fr, xp, vbr, 
+			    mpgdec_info->jump_to_time) > -1) {
                 playback->output->flush(mpgdec_info->jump_to_time * 1000);
-                mpgdec_info->eof = FALSE;
+                playback->eof = FALSE;
             }
             mpgdec_info->jump_to_time = -1;
         }
-        if (!mpgdec_info->eof) {
+        if (!playback->eof) {
             if (mpgdec_read_frame(&fr) != 0) {
                 if (fr.lay != mpgdec_layer || fr.lsf != mpgdec_lsf) {
                     memcpy(&temp_fr, &fr, sizeof(struct frame));
@@ -899,7 +901,7 @@
             else {
                 playback->output->buffer_free();
                 playback->output->buffer_free();
-                mpgdec_info->eof = TRUE;
+                playback->eof = TRUE;
                 g_usleep(10000);
             }
         }
@@ -915,11 +917,10 @@
     old_title = NULL;
     mpgdec_title = NULL;
     mpgdec_stream_close();
-    if (output_opened && !audio_error)
+    if (output_opened && !playback->error)
         playback->output->close_audio();
     g_free(mpgdec_pcm_sample);
     mpgdec_filename = NULL;
-    g_free(filename);
 
     return NULL;
 }
@@ -931,12 +932,13 @@
     memset(&temp_fr, 0, sizeof(struct frame));
 
     mpgdec_info = g_malloc0(sizeof(PlayerInfo));
-    mpgdec_info->going = 1;
+    mpgdec_info->playback = playback;
+    playback->playing = TRUE;
     mpgdec_info->first_frame = TRUE;
     mpgdec_info->output_audio = TRUE;
     mpgdec_info->jump_to_time = -1;
     skip_frames = 0;
-    audio_error = FALSE;
+    playback->error = FALSE;
     output_opened = FALSE;
     dopause = FALSE;
 
@@ -945,10 +947,10 @@
 }
 
 static void
-stop(InputPlayback * data)
+stop(InputPlayback * playback)
 {
-    if (mpgdec_info && mpgdec_info->going) {
-        mpgdec_info->going = FALSE;
+    if (mpgdec_info && playback->playing) {
+        playback->playing = FALSE;
         g_thread_join(decode_thread);
         g_free(mpgdec_info);
         mpgdec_info = NULL;
@@ -973,19 +975,6 @@
         dopause = p;
 }
 
-static int
-get_time(InputPlayback * playback)
-{
-    if (audio_error)
-        return -2;
-    if (!mpgdec_info)
-        return -1;
-    if (!mpgdec_info->going
-        || (mpgdec_info->eof && !playback->output->buffer_playing()))
-        return -1;
-    return playback->output->output_time();
-}
-
 static void
 aboutbox(void)
 {
@@ -1022,7 +1011,7 @@
     do_pause,
     seek,
     NULL,
-    get_time,
+    NULL,
     NULL, NULL,
     cleanup,
     NULL,
--- a/src/mpg123/mpg123.h	Sun Jan 28 21:09:12 2007 -0800
+++ b/src/mpg123/mpg123.h	Sun Jan 28 22:14:55 2007 -0800
@@ -129,7 +129,8 @@
 };
 
 typedef struct {
-    int going, num_frames, eof, jump_to_time, eq_active;
+    InputPlayback *playback;
+    int num_frames, jump_to_time, eq_active;
     int songtime;
     double tpf;
     float eq_mul[576];
@@ -242,7 +243,8 @@
 extern unsigned int mpgdec_getbits(int);
 extern unsigned int mpgdec_getbits_fast(int);
 
-extern void mpgdec_open_stream(char *bs_filenam, int fd, unsigned long range);
+extern void mpgdec_open_stream(InputPlayback *playback, char *bs_filenam,
+			       int fd, unsigned long range);
 extern int mpgdec_head_check(unsigned long);
 extern void mpgdec_stream_close(void);
 
@@ -285,8 +287,10 @@
 extern void mpgdec_read_frame_init(void);
 extern int mpgdec_read_frame(struct frame *fr);
 extern int mpgdec_back_frame(struct frame *fr, int num);
-int mpgdec_stream_jump_to_frame(struct frame *fr, int frame);
-int mpgdec_stream_jump_to_byte(struct frame *fr, int byte);
+int mpgdec_stream_jump_to_frame(InputPlayback *playback, struct frame *fr, 
+				int frame);
+int mpgdec_stream_jump_to_byte(InputPlayback *playback, struct frame *fr,
+			       int byte);
 int mpgdec_stream_check_for_xing_header(struct frame *fr,
                                         xing_header_t * xhead);
 int mpgdec_calc_numframes(struct frame *fr);