diff -Nur audacious-plugins-fedora-1.5.1-orig/src/sndfile/plugin.c audacious-plugins-fedora-1.5.1/src/sndfile/plugin.c --- audacious-plugins-fedora-1.5.1-orig/src/sndfile/plugin.c 2008-06-08 10:37:44.000000000 +0200 +++ audacious-plugins-fedora-1.5.1/src/sndfile/plugin.c 2009-06-05 00:35:29.000000000 +0200 @@ -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) { @@ -407,17 +425,13 @@ playback->eof = TRUE; playback->playing = FALSE; - g_mutex_unlock(decode_mutex); 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 +491,7 @@ static void play_pause (InputPlayback *playback, gshort p) { - playback->output->pause(p); + pause_flag = p; } static void