Commit d6825b35 authored by Wim Taymans's avatar Wim Taymans
Browse files

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.
parent 361eb99a
2005-09-29 Wim Taymans <wim@fluendo.com>
* 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 <wim@fluendo.com>
* ext/vorbis/vorbisdec.c: (gst_vorbis_dec_init):
......
common @ e6246e87
Subproject commit 7caeee4b949b4388927fec7fcf25f767429bde30
Subproject commit e6246e87e86c75b2c9c00d0748f0cd2332295eaa
......@@ -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;
......
......@@ -987,7 +987,7 @@ wrong_dimensions:
}
no_buffer:
{
return GST_FLOW_OK;
return result;
}
}
......
......@@ -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);
if (result == GST_FLOW_OK) {
float *out_data = (float *) GST_BUFFER_DATA (out);
/* count samples ready for reading */
if ((sample_count = vorbis_synthesis_pcmout (&vd->vd, NULL)) == 0)
goto done;
copy_samples (out_data, pcm, sample_count, vd->vi.channels);
/* 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;
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;
/* get samples ready for reading now, should be sample_count */
if ((vorbis_synthesis_pcmout (&vd->vd, &pcm)) != sample_count)
goto wrong_samples;
result = vorbis_dec_push (vd, out);
/* copy samples in buffer */
copy_samples ((float *) GST_BUFFER_DATA (out), pcm, sample_count,
vd->vi.channels);
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
......
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