From d6825b358af204d01b03c475c4156d7e573e6c30 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 29 Sep 2005 19:12:44 +0000 Subject: [PATCH] ext/: Propagate error codes from alloc_buffer too. Original commit message from CVS: * ext/ogg/gstoggdemux.c: (gst_ogg_demux_chain_peer): * ext/theora/theoradec.c: (theora_handle_data_packet): * ext/vorbis/vorbisdec.c: (vorbis_handle_data_packet): Propagate error codes from alloc_buffer too. --- ChangeLog | 7 +++++ common | 2 +- ext/ogg/gstoggdemux.c | 3 +- ext/theora/theoradec.c | 2 +- ext/vorbis/vorbisdec.c | 69 ++++++++++++++++++++++++------------------ 5 files changed, 51 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 78de239f37..339cec482c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-09-29 Wim Taymans + + * ext/ogg/gstoggdemux.c: (gst_ogg_demux_chain_peer): + * ext/theora/theoradec.c: (theora_handle_data_packet): + * ext/vorbis/vorbisdec.c: (vorbis_handle_data_packet): + Propagate error codes from alloc_buffer too. + 2005-09-29 Wim Taymans * ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init): diff --git a/common b/common index 7caeee4b94..e6246e87e8 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 7caeee4b949b4388927fec7fcf25f767429bde30 +Subproject commit e6246e87e86c75b2c9c00d0748f0cd2332295eaa diff --git a/ext/ogg/gstoggdemux.c b/ext/ogg/gstoggdemux.c index 0c66c3adeb..1c4c544eaf 100644 --- a/ext/ogg/gstoggdemux.c +++ b/ext/ogg/gstoggdemux.c @@ -733,7 +733,6 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet) GstFlowReturn ret; GstOggDemux *ogg = pad->ogg; - ret = gst_pad_alloc_buffer (GST_PAD (pad), GST_BUFFER_OFFSET_NONE, packet->bytes, GST_PAD_CAPS (pad), &buf); @@ -747,6 +746,8 @@ gst_ogg_demux_chain_peer (GstOggPad * pad, ogg_packet * packet) GST_BUFFER_OFFSET_END (buf) = packet->granulepos; ret = gst_pad_push (GST_PAD (pad), buf); + if (ret == GST_FLOW_NOT_LINKED) + ret = GST_FLOW_OK; if (packet->granulepos != -1) { GstFormat format; diff --git a/ext/theora/theoradec.c b/ext/theora/theoradec.c index f7e03e956d..cca0296ea6 100644 --- a/ext/theora/theoradec.c +++ b/ext/theora/theoradec.c @@ -987,7 +987,7 @@ wrong_dimensions: } no_buffer: { - return GST_FLOW_OK; + return result; } } diff --git a/ext/vorbis/vorbisdec.c b/ext/vorbis/vorbisdec.c index c146a7800e..79b2360d4c 100644 --- a/ext/vorbis/vorbisdec.c +++ b/ext/vorbis/vorbisdec.c @@ -742,6 +742,7 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet) { float **pcm; guint sample_count; + GstBuffer *out; GstFlowReturn result; if (!vd->initialized) @@ -754,43 +755,46 @@ vorbis_handle_data_packet (GstVorbisDec * vd, ogg_packet * packet) if (vorbis_synthesis_blockin (&vd->vd, &vd->vb) < 0) goto not_accepted; - sample_count = vorbis_synthesis_pcmout (&vd->vd, &pcm); - if (sample_count > 0) { - GstBuffer *out; + /* assume all goes well here */ + result = GST_FLOW_OK; - result = gst_pad_alloc_buffer (vd->srcpad, GST_BUFFER_OFFSET_NONE, - sample_count * vd->vi.channels * sizeof (float), - GST_PAD_CAPS (vd->srcpad), &out); + /* count samples ready for reading */ + if ((sample_count = vorbis_synthesis_pcmout (&vd->vd, NULL)) == 0) + goto done; - if (result == GST_FLOW_OK) { - float *out_data = (float *) GST_BUFFER_DATA (out); + /* alloc buffer for it */ + result = gst_pad_alloc_buffer (vd->srcpad, GST_BUFFER_OFFSET_NONE, + sample_count * vd->vi.channels * sizeof (float), + GST_PAD_CAPS (vd->srcpad), &out); + if (result != GST_FLOW_OK) + goto done; - copy_samples (out_data, pcm, sample_count, vd->vi.channels); + /* get samples ready for reading now, should be sample_count */ + if ((vorbis_synthesis_pcmout (&vd->vd, &pcm)) != sample_count) + goto wrong_samples; - GST_BUFFER_OFFSET (out) = vd->granulepos; - if (vd->granulepos != -1) { - GST_BUFFER_OFFSET_END (out) = vd->granulepos + sample_count; - GST_BUFFER_TIMESTAMP (out) = - gst_util_uint64_scale (vd->granulepos, GST_SECOND, vd->vi.rate); - } else { - GST_BUFFER_TIMESTAMP (out) = -1; - } - GST_BUFFER_DURATION (out) = sample_count * GST_SECOND / vd->vi.rate; + /* copy samples in buffer */ + copy_samples ((float *) GST_BUFFER_DATA (out), pcm, sample_count, + vd->vi.channels); - result = vorbis_dec_push (vd, out); - - if (vd->granulepos != -1) - vd->granulepos += sample_count; - } else { - /* no buffer.. */ - result = GST_FLOW_OK; - } - vorbis_synthesis_read (&vd->vd, sample_count); + GST_BUFFER_OFFSET (out) = vd->granulepos; + if (vd->granulepos != -1) { + GST_BUFFER_OFFSET_END (out) = vd->granulepos + sample_count; + GST_BUFFER_TIMESTAMP (out) = + gst_util_uint64_scale (vd->granulepos, GST_SECOND, vd->vi.rate); } else { - /* no samples.. */ - result = GST_FLOW_OK; + GST_BUFFER_TIMESTAMP (out) = -1; } + GST_BUFFER_DURATION (out) = sample_count * GST_SECOND / vd->vi.rate; + if (vd->granulepos != -1) + vd->granulepos += sample_count; + + vorbis_synthesis_read (&vd->vd, sample_count); + + result = vorbis_dec_push (vd, out); + +done: /* granulepos is the last sample in the packet */ if (packet->granulepos != -1) vd->granulepos = packet->granulepos; @@ -816,6 +820,13 @@ not_accepted: (NULL), ("vorbis decoder did not accept data packet")); return GST_FLOW_ERROR; } +wrong_samples: + { + gst_buffer_unref (out); + GST_ELEMENT_ERROR (GST_ELEMENT (vd), STREAM, DECODE, + (NULL), ("vorbis decoder reported wrong number of samples")); + return GST_FLOW_ERROR; + } } static GstFlowReturn