Attached are patches for the following plugins, as well as a corrected one for
the MPEG Audio Plugin:
FLACng Audio Plugin
MP4 Audio Plugin
Windows Media Audio (WMA) Plugin
John
--- plugin.0.c 2008-05-23 18:44:19.000000000 -0400
+++ plugin.c 2009-03-03 22:20:51.000000000 -0500
@@ -56,6 +56,7 @@
callback_info* main_info;
gboolean plugin_initialized = FALSE;
glong seek_to = -1;
+static volatile char pause_flag = 0;
static GThread* thread = NULL;
/* === */
@@ -302,6 +303,22 @@
/* --- */
+static void do_seek (InputPlayback * playback) {
+ playback->output->flush (seek_to);
+ FLAC__stream_decoder_seek_absolute (main_decoder, (long long) seek_to * main_info->stream.samplerate / 1000);
+ seek_to = -1;
+}
+
+static void do_pause (InputPlayback * playback) {
+ playback->output->pause (1);
+ while (pause_flag) {
+ if (seek_to != -1)
+ do_seek (playback);
+ g_usleep(50000);
+ }
+ playback->output->pause (0);
+}
+
static gpointer flac_play_loop(gpointer arg) {
/*
@@ -312,7 +329,6 @@
gint32* read_pointer;
gint elements_left;
- gint seek_sample;
FLAC__StreamDecoderState state;
struct stream_info stream_info;
guint sample_count;
@@ -432,24 +448,10 @@
main_info->buffer_free = BUFFER_SIZE_SAMP;
main_info->buffer_used = 0;
- /*
- * Do we have to seek to somewhere?
- */
- if (-1 != seek_to) {
- _DEBUG("Seek requested to %d milliseconds", seek_to);
-
- seek_sample = (unsigned long)((gint64)seek_to * (gint64) main_info->stream.samplerate / 1000L );
- _DEBUG("Seek requested to sample %d", seek_sample);
- if (FALSE == FLAC__stream_decoder_seek_absolute(main_decoder, seek_sample)) {
- _ERROR("Could not seek to sample %d!", seek_sample);
- } else {
- /*
- * Flush the buffers
- */
- flac_ip.output->flush(seek_to);
- }
- seek_to = -1;
- }
+ if (seek_to != -1)
+ do_seek (playback);
+ if (pause_flag)
+ do_pause (playback);
/*
* Have we reached the end of the stream?
@@ -564,12 +566,7 @@
/* --- */
void flac_pause(InputPlayback* input, gshort p) {
-
- _ENTER;
-
- input->output->pause(p);
-
- _LEAVE;
+ pause_flag = p;
}
/* --- */
--- libmp4.0.c 2008-05-23 18:44:19.000000000 -0400
+++ libmp4.c 2009-03-03 23:17:09.000000000 -0500
@@ -76,6 +76,7 @@
static GThread *decodeThread;
GStaticMutex mutex = G_STATIC_MUTEX_INIT;
static int seekPosition = -1;
+static volatile char pause_flag;
void getMP4info(char*);
int getAACTrack(mp4ff_t *);
@@ -100,6 +101,7 @@
{
mp4cfg.file_type = FILE_UNKNOWN;
seekPosition = -1;
+ pause_flag = 0;
return;
}
@@ -296,7 +298,7 @@
static void mp4_pause(InputPlayback *playback, short flag)
{
- playback->output->pause(flag);
+ pause_flag = flag;
}
static void mp4_seek(InputPlayback *data, int time)
@@ -542,6 +544,19 @@
seekPosition = -1;
}
+ if (pause_flag) {
+ playback->output->pause (1);
+ while (pause_flag) {
+ if (seekPosition != -1) {
+ playback->output->flush (seekPosition * 1000);
+ sampleID = (long long) seekPosition * samplerate / (framesize - 1);
+ seekPosition = -1;
+ }
+ g_usleep(50000);
+ }
+ playback->output->pause (0);
+ }
+
/* Otherwise continue playing */
buffer=NULL;
bufferSize=0;
--- plugin.0.c 2008-05-23 18:44:19.000000000 -0400
+++ plugin.c 2009-03-03 20:40:19.000000000 -0500
@@ -448,6 +448,7 @@
info.playback = playback;
info.seek = millisecond;
g_mutex_unlock(pb_mutex);
+ playback->output->flush (millisecond);
}
static void
--- wma.0.c 2008-05-23 18:44:20.000000000 -0400
+++ wma.c 2009-03-03 20:44:08.000000000 -0500
@@ -194,15 +194,12 @@
static void wma_do_pause(InputPlayback *playback, short p)
{
wma_pause = p;
- playback->output->pause(wma_pause);
}
static void wma_seek(InputPlayback *playback, int time)
{
wma_seekpos = time;
- if(wma_pause) playback->output->pause(0);
while(wma_decode && wma_seekpos!=-1) g_usleep(10000);
- if(wma_pause) playback->output->pause(1);
}
static void _assoc_string(Tuple *tuple, const gint nfield, const gchar *str)
@@ -285,6 +282,22 @@
(*title_real) = aud_tuple_formatter_make_title_string(tuple, aud_get_gentitle_format());
}
+static void do_seek (InputPlayback * playback, AVFormatContext * context, int index) {
+ playback->output->flush (wma_seekpos * 1000);
+ av_seek_frame (context, index, (long long) wma_seekpos * 1000000);
+ wma_seekpos = -1;
+}
+
+static void do_pause (InputPlayback * playback, AVFormatContext * context, int index) {
+ playback->output->pause (1);
+ while (wma_pause) {
+ if (wma_seekpos != -1)
+ do_seek (playback, context, index);
+ g_usleep(50000);
+ }
+ playback->output->pause (0);
+}
+
static void wma_play_file(InputPlayback *playback)
{
AVCodec *codec;
@@ -333,11 +346,9 @@
while(playback->playing)
{
if(wma_seekpos != -1)
- {
- av_seek_frame(ic, wma_idx, wma_seekpos * 1000000LL);
- playback->output->flush(wma_seekpos * 1000);
- wma_seekpos = -1;
- }
+ do_seek (playback, ic, wma_idx);
+ if (wma_pause)
+ do_pause (playback, ic, wma_idx);
if(av_read_frame(ic, &pkt) < 0) break;