qtdemux: Use empty-array safe way to cleanup GPtrArray

Fix assertion fail
GLib-CRITICAL **: g_ptr_array_remove_range: assertion 'index_ < rarray->len' failed
This commit is contained in:
Seungha Yang 2019-08-01 15:02:23 +09:00
parent d365c4fdf9
commit 4146dc905d

View file

@ -2174,10 +2174,8 @@ gst_qtdemux_reset (GstQTDemux * qtdemux, gboolean hard)
if (hard) { if (hard) {
qtdemux->segment_seqnum = GST_SEQNUM_INVALID; qtdemux->segment_seqnum = GST_SEQNUM_INVALID;
qtdemux->trickmode_interval = 0; qtdemux->trickmode_interval = 0;
g_ptr_array_remove_range (qtdemux->active_streams, g_ptr_array_set_size (qtdemux->active_streams, 0);
0, qtdemux->active_streams->len); g_ptr_array_set_size (qtdemux->old_streams, 0);
g_ptr_array_remove_range (qtdemux->old_streams,
0, qtdemux->old_streams->len);
qtdemux->n_video_streams = 0; qtdemux->n_video_streams = 0;
qtdemux->n_audio_streams = 0; qtdemux->n_audio_streams = 0;
qtdemux->n_sub_streams = 0; qtdemux->n_sub_streams = 0;
@ -2284,7 +2282,7 @@ gst_qtdemux_stream_concat (GstQTDemux * qtdemux, GPtrArray * dest,
g_ptr_array_add (dest, gst_qtdemux_stream_ref (stream)); g_ptr_array_add (dest, gst_qtdemux_stream_ref (stream));
} }
g_ptr_array_remove_range (src, 0, len); g_ptr_array_set_size (src, 0);
} }
static gboolean static gboolean
@ -12909,9 +12907,7 @@ qtdemux_expose_streams (GstQTDemux * qtdemux)
return GST_FLOW_ERROR; return GST_FLOW_ERROR;
} }
g_ptr_array_remove_range (qtdemux->old_streams, g_ptr_array_set_size (qtdemux->old_streams, 0);
0, qtdemux->old_streams->len);
qtdemux->need_segment = TRUE; qtdemux->need_segment = TRUE;
return GST_FLOW_OK; return GST_FLOW_OK;
@ -12953,7 +12949,7 @@ qtdemux_expose_streams (GstQTDemux * qtdemux)
} }
} }
g_ptr_array_remove_range (qtdemux->old_streams, 0, qtdemux->old_streams->len); g_ptr_array_set_size (qtdemux->old_streams, 0);
/* check if we should post a redirect in case there is a single trak /* check if we should post a redirect in case there is a single trak
* and it is a redirecting trak */ * and it is a redirecting trak */