From: Tim-Philipp Müller Date: Fri, 9 Feb 2007 16:24:45 +0000 (+0000) Subject: ext/lame/gstlame.*: On receiving EOS, we try to push a last buffer with the remaining... X-Git-Tag: 1.19.3~505^2~1809 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0d4e832887cc67d15e8e7c72ea64c47a0a883237;p=platform%2Fupstream%2Fgstreamer.git 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). --- diff --git a/ChangeLog b/ChangeLog index e2555ac..d7d4f66 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2007-02-09 Tim-Philipp Müller + + * 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 * gst/synaesthesia/gstsynaesthesia.c: diff --git a/ext/lame/gstlame.c b/ext/lame/gstlame.c index 92f8bef..24853da 100644 --- a/ext/lame/gstlame.c +++ b/ext/lame/gstlame.c @@ -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; diff --git a/ext/lame/gstlame.h b/ext/lame/gstlame.h index 71bfacc..bcae339 100644 --- a/ext/lame/gstlame.h +++ b/ext/lame/gstlame.h @@ -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 */ diff --git a/gst/mpegaudioparse/gstmpegaudioparse.c b/gst/mpegaudioparse/gstmpegaudioparse.c index 6e52b57..68b62fd 100644 --- a/gst/mpegaudioparse/gstmpegaudioparse.c +++ b/gst/mpegaudioparse/gstmpegaudioparse.c @@ -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"); } - } - gst_object_unref (mp3parse); + if (GST_FLOW_IS_FATAL (flow)) + break; + } - return GST_FLOW_OK; + return flow; } static gboolean