summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Schmidt <jan@centricular.com>2015-11-11 00:59:16 +1100
committerJan Schmidt <jan@centricular.com>2015-11-11 01:33:55 +1100
commit797a0ca3765ab877f71e2150ff28d977db017757 (patch)
treeeae0946d0d42a60466d887e5b5662c0f20d22f1d
parent0b98ed32ce9db48089787f32c13c1a3db3ac36f3 (diff)
vorbisdec: Re-init on new caps
If we get new input caps, then reset the decoder ready for new headers and fresh data. Makes chained oggs work when reusing the decoder.
-rw-r--r--ext/vorbis/gstvorbisdec.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/ext/vorbis/gstvorbisdec.c b/ext/vorbis/gstvorbisdec.c
index f679d7ef7..bc0a20f9d 100644
--- a/ext/vorbis/gstvorbisdec.c
+++ b/ext/vorbis/gstvorbisdec.c
@@ -78,6 +78,7 @@ static gboolean vorbis_dec_stop (GstAudioDecoder * dec);
static GstFlowReturn vorbis_dec_handle_frame (GstAudioDecoder * dec,
GstBuffer * buffer);
static void vorbis_dec_flush (GstAudioDecoder * dec, gboolean hard);
+static gboolean vorbis_dec_set_format (GstAudioDecoder * dec, GstCaps * caps);
static void
gst_vorbis_dec_class_init (GstVorbisDecClass * klass)
@@ -102,6 +103,7 @@ gst_vorbis_dec_class_init (GstVorbisDecClass * klass)
base_class->start = GST_DEBUG_FUNCPTR (vorbis_dec_start);
base_class->stop = GST_DEBUG_FUNCPTR (vorbis_dec_stop);
+ base_class->set_format = GST_DEBUG_FUNCPTR (vorbis_dec_set_format);
base_class->handle_frame = GST_DEBUG_FUNCPTR (vorbis_dec_handle_frame);
base_class->flush = GST_DEBUG_FUNCPTR (vorbis_dec_flush);
}
@@ -632,3 +634,30 @@ vorbis_dec_flush (GstAudioDecoder * dec, gboolean hard)
vorbis_synthesis_restart (&vd->vd);
#endif
}
+
+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;
+
+ vd->initialized = FALSE;
+#ifndef USE_TREMOLO
+ vorbis_block_clear (&vd->vb);
+#endif
+ vorbis_dsp_clear (&vd->vd);
+
+ /* We need to free and re-init these,
+ * or libvorbis chokes */
+ vorbis_comment_clear (&vd->vc);
+ vorbis_info_clear (&vd->vi);
+ vorbis_info_init (&vd->vi);
+ vorbis_comment_init (&vd->vc);
+
+ return TRUE;
+}