matroska: Ref index table when updating track info

Track index table array was being lost during track info update.
Ref it over to updated info, so it can be used for finding
nearest seek points.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/1203>
This commit is contained in:
Rafał Dzięgiel 2021-05-07 10:44:15 +02:00 committed by GStreamer Marge Bot
parent 478f94edc7
commit 41385ab6f7
2 changed files with 10 additions and 2 deletions

View file

@ -3512,6 +3512,12 @@ gst_matroska_demux_update_tracks (GstMatroskaDemux * demux, GstEbmlRead * ebml)
new_track->pad = old_track->pad;
new_track->index = old_track->index;
new_track->pos = old_track->pos;
/* If index table is empty, do not ref it, we will try to fallback
* to the generic one from read-common in such case */
if (old_track->index_table && old_track->index_table->len > 0)
new_track->index_table = g_array_ref (old_track->index_table);
g_ptr_array_index (demux->common.src, old_track_index) = new_track;
gst_pad_set_element_private (new_track->pad, new_track);

View file

@ -591,10 +591,12 @@ gst_matroska_read_common_do_index_seek (GstMatroskaReadCommon * common,
GArray *index;
/* find entry just before or at the requested position */
if (track && track->index_table)
if (track && track->index_table) {
index = track->index_table;
else
} else {
GST_DEBUG_OBJECT (common->sinkpad, "Missing track index table");
index = common->index;
}
if (!index || !index->len)
return NULL;