From c41d3d87fa975a9a6829766d60e7553c0cd28a1c Mon Sep 17 00:00:00 2001 From: Jan Schmidt Date: Mon, 20 Apr 2009 18:33:09 +0100 Subject: flac: Make buffers created during seek act like normal buffers. Store the offset and caps when allocating a buffer during seeking, and then allocate a new buffer with buffer_alloc before we push it out. This ensures that in all respects the first buffer decoded during seeking behaves like all other buffers, including allowing downstream re-negotiation. --- ext/flac/gstflacdec.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'ext/flac') diff --git a/ext/flac/gstflacdec.c b/ext/flac/gstflacdec.c index 5f6c82c7..f8eb818c 100644 --- a/ext/flac/gstflacdec.c +++ b/ext/flac/gstflacdec.c @@ -931,8 +931,18 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame, GST_BUFFER_OFFSET (flacdec->pending), GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (flacdec->pending)), GST_TIME_ARGS (GST_BUFFER_DURATION (flacdec->pending))); - gst_pad_push (flacdec->srcpad, flacdec->pending); - flacdec->pending = NULL; + /* Pending buffer was always allocated from the seeking thread, + * which means it wasn't gst_buffer_alloc'd. Do so now to let + * downstream negotiation work on older basetransform */ + ret = gst_pad_alloc_buffer_and_set_caps (flacdec->srcpad, + GST_BUFFER_OFFSET (flacdec->pending), + GST_BUFFER_SIZE (flacdec->pending), + GST_BUFFER_CAPS (flacdec->pending), &outbuf); + if (ret == GST_FLOW_OK) + gst_pad_push (flacdec->srcpad, outbuf); + + gst_buffer_unref (flacdec->pending); + outbuf = flacdec->pending = NULL; flacdec->segment.last_stop += flacdec->pending_samples; flacdec->pending_samples = 0; } @@ -940,7 +950,8 @@ gst_flac_dec_write (GstFlacDec * flacdec, const FLAC__Frame * frame, if (flacdec->seeking) { GST_DEBUG_OBJECT (flacdec, "a pad_alloc would block here, do normal alloc"); outbuf = gst_buffer_new_and_alloc (samples * channels * (width / 8)); - outbuf->offset = flacdec->segment.last_stop; + gst_buffer_set_caps (outbuf, GST_PAD_CAPS (flacdec->srcpad)); + GST_BUFFER_OFFSET (outbuf) = flacdec->segment.last_stop; } else { GST_LOG_OBJECT (flacdec, "alloc_buffer_and_set_caps"); ret = gst_pad_alloc_buffer_and_set_caps (flacdec->srcpad, -- cgit