From 97b14e3d7c463965295281bb05eb3e5609fee7e3 Mon Sep 17 00:00:00 2001 From: Scott Theisen Date: Fri, 27 Dec 2024 23:59:58 -0500 Subject: [PATCH] remove DecoderBase::InsertTrack() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It does not make semantic sense to modify m_tracks from outside DecoderBase or its subclasses. DecoderBase::InsertTrack() is only used by cc708reader.cpp for kTrackTypeCC708 The call graph eventually goes back to AvFormatDecoder::DecodeCCx08() which will call AvFormatDecoder::UpdateCaptionTracksFromStreams() afterwards, which calls AvFormatDecoder::UpdateATSCCaptionTracks() which will clear m_tracks[kTrackTypeCC608] and m_tracks[kTrackTypeCC708]. Therefore, the inserted track is immediately deleted before it is used. However, the emitted signal may do something, although I don’t know why it sends a signal to itself instead of being able to call it directly. The signal would be emitted if a track for that service_num was not in AvFormatDecoder::m_tracks. However, this does not make sense since the selected track has not changed and this track did not exist, so it was not in use to change. If there were no kTrackTypeCC708 tracks, the signal will still be emitted when AvFormatDecoder::GetFrame() next calls DecoderBase::AutoSelectTracks(). --- mythtv/libs/libmythtv/captions/cc708reader.cpp | 5 ----- mythtv/libs/libmythtv/decoders/decoderbase.cpp | 18 ------------------ mythtv/libs/libmythtv/decoders/decoderbase.h | 1 - 3 files changed, 24 deletions(-) diff --git a/mythtv/libs/libmythtv/captions/cc708reader.cpp b/mythtv/libs/libmythtv/captions/cc708reader.cpp index 87166c69d85..b3a34491c92 100644 --- a/mythtv/libs/libmythtv/captions/cc708reader.cpp +++ b/mythtv/libs/libmythtv/captions/cc708reader.cpp @@ -61,11 +61,6 @@ void CC708Reader::DefineWindow( int row_lock, int column_lock, int pen_style, int window_style) { - if (m_parent && m_parent->GetDecoder()) - { - StreamInfo si {-1, static_cast(service_num)}; - m_parent->GetDecoder()->InsertTrack(kTrackTypeCC708, si); - } CHECKENABLED; diff --git a/mythtv/libs/libmythtv/decoders/decoderbase.cpp b/mythtv/libs/libmythtv/decoders/decoderbase.cpp index 9b30ab19ba1..e820b755998 100644 --- a/mythtv/libs/libmythtv/decoders/decoderbase.cpp +++ b/mythtv/libs/libmythtv/decoders/decoderbase.cpp @@ -1013,24 +1013,6 @@ int DecoderBase::NextTrack(uint Type) return next_track; } -bool DecoderBase::InsertTrack(uint Type, const StreamInfo &Info) -{ - QMutexLocker locker(&m_trackLock); - - if (std::any_of(m_tracks[Type].cbegin(), m_tracks[Type].cend(), - [&](const StreamInfo& Si) { return Si.m_stream_id == Info.m_stream_id; } )) - { - return false; - } - - m_tracks[Type].push_back(Info); - - if (m_parent) - emit m_parent->SignalTracksChanged(Type); - - return true; -} - /** \fn DecoderBase::BestTrack(uint, bool) * \brief Determine the best track according to weights * diff --git a/mythtv/libs/libmythtv/decoders/decoderbase.h b/mythtv/libs/libmythtv/decoders/decoderbase.h index 6712dff2161..46dde3eda0a 100644 --- a/mythtv/libs/libmythtv/decoders/decoderbase.h +++ b/mythtv/libs/libmythtv/decoders/decoderbase.h @@ -233,7 +233,6 @@ class DecoderBase int GetTrack(uint Type); StreamInfo GetTrackInfo(uint Type, uint TrackNo); int ChangeTrack(uint Type, int Dir); - virtual bool InsertTrack(uint Type, const StreamInfo &Info); int NextTrack(uint Type); virtual int GetTeletextDecoderType(void) const { return -1; }