Skip to content

Commit

Permalink
MythDVDPlayer: Add specific method for disabling DVD subs
Browse files Browse the repository at this point in the history
- which is signalled (thread safe) from the decoder, allowing the
removal of the GetCaptionsMode call, which was not thread safe.
  • Loading branch information
mark-kendall committed Feb 19, 2021
1 parent 48458d0 commit 4225ff0
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
14 changes: 6 additions & 8 deletions mythtv/libs/libmythtv/DVD/mythdvddecoder.cpp
Expand Up @@ -485,7 +485,7 @@ void MythDVDDecoder::PostProcessTracks(void)
m_tracks[kTrackTypeSubtitle] = filteredTracks;
stable_sort(m_tracks[kTrackTypeSubtitle].begin(), m_tracks[kTrackTypeSubtitle].end());

int trackNo = -1;
int track = -1;
int selectedStream = m_ringBuffer->DVD()->GetTrack(kTrackTypeSubtitle);

// Now iterate over the sorted list and try to find the index of the
Expand All @@ -509,19 +509,17 @@ void MythDVDDecoder::PostProcessTracks(void)
.arg(iso639_key_toName(stream. m_language)));

if ((selectedStream != -1) && (stream.m_stream_id == selectedStream))
trackNo = static_cast<int>(idx);
track = static_cast<int>(idx);
}

uint captionmode = m_parent->GetCaptionMode();
int trackcount = static_cast<int>(m_tracks[kTrackTypeSubtitle].size());

if (captionmode == kDisplayAVSubtitle && (trackNo < 0 || trackNo >= trackcount))
if (auto * dvdplayer = dynamic_cast<MythDVDPlayer*>(m_parent); dvdplayer && (track < 0 || track >= trackcount))
{
m_parent->EnableSubtitles(false);
emit dvdplayer->DisableDVDSubtitles();
}
else if (trackNo >= 0 && trackNo < trackcount)
else if (track >= 0 && track < trackcount)
{
SetTrack(kTrackTypeSubtitle, trackNo);
SetTrack(kTrackTypeSubtitle, track);
m_parent->EnableSubtitles(true);
}
}
Expand Down
7 changes: 7 additions & 0 deletions mythtv/libs/libmythtv/DVD/mythdvdplayer.cpp
Expand Up @@ -12,6 +12,7 @@ MythDVDPlayer::MythDVDPlayer(MythMainWindow* MainWindow, TV* Tv, PlayerContext*
{
connect(Tv, &TV::GoToMenu, this, &MythDVDPlayer::GoToMenu);
connect(Tv, &TV::GoToDVDProgram, this, &MythDVDPlayer::GoToDVDProgram);
connect(this, &MythDVDPlayer::DisableDVDSubtitles, this, &MythDVDPlayer::DoDisableDVDSubtitles);
}

void MythDVDPlayer::AutoDeint(MythVideoFrame *Frame, MythVideoOutput *VideoOutput,
Expand Down Expand Up @@ -49,6 +50,12 @@ bool MythDVDPlayer::HasReachedEof(void) const
return eof != kEofStateNone && !m_allPaused;
}

void MythDVDPlayer::DoDisableDVDSubtitles()
{
if (kDisplayAVSubtitle == m_captionsState.m_textDisplayMode)
SetCaptionsEnabled(false, false);
}

void MythDVDPlayer::DisableCaptions(uint Mode, bool OSDMsg)
{
if ((kDisplayAVSubtitle & Mode) && m_playerCtx->m_buffer->IsDVD())
Expand Down
4 changes: 4 additions & 0 deletions mythtv/libs/libmythtv/DVD/mythdvdplayer.h
Expand Up @@ -11,6 +11,9 @@ class MythDVDPlayer : public MythPlayerUI
{
Q_OBJECT

signals:
void DisableDVDSubtitles();

public:
MythDVDPlayer(MythMainWindow* MainWindow, TV* Tv, PlayerContext* Context,PlayerFlags Flags = kNoFlags);

Expand Down Expand Up @@ -62,6 +65,7 @@ class MythDVDPlayer : public MythPlayerUI
void DisableCaptions(uint Mode, bool OSDMsg = true) override;
void EnableCaptions(uint Mode, bool OSDMsg = true) override;
void SetTrack(uint Type, uint TrackNo) override;
void DoDisableDVDSubtitles();

private:
void DisplayDVDButton(void);
Expand Down
1 change: 0 additions & 1 deletion mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -191,7 +191,6 @@ class MTV_PUBLIC MythPlayer : public QObject
virtual bool PrepareAudioSample(std::chrono::milliseconds &timecode);

// Public Closed caption and teletext stuff
virtual uint GetCaptionMode() const { return kDisplayNone; }
virtual CC708Reader *GetCC708Reader(uint /*id*/=0) { return &m_cc708; }
virtual CC608Reader *GetCC608Reader(uint /*id*/=0) { return &m_cc608; }
virtual SubtitleReader *GetSubReader(uint /*id*/=0) { return &m_subReader; }
Expand Down
5 changes: 0 additions & 5 deletions mythtv/libs/libmythtv/mythplayercaptionsui.cpp
Expand Up @@ -265,11 +265,6 @@ void MythPlayerCaptionsUI::ToggleCaptions()
SetCaptionsEnabled(!(static_cast<bool>(m_captionsState.m_textDisplayMode)));
}

uint MythPlayerCaptionsUI::GetCaptionMode() const
{
return m_captionsState.m_textDisplayMode;
}

void MythPlayerCaptionsUI::ToggleCaptionsByType(uint Type)
{
QMutexLocker locker(&m_osdLock);
Expand Down
2 changes: 0 additions & 2 deletions mythtv/libs/libmythtv/mythplayercaptionsui.h
Expand Up @@ -20,8 +20,6 @@ class MTV_PUBLIC MythPlayerCaptionsUI : public MythPlayerAudioUI
MythPlayerCaptionsUI(MythMainWindow* MainWindow, TV* Tv, PlayerContext* Context, PlayerFlags Flags);
~MythPlayerCaptionsUI() override;

uint GetCaptionMode() const override;

// N.B. These methods handle audio tracks as well. Fix.
QStringList GetTracks(uint Type);
uint GetTrackCount(uint Type);
Expand Down

0 comments on commit 4225ff0

Please sign in to comment.