I am attaching five patches, one for audacious and four for audacious-plugins.
These patches remove the ugly workaround and update the following plugins
to work correctly without it (or with it, for that matter):

   CD Audio Plugin NG
   MPEG Audio Plugin
   Ogg Vorbis Audio Plugin
   sndfile plugin

These patches fix both problems which I reported.

Other plugins may still have problems when the workaround is removed; I have
not tested any others.

John
--- cdaudio-ng.0.c	2008-05-23 18:44:19.000000000 -0400
+++ cdaudio-ng.c	2009-03-02 23:20:24.000000000 -0500
@@ -690,6 +690,23 @@
 	return tuple;
 }
 
+static void do_seek (dae_params_t * pdae_params) {
+	pdae_params->pplayback->output->flush(pdae_params->seektime);
+	pdae_params->currlsn = pdae_params->startlsn + (pdae_params->seektime * 75 / 1000);
+	cdio_lseek(pcdio, pdae_params->currlsn * CDIO_CD_FRAMESIZE_RAW, SEEK_SET);
+	pdae_params->seektime = -1;
+}
+
+static void do_pause (dae_params_t * pdae_params) {
+	pdae_params->pplayback->output->pause (1);
+	while (is_paused) {
+		if (pdae_params->seektime != -1)
+			do_seek (pdae_params);
+		g_usleep(50000);
+	}
+	pdae_params->pplayback->output->pause (0);
+}
+
 static void dae_play_loop(dae_params_t *pdae_params)
 {
 	guchar *buffer = g_new(guchar, CDDA_DAE_FRAMES * CDIO_CD_FRAMESIZE_RAW);
@@ -697,39 +714,15 @@
 	debug("dae started\n");
 	cdio_lseek(pcdio, pdae_params->startlsn * CDIO_CD_FRAMESIZE_RAW, SEEK_SET);
 
-	gboolean output_paused = FALSE;
 	gint read_error_counter = 0;
 
 	//pdae_params->endlsn += 75 * 3;
 
 	while (pdae_params->pplayback->playing) {
-		/* handle pause status */
-		if (is_paused) {
-			if (!output_paused) {
-				debug("playback was not paused, pausing\n");
-				pdae_params->pplayback->output->pause(TRUE);
-				output_paused = TRUE;
-			}
-			g_usleep(1000);
-			continue;
-		}
-		else {
-			if (output_paused) {
-				debug("playback was paused, resuming\n");
-				pdae_params->pplayback->output->pause(FALSE);
-				output_paused = FALSE;
-			}
-		}
-
-		/* check if we have to seek */
-		if (pdae_params->seektime != -1) {
-			debug("requested seek to %d ms\n", pdae_params->seektime);
-			gint newlsn = pdae_params->startlsn + ((pdae_params->seektime * 75) / 1000);
-			cdio_lseek(pcdio, newlsn * CDIO_CD_FRAMESIZE_RAW, SEEK_SET);
-			pdae_params->pplayback->output->flush(pdae_params->seektime);
-			pdae_params->currlsn = newlsn;
-			pdae_params->seektime = -1;
-		}
+		if (pdae_params->seektime != -1)
+			do_seek (pdae_params);
+		if (is_paused)
+			do_pause (pdae_params);
 
 		/* compute the actual number of sectors to read */
 		gint lsncount = CDDA_DAE_FRAMES <= (pdae_params->endlsn - pdae_params->currlsn + 1) ? CDDA_DAE_FRAMES : (pdae_params->endlsn - pdae_params->currlsn + 1);
--- plugin.0.c	2008-05-23 18:44:19.000000000 -0400
+++ plugin.c	2009-03-02 22:55:15.000000000 -0500
@@ -448,6 +448,7 @@
     info.playback = playback;
     info.seek = millisecond;
     g_mutex_unlock(pb_mutex);
+    playback->output->flush (millisecond / 1000);
 }
 
 static void
--- playback.0.c	2008-05-23 18:00:34.000000000 -0400
+++ playback.c	2009-03-02 02:11:02.000000000 -0500
@@ -441,33 +441,13 @@
 playback_seek(gint time)
 {
     InputPlayback *playback = get_current_input_playback();
-    gboolean restore_pause = FALSE;
-    gint l=0, r=0;
 
     g_return_if_fail(ip_data.playing);
     g_return_if_fail(playback != NULL);
 
-    /* FIXME WORKAROUND...that should work with all plugins
-     * mute the volume, start playback again, do the seek, then pause again
-     * -Patrick Sudowe 
-     */
-    if (ip_data.paused)
-    {
-        restore_pause = TRUE;
-        output_get_volume(&l, &r);
-        output_set_volume(0,0);
-        playback_pause();
-    }
-    
     plugin_set_current((Plugin *)(playback->plugin));
     playback->plugin->seek(playback, time);
     playback->set_pb_change(playback);
-    
-    if (restore_pause)
-    {
-        playback_pause();
-        output_set_volume(l, r);
-    }
 
     event_queue_timed(100, "playback seek", playback);
 }
--- plugin.0.c	2008-05-23 18:44:20.000000000 -0400
+++ plugin.c	2009-03-02 23:13:37.000000000 -0500
@@ -47,6 +47,7 @@
 static gint song_length;
 static gint bit_rate = 0;
 static glong seek_time = -1;
+static volatile char pause_flag;
 
 static GThread *decode_thread;
 static GMutex *decode_mutex;
@@ -121,6 +122,7 @@
 plugin_init (void)
 {
     seek_time = -1;
+    pause_flag = 0;
 
     decode_mutex = g_mutex_new();
     decode_cond = g_cond_new();
@@ -362,6 +364,22 @@
     return TRUE;
 }
 
+static void do_seek (InputPlayback * playback) {
+   playback->output->flush (seek_time);
+   sf_seek (sndfile, (long long) seek_time * sfinfo.samplerate / 1000, SEEK_SET);
+   seek_time = -1;
+}
+
+static void do_pause (InputPlayback * playback) {
+   playback->output->pause (1);
+   while (pause_flag) {
+      if (seek_time != -1)
+         do_seek (playback);
+      g_usleep(50000);
+   }
+   playback->output->pause (0);
+}
+
 static gpointer
 play_loop (gpointer arg)
 {
@@ -411,13 +429,10 @@
             break;
         }
 
-        /* Do seek if seek_time is valid. */
-        if (seek_time >= 0) {
-            sf_seek (sndfile, (sf_count_t)((gint64)seek_time * (gint64)sfinfo.samplerate / 1000L),
-                     SEEK_SET);
-            playback->output->flush (seek_time);
-            seek_time = -1;
-        }
+        if (seek_time != -1)
+           do_seek (playback);
+        if (pause_flag)
+           do_pause (playback);
 
         if (playback->playing == FALSE)
             break;
@@ -477,7 +492,7 @@
 static void
 play_pause (InputPlayback *playback, gshort p)
 {
-    playback->output->pause(p);
+   pause_flag = p;
 }
 
 static void
--- vorbis.0.c	2008-05-23 18:44:20.000000000 -0400
+++ vorbis.c	2009-03-02 01:51:28.000000000 -0500
@@ -120,6 +120,7 @@
 
 static GThread *thread;
 static volatile int seekneeded = -1;
+static volatile char pause_flag;
 static int samplerate, channels;
 GMutex *vf_mutex;
 
@@ -228,6 +229,16 @@
     }
 }
 
+static void do_pause (InputPlayback * playback) {
+   playback->output->pause (1);
+   while (pause_flag) {
+      if (seekneeded != -1)
+         do_seek (playback);
+      g_usleep(50000);
+   }
+   playback->output->pause (0);
+}
+
 #define PCM_FRAMES 1024
 #define PCM_BUFSIZE PCM_FRAMES*2
 
@@ -338,6 +349,8 @@
 
         if (seekneeded != -1)
             do_seek(playback);
+        if (pause_flag)
+            do_pause (playback);
 
         
         int current_section = last_section;
@@ -488,7 +501,7 @@
 static void
 vorbis_pause(InputPlayback *playback, short p)
 {
-    playback->output->pause(p);
+    pause_flag = p;
 }
 
 static void

Reply via email to