ext/lame/gstlame.c: Don't crash if we get an EOS event before the encoder has been set up (#339287).

Original commit message from CVS:
Patch by: Ed Catmur  <ed at catmur dot co dot uk>
* ext/lame/gstlame.c: (gst_lame_sink_event):
Don't crash if we get an EOS event before the encoder
has been set up (#339287).
This commit is contained in:
Ed Catmur 2006-04-21 12:40:41 +00:00 committed by Tim-Philipp Müller
parent 6b137b65ea
commit c9c991563e

View file

@ -951,12 +951,15 @@ gst_lame_sink_event (GstPad * pad, GstEvent * event)
switch (GST_EVENT_TYPE (event)) { switch (GST_EVENT_TYPE (event)) {
case GST_EVENT_EOS:{ case GST_EVENT_EOS:{
GST_DEBUG_OBJECT (lame, "handling EOS event");
if (lame->lgf != NULL) {
GstBuffer *buf; GstBuffer *buf;
gint size; gint size;
GST_DEBUG_OBJECT (lame, "handling EOS event");
buf = gst_buffer_new_and_alloc (7200); buf = gst_buffer_new_and_alloc (7200);
size = lame_encode_flush (lame->lgf, GST_BUFFER_DATA (buf), 7200); size = lame_encode_flush (lame->lgf, GST_BUFFER_DATA (buf), 7200);
if (size > 0) { if (size > 0) {
GST_BUFFER_SIZE (buf) = size; GST_BUFFER_SIZE (buf) = size;
GST_DEBUG_OBJECT (lame, "pushing final packet of %u bytes", size); GST_DEBUG_OBJECT (lame, "pushing final packet of %u bytes", size);
@ -966,6 +969,7 @@ gst_lame_sink_event (GstPad * pad, GstEvent * event)
GST_DEBUG_OBJECT (lame, "no final packet (size=%d)", size); GST_DEBUG_OBJECT (lame, "no final packet (size=%d)", size);
gst_buffer_unref (buf); gst_buffer_unref (buf);
} }
}
ret = gst_pad_event_default (pad, event); ret = gst_pad_event_default (pad, event);
break; break;