mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-27 04:01:08 +00:00
ext/a52dec/gsta52dec.c: Use GST_ELEMENT_ERROR for error reporting; post errors in some more places; remove superfluou...
Original commit message from CVS: * ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push), (gst_a52dec_reneg), (gst_a52dec_handle_frame), (gst_a52dec_chain): Use GST_ELEMENT_ERROR for error reporting; post errors in some more places; remove superfluous newlines from debug statements.
This commit is contained in:
parent
3c862cf828
commit
6733054117
2 changed files with 34 additions and 23 deletions
|
@ -1,3 +1,10 @@
|
||||||
|
2006-08-07 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
|
* ext/a52dec/gsta52dec.c: (gst_a52dec_channels), (gst_a52dec_push),
|
||||||
|
(gst_a52dec_reneg), (gst_a52dec_handle_frame), (gst_a52dec_chain):
|
||||||
|
Use GST_ELEMENT_ERROR for error reporting; post errors in some
|
||||||
|
more places; remove superfluous newlines from debug statements.
|
||||||
|
|
||||||
2006-08-07 Tim-Philipp Müller <tim at centricular dot net>
|
2006-08-07 Tim-Philipp Müller <tim at centricular dot net>
|
||||||
|
|
||||||
Patch by: Frédéric Riss <frederic.riss at gmail com>
|
Patch by: Frédéric Riss <frederic.riss at gmail com>
|
||||||
|
|
|
@ -269,8 +269,7 @@ gst_a52dec_channels (int flags, GstAudioChannelPosition ** _pos)
|
||||||
chans += 2;
|
chans += 2;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
/* error */
|
/* error, caller should post error message */
|
||||||
g_warning ("a52dec invalid flags %d", flags);
|
|
||||||
g_free (pos);
|
g_free (pos);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -289,6 +288,8 @@ gst_a52dec_push (GstA52Dec * a52dec,
|
||||||
flags &= (A52_CHANNEL_MASK | A52_LFE);
|
flags &= (A52_CHANNEL_MASK | A52_LFE);
|
||||||
chans = gst_a52dec_channels (flags, NULL);
|
chans = gst_a52dec_channels (flags, NULL);
|
||||||
if (!chans) {
|
if (!chans) {
|
||||||
|
GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), STREAM, DECODE, (NULL),
|
||||||
|
("invalid channel flags: %d", flags));
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -316,10 +317,9 @@ gst_a52dec_push (GstA52Dec * a52dec,
|
||||||
}
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
gst_a52dec_reneg (GstPad * pad)
|
gst_a52dec_reneg (GstA52Dec * a52dec, GstPad * pad)
|
||||||
{
|
{
|
||||||
GstAudioChannelPosition *pos;
|
GstAudioChannelPosition *pos;
|
||||||
GstA52Dec *a52dec = GST_A52DEC (gst_pad_get_parent (pad));
|
|
||||||
gint channels = gst_a52dec_channels (a52dec->using_channels, &pos);
|
gint channels = gst_a52dec_channels (a52dec->using_channels, &pos);
|
||||||
GstCaps *caps = NULL;
|
GstCaps *caps = NULL;
|
||||||
gboolean result = FALSE;
|
gboolean result = FALSE;
|
||||||
|
@ -327,7 +327,7 @@ gst_a52dec_reneg (GstPad * pad)
|
||||||
if (!channels)
|
if (!channels)
|
||||||
goto done;
|
goto done;
|
||||||
|
|
||||||
GST_INFO ("a52dec: reneg channels:%d rate:%d\n",
|
GST_INFO_OBJECT (a52dec, "reneg channels:%d rate:%d",
|
||||||
channels, a52dec->sample_rate);
|
channels, a52dec->sample_rate);
|
||||||
|
|
||||||
caps = gst_caps_new_simple ("audio/x-raw-float",
|
caps = gst_caps_new_simple ("audio/x-raw-float",
|
||||||
|
@ -346,7 +346,6 @@ gst_a52dec_reneg (GstPad * pad)
|
||||||
done:
|
done:
|
||||||
if (caps)
|
if (caps)
|
||||||
gst_caps_unref (caps);
|
gst_caps_unref (caps);
|
||||||
gst_object_unref (GST_OBJECT (a52dec));
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -455,9 +454,9 @@ gst_a52dec_handle_frame (GstA52Dec * a52dec, guint8 * data,
|
||||||
|
|
||||||
/* negotiate if required */
|
/* negotiate if required */
|
||||||
if (need_reneg == TRUE) {
|
if (need_reneg == TRUE) {
|
||||||
GST_DEBUG ("a52dec reneg: sample_rate:%d stream_chans:%d using_chans:%d\n",
|
GST_DEBUG ("a52dec reneg: sample_rate:%d stream_chans:%d using_chans:%d",
|
||||||
a52dec->sample_rate, a52dec->stream_channels, a52dec->using_channels);
|
a52dec->sample_rate, a52dec->stream_channels, a52dec->using_channels);
|
||||||
if (!gst_a52dec_reneg (a52dec->srcpad)) {
|
if (!gst_a52dec_reneg (a52dec, a52dec->srcpad)) {
|
||||||
GST_ELEMENT_ERROR (a52dec, CORE, NEGOTIATION, (NULL), (NULL));
|
GST_ELEMENT_ERROR (a52dec, CORE, NEGOTIATION, (NULL), (NULL));
|
||||||
return GST_FLOW_ERROR;
|
return GST_FLOW_ERROR;
|
||||||
}
|
}
|
||||||
|
@ -507,23 +506,19 @@ gst_a52dec_sink_setcaps (GstPad * pad, GstCaps * caps)
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
gst_a52dec_chain (GstPad * pad, GstBuffer * buf)
|
gst_a52dec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
{
|
{
|
||||||
GstA52Dec *a52dec = GST_A52DEC (gst_pad_get_parent (pad));
|
GstA52Dec *a52dec = GST_A52DEC (GST_PAD_PARENT (pad));
|
||||||
GstFlowReturn ret;
|
GstFlowReturn ret;
|
||||||
|
gint first_access;
|
||||||
|
|
||||||
if (a52dec->dvdmode) {
|
if (a52dec->dvdmode) {
|
||||||
gint size = GST_BUFFER_SIZE (buf);
|
gint size = GST_BUFFER_SIZE (buf);
|
||||||
guchar *data = GST_BUFFER_DATA (buf);
|
guchar *data = GST_BUFFER_DATA (buf);
|
||||||
gint first_access;
|
|
||||||
gint offset;
|
gint offset;
|
||||||
gint len;
|
gint len;
|
||||||
GstBuffer *subbuf;
|
GstBuffer *subbuf;
|
||||||
|
|
||||||
if (size < 2) {
|
if (size < 2)
|
||||||
GST_ERROR_OBJECT (pad, "Insufficient data in buffer. "
|
goto not_enough_data;
|
||||||
"Can't determine first_acess");
|
|
||||||
ret = GST_FLOW_ERROR;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
first_access = (data[0] << 8) | data[1];
|
first_access = (data[0] << 8) | data[1];
|
||||||
|
|
||||||
|
@ -534,12 +529,8 @@ gst_a52dec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
/* Length of data before first_access */
|
/* Length of data before first_access */
|
||||||
len = first_access - 1;
|
len = first_access - 1;
|
||||||
|
|
||||||
if (len <= 0 || offset + len > size) {
|
if (len <= 0 || offset + len > size)
|
||||||
GST_ERROR_OBJECT (pad, "Bad first_access parameter (%d) in buffer",
|
goto bad_first_access_parameter;
|
||||||
first_access);
|
|
||||||
ret = GST_FLOW_ERROR;
|
|
||||||
goto done;
|
|
||||||
}
|
|
||||||
|
|
||||||
subbuf = gst_buffer_create_sub (buf, offset, len);
|
subbuf = gst_buffer_create_sub (buf, offset, len);
|
||||||
GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE;
|
GST_BUFFER_TIMESTAMP (subbuf) = GST_CLOCK_TIME_NONE;
|
||||||
|
@ -567,9 +558,22 @@ gst_a52dec_chain (GstPad * pad, GstBuffer * buf)
|
||||||
}
|
}
|
||||||
|
|
||||||
done:
|
done:
|
||||||
gst_object_unref (a52dec);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
/* ERRORS */
|
||||||
|
not_enough_data:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), STREAM, DECODE, (NULL),
|
||||||
|
("Insufficient data in buffer. Can't determine first_acess"));
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
|
bad_first_access_parameter:
|
||||||
|
{
|
||||||
|
GST_ELEMENT_ERROR (GST_ELEMENT (a52dec), STREAM, DECODE, (NULL),
|
||||||
|
("Bad first_access parameter (%d) in buffer", first_access));
|
||||||
|
return GST_FLOW_ERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstFlowReturn
|
static GstFlowReturn
|
||||||
|
|
Loading…
Reference in a new issue