Repository navigation
Add option to default to Last Captions State - #1183
Conversation
|
@SteveErl The setting migration is safe, which was the first thing I checked: Three things I noticed: The help text under the new selections still reads "If enabled, captions will be displayed when playing back recordings...", which described the old checkbox. With three choices it no longer matches the control.
|
|
@BobEntwhistle Thanks for your analysis. The help text has been fixed. Based on your suggestion, an enum for the |
This solution adds a LastCaptions entry into the Settings database. This boolean gets updated each time a user toggles captions on or off, and indicates whether captions were enabled or disabled the last time it changed. The m_captionsEnabledbyDefault variable is switched from a boolean to an unsigned int so that it can hold 0, 1, or 2. It's set to 2 when the Last Captions State configuration is selected. When starting up viewing of a video recording or Live TV, captions are either disabled (0), enabled (1), or set to match the last caption state (2). Resolves: MythTV#1154
The help text has been updated to describe
the three optional value. A missing space in
"duringplayback." has been added.
An enum for the m_captionsEnabledbyDefault values
has been introduced.
The call of SaveSetting("LastCaptions"...)
has been moved from ToggleCaptions() into
SetCaptionsEnabled() so that it will be updated
through actions other than just the toggle key.
ToggleCaptionsByType() has also been updated
to call SaveSetting("LastCaptions",...).
Resolves: MythTV#1154
|
@SteveErl Help text and the enum both look right to me now. On
None of those are new; they are all in current master, so this is something I should have spotted the first time rather than something your branch introduced. There is also a side effect in the current shape. The disable branch of if (!Enable)
{
DisableCaptions(origmode, UpdateOSD);
gCoreContext->SaveSetting("LastCaptions", false);
return;
}and A suggestion that covers all of it in one place. auto oldcaptions = m_captionsState.m_textDisplayMode;
m_captionsState.m_textDisplayMode = Mode; // or &= ~Mode in DisableCaptions
if (m_captionsState.m_textDisplayMode != kDisplayNone)
m_lastValidTextDisplayMode = m_captionsState.m_textDisplayMode;
if (oldcaptions != m_captionsState.m_textDisplayMode)
emit CaptionsStateChanged(m_captionsState);So a small helper called from inside that existing void MythPlayerCaptionsUI::SaveLastCaptionsState()
{
bool enabled = m_captionsState.m_textDisplayMode != kDisplayNone;
if (enabled != m_lastCaptionsEnabled)
{
m_lastCaptionsEnabled = enabled;
gCoreContext->SaveSetting("LastCaptions", enabled);
}
}That gets you four things:
One wrinkle worth knowing rather than fixing: The |
|
@BobEntwhistle I implemented your helper function, and added a temporary LOG message to see how often it was getting invoked. In Live TV, I enabled captions. Then I exited, and started it again. As you predicted, when the Last Caption State is Enabled, we end up writing to the database to turn it off and then immediately to turn it on again. I don't like these wasteful, unnecessary database writes. I'm going to try adding an optional third argument to In |
A helper function SaveLastCaptionsState() has been added to check for Captions Enabled state changes before writing to the database. This function will now get called from DisableCaptions() and EnableCaptions(). A third argument has been added to DisableCaptions() which specifies whether we want to write to the database, or not. Normally we will write to the database. However, in SetCaptionsEnabled() and SetTrack() there are calls to DisableCaptions() right before calling EnableCaptions(). We don't want to pay the cost of a database write which immediately gets overwritten, so we'll set the new third argument to false in DisableCaptions(). Resolves: MythTV#1154
|
@SteveErl That looks good to me. With For completeness, a few paths still do a disable followed by an enable with the default Tiny style point: the other parameters in these signatures are PascalCase ( |
To follow the PascalCase naming convention, the new argument name has been slightly altered. Resolves: MythTV#1154
|
@BobEntwhistle For completeness, I have code to cover the |
The new SaveInDb argument has been used to defer a database write which is about to be reversed in ToggleCaptionsByType() and ChangeCaptionTrack(). Resolves: MythTV#1154
|
@BobEntwhistle : Could you please add a Review Passed indicator? I think that would make it more likely that someone with merge privileges would merge in my changes. To give your approval to the Pull Request, click the Files changed tab near the top. Then click the green Submit review button. Click the Approve radio button, and optionally add some text, if you wish. Finally click the Submit review button at the bottom. This will add your name as a reviewer and a check-mark to indicate that it passed your review. Thanks! |
This change adds a new configuration option for mythfrontend closed captioning. Setup -> Video -> Playback OSD -> Always display Closed Captioning or Subtitles is switched to Default to display Closed Captioning or Subtitles and the user is able to pick a new configuration option.
A LastCaptions entry is added into the Settings database. This boolean gets updated each time a user toggles captions on or off, and indicates whether captions were enabled or disabled the last time it changed. The m_captionsEnabledbyDefault variable is switched from a boolean to an unsigned int so that it can hold 0, 1, or 2. It's set to 2 when the Last Captions State configuration is selected. When starting up viewing of a video recording or Live TV, by default, captions are either disabled (0), enabled (1), or set to match the last caption state (2).
When a user picks Last Captions State, mythfrontend will remember whether captions were enabled or disabled the last time something was watched, and will carry over that state for the next thing to be watched. Turn on captions, and they will continue to appear until you explicitly turn them off. Turn off captions and they will not appear until you explicitly turn them on.
Resolves: #1154
Checklist