Commit b95725c3 authored by Jochen Henneberg's avatar Jochen Henneberg Committed by Sebastian Dröge

vorbisdec: reset decoder on vorbis headers update

if the vorbis encoder receives new headers it must be
reset and re-initialized to continue decoding, e. g.
for live streams
parent bb051c14
...@@ -79,6 +79,7 @@ static GstFlowReturn vorbis_dec_handle_frame (GstAudioDecoder * dec, ...@@ -79,6 +79,7 @@ static GstFlowReturn vorbis_dec_handle_frame (GstAudioDecoder * dec,
GstBuffer * buffer); GstBuffer * buffer);
static void vorbis_dec_flush (GstAudioDecoder * dec, gboolean hard); static void vorbis_dec_flush (GstAudioDecoder * dec, gboolean hard);
static gboolean vorbis_dec_set_format (GstAudioDecoder * dec, GstCaps * caps); static gboolean vorbis_dec_set_format (GstAudioDecoder * dec, GstCaps * caps);
static void vorbis_dec_reset (GstAudioDecoder * dec);
static void static void
gst_vorbis_dec_class_init (GstVorbisDecClass * klass) gst_vorbis_dec_class_init (GstVorbisDecClass * klass)
...@@ -582,8 +583,8 @@ vorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer) ...@@ -582,8 +583,8 @@ vorbis_dec_handle_frame (GstAudioDecoder * dec, GstBuffer * buffer)
/* switch depending on packet type */ /* switch depending on packet type */
if ((gst_ogg_packet_data (packet))[0] & 1) { if ((gst_ogg_packet_data (packet))[0] & 1) {
if (vd->initialized) { if (vd->initialized) {
GST_WARNING_OBJECT (vd, "Already initialized, so ignoring header packet"); GST_INFO_OBJECT (vd, "already initialized, re-init");
goto done; vorbis_dec_reset (dec);
} }
result = vorbis_handle_header_packet (vd, packet); result = vorbis_handle_header_packet (vd, packet);
if (result != GST_FLOW_OK) if (result != GST_FLOW_OK)
...@@ -633,29 +634,37 @@ vorbis_dec_flush (GstAudioDecoder * dec, gboolean hard) ...@@ -633,29 +634,37 @@ vorbis_dec_flush (GstAudioDecoder * dec, gboolean hard)
#endif #endif
} }
static gboolean static void
vorbis_dec_set_format (GstAudioDecoder * dec, GstCaps * caps) vorbis_dec_reset (GstAudioDecoder * dec)
{ {
GstVorbisDec *vd = GST_VORBIS_DEC (dec); GstVorbisDec *vd = GST_VORBIS_DEC (dec);
GST_DEBUG_OBJECT (vd, "New caps %" GST_PTR_FORMAT " - resetting", caps);
/* A set_format call implies new data with new header packets */
if (!vd->initialized)
return TRUE;
vd->initialized = FALSE; vd->initialized = FALSE;
#ifndef USE_TREMOLO #ifndef USE_TREMOLO
vorbis_block_clear (&vd->vb); vorbis_block_clear (&vd->vb);
#endif #endif
vorbis_dsp_clear (&vd->vd); vorbis_dsp_clear (&vd->vd);
/* We need to free and re-init these,
* or libvorbis chokes */
vorbis_comment_clear (&vd->vc); vorbis_comment_clear (&vd->vc);
vorbis_info_clear (&vd->vi); vorbis_info_clear (&vd->vi);
vorbis_info_init (&vd->vi); vorbis_info_init (&vd->vi);
vorbis_comment_init (&vd->vc); vorbis_comment_init (&vd->vc);
}
static gboolean
vorbis_dec_set_format (GstAudioDecoder * dec, GstCaps * caps)
{
GstVorbisDec *vd = GST_VORBIS_DEC (dec);
GST_DEBUG_OBJECT (vd, "New caps %" GST_PTR_FORMAT " - resetting", caps);
/* A set_format call implies new data with new header packets */
if (!vd->initialized)
return TRUE;
/* We need to free and re-init libvorbis,
* or it chokes */
vorbis_dec_reset (dec);
return TRUE; return TRUE;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment