ext/lame/gstlame.*: On receiving EOS, we try to push a last buffer with the remaining samples. Don't do that if we go...

Original commit message from CVS:
* ext/lame/gstlame.c: (gst_lame_sink_event), (gst_lame_chain),
(gst_lame_change_state):
* ext/lame/gstlame.h:
On receiving EOS, we try to push a last buffer with the remaining
samples. Don't do that if we got an unclean flow return on the last
gst_pad_push(), downstream might not handle this very gracefully
(see #403168).
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_chain):
Pass flow returns upstream (helps #403168).
This commit is contained in:
Tim-Philipp Müller 2007-02-09 16:24:45 +00:00
parent 9f8cdabb6c
commit 0d4e832887
4 changed files with 29 additions and 9 deletions

View file

@ -1,3 +1,16 @@
2007-02-09 Tim-Philipp Müller <tim at centricular dot net>
* ext/lame/gstlame.c: (gst_lame_sink_event), (gst_lame_chain),
(gst_lame_change_state):
* ext/lame/gstlame.h:
On receiving EOS, we try to push a last buffer with the remaining
samples. Don't do that if we got an unclean flow return on the last
gst_pad_push(), downstream might not handle this very gracefully
(see #403168).
* gst/mpegaudioparse/gstmpegaudioparse.c: (gst_mp3parse_chain):
Pass flow returns upstream (helps #403168).
2007-02-09 Stefan Kost <ensonic@users.sf.net>
* gst/synaesthesia/gstsynaesthesia.c:

View file

@ -920,7 +920,7 @@ gst_lame_sink_event (GstPad * pad, GstEvent * event)
buf = gst_buffer_new_and_alloc (7200);
size = lame_encode_flush (lame->lgf, GST_BUFFER_DATA (buf), 7200);
if (size > 0) {
if (size > 0 && lame->last_flow == GST_FLOW_OK) {
gint64 duration;
duration = gst_util_uint64_scale_int (size, GST_SECOND,
@ -941,7 +941,8 @@ gst_lame_sink_event (GstPad * pad, GstEvent * event)
gst_buffer_set_caps (buf, GST_PAD_CAPS (lame->srcpad));
gst_pad_push (lame->srcpad, buf);
} else {
GST_DEBUG_OBJECT (lame, "no final packet (size=%d)", size);
GST_DEBUG_OBJECT (lame, "no final packet (size=%d, last_flow=%s)",
size, gst_flow_get_name (lame->last_flow));
gst_buffer_unref (buf);
}
}
@ -1064,6 +1065,7 @@ gst_lame_chain (GstPad * pad, GstBuffer * buf)
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (lame->srcpad));
result = gst_pad_push (lame->srcpad, outbuf);
lame->last_flow = result;
if (result != GST_FLOW_OK) {
GST_DEBUG_OBJECT (lame, "flow return: %s", gst_flow_get_name (result));
}
@ -1201,6 +1203,7 @@ gst_lame_change_state (GstElement * element, GstStateChange transition)
switch (transition) {
case GST_STATE_CHANGE_READY_TO_PAUSED:
lame->last_flow = GST_FLOW_OK;
lame->last_ts = GST_CLOCK_TIME_NONE;
lame->eos_ts = GST_CLOCK_TIME_NONE;
break;

View file

@ -93,6 +93,9 @@ struct _GstLame {
gboolean emphasis;
gint preset;
/* track this so we don't send a last buffer in eos handler after error */
GstFlowReturn last_flow;
lame_global_flags *lgf;
/* time tracker */

View file

@ -319,6 +319,7 @@ gst_mp3parse_sink_event (GstPad * pad, GstEvent * event)
static GstFlowReturn
gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
{
GstFlowReturn flow = GST_FLOW_OK;
GstMPEGAudioParse *mp3parse;
const guchar *data;
guint32 header;
@ -327,10 +328,9 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
GstClockTime timestamp;
guint available;
mp3parse = GST_MP3PARSE (gst_pad_get_parent (pad));
mp3parse = GST_MP3PARSE (GST_PAD_PARENT (pad));
GST_DEBUG_OBJECT (mp3parse, "received buffer of %d bytes",
GST_BUFFER_SIZE (buf));
GST_LOG_OBJECT (mp3parse, "buffer of %d bytes", GST_BUFFER_SIZE (buf));
timestamp = GST_BUFFER_TIMESTAMP (buf);
@ -472,7 +472,7 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
gst_buffer_set_caps (outbuf, GST_PAD_CAPS (mp3parse->srcpad));
gst_pad_push (mp3parse->srcpad, outbuf);
flow = gst_pad_push (mp3parse->srcpad, outbuf);
} else {
GST_DEBUG_OBJECT (mp3parse, "skipping buffer of %d bytes",
@ -486,11 +486,12 @@ gst_mp3parse_chain (GstPad * pad, GstBuffer * buf)
gst_adapter_flush (mp3parse->adapter, 1);
GST_DEBUG_OBJECT (mp3parse, "wrong header, skipping byte");
}
if (GST_FLOW_IS_FATAL (flow))
break;
}
gst_object_unref (mp3parse);
return GST_FLOW_OK;
return flow;
}
static gboolean