# HG changeset patch # User Tony Vroon # Date 1236170900 0 # Node ID e2e8f927a08aef3a0b48a60c30d903f2eeea65c8 # Parent fc666525b41069b97313939a43b1c8d35ce06ba2 Patch from John Lindgren to support seeking whilst paused, Debian bug #517692. diff -r fc666525b410 -r e2e8f927a08a src/sndfile/plugin.c --- a/src/sndfile/plugin.c Wed Mar 04 12:48:09 2009 +0000 +++ b/src/sndfile/plugin.c Wed Mar 04 12:48:20 2009 +0000 @@ -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(); @@ -364,6 +366,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) { @@ -413,13 +431,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; @@ -479,7 +494,7 @@ static void play_pause (InputPlayback *playback, gshort p) { - playback->output->pause(p); + pause_flag = p; } static void