diff --git a/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c b/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c index 76aa2e78dd..4675dc8401 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c +++ b/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.c @@ -501,8 +501,15 @@ mpegts_base_steal_program (MpegTSBase * base, gint program_number) for (i = 0; i < base->programs->len; i++) { MpegTSBaseProgram *program = g_ptr_array_index (base->programs, i); - if (program->program_number == program_number) + if (program->program_number == program_number) { +#if GLIB_CHECK_VERSION(2, 58, 0) return g_ptr_array_steal_index (base->programs, i); +#else + program->recycle = TRUE; + g_ptr_array_remove_index (base->programs, i); + return program; +#endif + } } return NULL; @@ -523,6 +530,11 @@ mpegts_base_free_program (MpegTSBaseProgram * program) { GList *tmp; + if (program->recycle) { + program->recycle = FALSE; + return; + } + if (program->pmt) { gst_mpegts_section_unref (program->section); program->pmt = NULL; diff --git a/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.h b/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.h index 8965c48d1f..3d463f4e46 100644 --- a/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.h +++ b/subprojects/gst-plugins-bad/gst/mpegtsdemux/mpegtsbase.h @@ -95,6 +95,9 @@ struct _MpegTSBaseProgram gboolean active; /* TRUE if this is the first program created */ gboolean initial_program; + + /* TRUE if the program shouldn't be freed */ + gboolean recycle; }; typedef enum {