Skip to content

Commit

Permalink
Subtitles: Try to reenable the previously selected caption type.
Browse files Browse the repository at this point in the history
During DVD playback with AVSubs enabled, once in a while the decoder
disables and reenables subtitles.  If the DVD also contains cc608
captions, the caption priority order would favor cc608 and the user
would need to reselect AVSubs every time this happens.  To fix this,
we keep track of the previously selected caption type and default to
that if possible when captions are turned on.  This is in addition to
the existing code that tries to reselect the previous AVSubs track
when AVSubs are enabled.
  • Loading branch information
stichnot committed Mar 15, 2012
1 parent 20a5628 commit d3b4762
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythbase/mythversion.h
Expand Up @@ -12,7 +12,7 @@
/// Update this whenever the plug-in API changes.
/// Including changes in the libmythbase, libmyth, libmythtv, libmythav* and
/// libmythui class methods used by plug-ins.
#define MYTH_BINARY_VERSION "0.25.20120314-3"
#define MYTH_BINARY_VERSION "0.25.20120315-1"

/** \brief Increment this whenever the MythTV network protocol changes.
*
Expand Down
37 changes: 26 additions & 11 deletions mythtv/libs/libmythtv/mythplayer.cpp
Expand Up @@ -165,6 +165,7 @@ MythPlayer::MythPlayer(PlayerFlags flags)
// General Caption/Teletext/Subtitle support
textDisplayMode(kDisplayNone),
prevTextDisplayMode(kDisplayNone),
prevNonzeroTextDisplayMode(kDisplayNone),
// Support for analog captions and teletext
vbimode(VBIMode::None),
ttPageNum(0x888),
Expand Down Expand Up @@ -1317,6 +1318,8 @@ void MythPlayer::ResetCaptions(void)

void MythPlayer::DisableCaptions(uint mode, bool osd_msg)
{
if (textDisplayMode)
prevNonzeroTextDisplayMode = textDisplayMode;
textDisplayMode &= ~mode;
ResetCaptions();

Expand Down Expand Up @@ -1394,6 +1397,8 @@ void MythPlayer::EnableCaptions(uint mode, bool osd_msg)
.arg(mode).arg(msg));

textDisplayMode = mode;
if (textDisplayMode)
prevNonzeroTextDisplayMode = textDisplayMode;
if (osd_msg)
SetOSDMessage(msg, kOSDTimeout_Med);
}
Expand Down Expand Up @@ -1432,7 +1437,8 @@ void MythPlayer::SetCaptionsEnabled(bool enable, bool osd_msg)
DisableCaptions(origMode, osd_msg);
return;
}
int mode = NextCaptionTrack(kDisplayNone);
int mode = HasCaptionTrack(prevNonzeroTextDisplayMode) ?
prevNonzeroTextDisplayMode : NextCaptionTrack(kDisplayNone);
if (origMode != (uint)mode)
{
DisableCaptions(origMode, false);
Expand Down Expand Up @@ -1642,6 +1648,23 @@ void MythPlayer::ChangeCaptionTrack(int dir)
}
}

bool MythPlayer::HasCaptionTrack(int mode)
{
if (mode == kDisplayNone)
return false;
if (((mode == kDisplayTextSubtitle) && HasTextSubtitles()) ||
(mode == kDisplayNUVTeletextCaptions))
{
return true;
}
else if (!(mode == kDisplayTextSubtitle) &&
decoder->GetTrackCount(toTrackType(mode)))
{
return true;
}
return false;
}

int MythPlayer::NextCaptionTrack(int mode)
{
// Text->TextStream->708/608->608/708->AVSubs->Teletext->NUV->None
Expand All @@ -1666,17 +1689,9 @@ int MythPlayer::NextCaptionTrack(int mode)
else if (kDisplayNone == mode)
nextmode = kDisplayTextSubtitle;

if (((nextmode == kDisplayTextSubtitle) && HasTextSubtitles()) ||
(nextmode == kDisplayNUVTeletextCaptions) ||
(nextmode == kDisplayNone))
{
return nextmode;
}
else if (!(nextmode == kDisplayTextSubtitle) &&
decoder->GetTrackCount(toTrackType(nextmode)))
{
if (nextmode == kDisplayNone || HasCaptionTrack(nextmode))
return nextmode;
}

return NextCaptionTrack(nextmode);
}

Expand Down
2 changes: 2 additions & 0 deletions mythtv/libs/libmythtv/mythplayer.h
Expand Up @@ -478,6 +478,7 @@ class MTV_PUBLIC MythPlayer
int GetTrack(uint type);
int ChangeTrack(uint type, int dir);
void ChangeCaptionTrack(int dir);
bool HasCaptionTrack(int mode);
int NextCaptionTrack(int mode);
void DoDisableForcedSubtitles(void);
void DoEnableForcedSubtitles(void);
Expand Down Expand Up @@ -674,6 +675,7 @@ class MTV_PUBLIC MythPlayer
// General Caption/Teletext/Subtitle support
uint textDisplayMode;
uint prevTextDisplayMode;
uint prevNonzeroTextDisplayMode;

// Support for analog captions and teletext
// (i.e. Vertical Blanking Interval (VBI) encoded data.)
Expand Down

0 comments on commit d3b4762

Please sign in to comment.