From 41385ab6f7e2464d4b364e52a1a27334108b226b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Dzi=C4=99giel?= Date: Fri, 7 May 2021 10:44:15 +0200 Subject: [PATCH] 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: --- subprojects/gst-plugins-good/gst/matroska/matroska-demux.c | 6 ++++++ .../gst-plugins-good/gst/matroska/matroska-read-common.c | 6 ++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/gst/matroska/matroska-demux.c b/subprojects/gst-plugins-good/gst/matroska/matroska-demux.c index ae3588487b..52a76b9d9c 100644 --- a/subprojects/gst-plugins-good/gst/matroska/matroska-demux.c +++ b/subprojects/gst-plugins-good/gst/matroska/matroska-demux.c @@ -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); diff --git a/subprojects/gst-plugins-good/gst/matroska/matroska-read-common.c b/subprojects/gst-plugins-good/gst/matroska/matroska-read-common.c index 2b63c03d56..eb317644cc 100644 --- a/subprojects/gst-plugins-good/gst/matroska/matroska-read-common.c +++ b/subprojects/gst-plugins-good/gst/matroska/matroska-read-common.c @@ -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;