diff --git a/ext/lame/gstlame.c b/ext/lame/gstlame.c index 6aefa6b9e0..f5265d43c7 100644 --- a/ext/lame/gstlame.c +++ b/ext/lame/gstlame.c @@ -581,6 +581,7 @@ gst_lame_init (GstLame * lame) id3tag_init (lame->lgf); + lame->newmediacount = 0; GST_DEBUG_OBJECT (lame, "done initializing"); } @@ -950,6 +951,21 @@ gst_lame_chain (GstPad * pad, GstData * _data) g_assert_not_reached (); } gst_pad_event_default (pad, GST_EVENT (buf)); + break; + case GST_EVENT_DISCONTINUOUS: + if (GST_EVENT_DISCONT_NEW_MEDIA (GST_EVENT (buf))) { + /* do not re-initialise if it is first new media discont */ + if (lame->newmediacount++ > 0) { + lame_close (lame->lgf); + lame->lgf = lame_init (); + lame->initialized = FALSE; + lame->last_ts = GST_CLOCK_TIME_NONE; + + gst_lame_setup (lame); + } + } + gst_pad_event_default (pad, GST_EVENT (buf)); + break; default: gst_pad_event_default (pad, GST_EVENT (buf)); diff --git a/ext/lame/gstlame.h b/ext/lame/gstlame.h index 1eccb83ea3..fbb01c7b37 100644 --- a/ext/lame/gstlame.h +++ b/ext/lame/gstlame.h @@ -100,6 +100,9 @@ struct _GstLame { /* time tracker */ guint64 last_ts, last_offs, last_duration; + + /* new media count */ + gint16 newmediacount; }; struct _GstLameClass {