ext/mad/gstmad.c: Don't call mad_stream_sync() directly after recovering sync.

Original commit message from CVS:
Reviewed by:  Ronald S. Bultje  <rbultje@ronald.bitfreak.net>
* ext/mad/gstmad.c: (gst_mad_chain):
Don't call mad_stream_sync() directly after recovering sync.
Fixes #151661.
This commit is contained in:
Ronald S. Bultje 2005-01-09 01:58:04 +00:00
parent f6caa6971e
commit d5257d4ea3
2 changed files with 31 additions and 15 deletions

View file

@ -1,3 +1,11 @@
2005-01-09 Francis Labonte <francis_labonte@hotmail.com>
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
* ext/mad/gstmad.c: (gst_mad_chain):
Don't call mad_stream_sync() directly after recovering sync.
Fixes #151661.
2005-01-09 Martin Eikermann <meiker@upb.de> 2005-01-09 Martin Eikermann <meiker@upb.de>
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net> Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>

View file

@ -1270,6 +1270,7 @@ gst_mad_chain (GstPad * pad, GstData * _data)
guint64 time_offset; guint64 time_offset;
guint64 time_duration; guint64 time_duration;
unsigned char const *before_sync, *after_sync; unsigned char const *before_sync, *after_sync;
gboolean resync = TRUE;
mad->in_error = FALSE; mad->in_error = FALSE;
@ -1329,6 +1330,9 @@ gst_mad_chain (GstPad * pad, GstData * _data)
* id3 tags, so we need to flush one byte less than the tagsize */ * id3 tags, so we need to flush one byte less than the tagsize */
mad_stream_skip (&mad->stream, tagsize - 1); mad_stream_skip (&mad->stream, tagsize - 1);
/* When we skip, we don't want to call sync */
resync = FALSE;
tag = id3_tag_parse (data, tagsize); tag = id3_tag_parse (data, tagsize);
if (tag) { if (tag) {
GstTagList *list; GstTagList *list;
@ -1350,23 +1354,27 @@ gst_mad_chain (GstPad * pad, GstData * _data)
} }
} }
} }
//Should not sync here if mad_skip has been used before, the offset
mad_frame_mute (&mad->frame); //is "pending" inside mad and will be applied on next call to decode.
mad_synth_mute (&mad->synth); if (resync) {
before_sync = mad->stream.ptr.byte; mad_frame_mute (&mad->frame);
if (mad_stream_sync (&mad->stream) != 0) mad_synth_mute (&mad->synth);
GST_WARNING ("mad_stream_sync failed"); before_sync = mad->stream.ptr.byte;
after_sync = mad->stream.ptr.byte; if (mad_stream_sync (&mad->stream) != 0)
/* a succesful resync should make us drop bytes as consumed, so GST_WARNING ("mad_stream_sync failed");
calculate from the byte pointers before and after resync */ after_sync = mad->stream.ptr.byte;
consumed = after_sync - before_sync; /* a succesful resync should make us drop bytes as consumed, so
GST_DEBUG ("resynchronization consumes %d bytes", consumed); calculate from the byte pointers before and after resync */
GST_DEBUG ("synced to data: 0x%0x 0x%0x", *mad->stream.ptr.byte, consumed = after_sync - before_sync;
*(mad->stream.ptr.byte + 1)); GST_DEBUG ("resynchronization consumes %d bytes", consumed);
GST_DEBUG ("synced to data: 0x%0x 0x%0x", *mad->stream.ptr.byte,
*(mad->stream.ptr.byte + 1));
mad_stream_sync (&mad->stream); mad_stream_sync (&mad->stream);
/* recoverable errors pass */ /* recoverable errors pass */
}
goto next; goto next;
} }