Skip to content

Commit 6812321

Browse files
author
Mark Kendall
committed
Video Visual: Refactor visualisation OSD menu entry.
- move to enable/disable rather than toggle. - toggle functionality retained. - move the visualiser entry below audio sync.
1 parent ef516ae commit 6812321

File tree

7 files changed

+46
-18
lines changed

7 files changed

+46
-18
lines changed

mythtv/libs/libmythtv/mythplayer.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4850,10 +4850,17 @@ bool MythPlayer::CanVisualise(void)
48504850
return false;
48514851
}
48524852

4853-
bool MythPlayer::ToggleVisualisation(void)
4853+
bool MythPlayer::IsVisualising(void)
48544854
{
48554855
if (videoOutput)
4856-
return videoOutput->ToggleVisualisation(&audio);
4856+
return videoOutput->GetVisualisation();
4857+
return false;
4858+
}
4859+
4860+
bool MythPlayer::EnableVisualisation(bool enable)
4861+
{
4862+
if (videoOutput)
4863+
return videoOutput->EnableVisualisation(&audio, enable);
48574864
return false;
48584865
}
48594866

mythtv/libs/libmythtv/mythplayer.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,8 @@ class MTV_PUBLIC MythPlayer
304304

305305
// Visualisations
306306
bool CanVisualise(void);
307-
bool ToggleVisualisation(void);
307+
bool IsVisualising(void);
308+
bool EnableVisualisation(bool enable);
308309

309310
void SaveTotalDuration(void);
310311
void ResetTotalDuration(void);

mythtv/libs/libmythtv/tv_actions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,9 @@
7676
#define ACTION_REVEAL "REVEAL"
7777

7878
/* Visualisations */
79-
#define ACTION_TOGGLEVISUALISATION "TOGGLEVISUALISATION"
79+
#define ACTION_TOGGLEVISUALISATION "TOGGLEVISUALISATION"
80+
#define ACTION_ENABLEVISUALISATION "ENABLEVISUALISATION"
81+
#define ACTION_DISABLEVISUALISATION "DISABLEVISUALISATION"
8082

8183
/* OSD playback information screen */
8284
#define ACTION_TOGGLEOSDDEBUG "DEBUGOSD"

mythtv/libs/libmythtv/tv_play.cpp

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4116,7 +4116,11 @@ bool TV::ToggleHandleAction(PlayerContext *ctx,
41164116
else if (has_action("TOGGLEAUDIOSYNC", actions))
41174117
ChangeAudioSync(ctx, 0); // just display
41184118
else if (has_action(ACTION_TOGGLEVISUALISATION, actions))
4119-
ToggleVisualisation(ctx);
4119+
EnableVisualisation(ctx, false, true /*toggle*/);
4120+
else if (has_action(ACTION_ENABLEVISUALISATION, actions))
4121+
EnableVisualisation(ctx, true);
4122+
else if (has_action(ACTION_DISABLEVISUALISATION, actions))
4123+
EnableVisualisation(ctx, false);
41204124
else if (has_action("TOGGLEPICCONTROLS", actions))
41214125
DoTogglePictureAttribute(ctx, kAdjustingPicture_Playback);
41224126
else if (has_action(ACTION_TOGGLESTUDIOLEVELS, actions))
@@ -4162,12 +4166,15 @@ bool TV::ToggleHandleAction(PlayerContext *ctx,
41624166
return handled;
41634167
}
41644168

4165-
void TV::ToggleVisualisation(const PlayerContext *ctx)
4169+
void TV::EnableVisualisation(const PlayerContext *ctx, bool enable, bool toggle)
41664170
{
41674171
ctx->LockDeletePlayer(__FILE__, __LINE__);
41684172
if (ctx->player && ctx->player->CanVisualise())
41694173
{
4170-
bool on = ctx->player->ToggleVisualisation();
4174+
bool want = enable;
4175+
if (toggle)
4176+
want = !ctx->player->IsVisualising();
4177+
bool on = ctx->player->EnableVisualisation(want);
41714178
SetOSDMessage(ctx, on ? tr("Visualisation On") :
41724179
tr("Visualisation Off"));
41734180
}
@@ -9632,7 +9639,11 @@ void TV::OSDDialogEvent(int result, QString text, QString action)
96329639
else if (action.left(15) == "TOGGLEAUDIOSYNC")
96339640
ChangeAudioSync(actx, 0);
96349641
else if (action == ACTION_TOGGLEVISUALISATION)
9635-
ToggleVisualisation(actx);
9642+
EnableVisualisation(actx, false, true /*toggle*/);
9643+
else if (action == ACTION_ENABLEVISUALISATION)
9644+
EnableVisualisation(actx, true);
9645+
else if (action == ACTION_DISABLEVISUALISATION)
9646+
EnableVisualisation(actx, false);
96369647
else if (action.left(11) == ACTION_TOGGLESLEEP)
96379648
{
96389649
ToggleSleepTimer(actx, action.left(13));
@@ -9897,10 +9908,12 @@ void TV::FillOSDMenuAudio(const PlayerContext *ctx, OSD *osd,
98979908
uint curtrack = ~0;
98989909
bool avsync = true;
98999910
bool visual = false;
9911+
bool active = false;
99009912
ctx->LockDeletePlayer(__FILE__, __LINE__);
99019913
if (ctx->player)
99029914
{
99039915
visual = ctx->player->CanVisualise();
9916+
active = ctx->player->IsVisualising();
99049917
tracks = ctx->player->GetTracks(kTrackTypeAudio);
99059918
if (!tracks.empty())
99069919
curtrack = (uint) ctx->player->GetTrack(kTrackTypeAudio);
@@ -9928,13 +9941,18 @@ void TV::FillOSDMenuAudio(const PlayerContext *ctx, OSD *osd,
99289941
"DIALOG_MENU_AUDIOTRACKS_0", true,
99299942
selected == "AUDIOTRACKS");
99309943
}
9931-
if (visual)
9932-
{
9933-
osd->DialogAddButton(tr("Toggle Visualisation"),
9934-
ACTION_TOGGLEVISUALISATION);
9935-
}
99369944
if (avsync)
99379945
osd->DialogAddButton(tr("Adjust Audio Sync"), "TOGGLEAUDIOSYNC");
9946+
if (visual && !active)
9947+
{
9948+
osd->DialogAddButton(tr("Enable Visualisation"),
9949+
ACTION_ENABLEVISUALISATION);
9950+
}
9951+
if (visual && active)
9952+
{
9953+
osd->DialogAddButton(tr("Disable Visualisation"),
9954+
ACTION_DISABLEVISUALISATION);
9955+
}
99389956
osd->DialogAddButton(tr("Toggle Audio Upmixer"), ACTION_TOGGLEUPMIX);
99399957
}
99409958
else if (category == "AUDIOTRACKS")

mythtv/libs/libmythtv/tv_play.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,7 +592,7 @@ class MTV_PUBLIC TV : public QObject
592592
bool DiscMenuHandleAction(PlayerContext*, const QStringList &actions);
593593

594594
// Visualisations
595-
void ToggleVisualisation(const PlayerContext*);
595+
void EnableVisualisation(const PlayerContext*, bool enable, bool toggle = false);
596596

597597
// Program jumping stuff
598598
void SetLastProgram(const ProgramInfo *rcinfo);

mythtv/libs/libmythtv/videooutbase.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,9 +1351,9 @@ bool VideoOutput::DisplayOSD(VideoFrame *frame, OSD *osd)
13511351
return show;
13521352
}
13531353

1354-
bool VideoOutput::ToggleVisualisation(AudioPlayer *audio)
1354+
bool VideoOutput::EnableVisualisation(AudioPlayer *audio, bool enable)
13551355
{
1356-
if (m_visual)
1356+
if (!enable)
13571357
{
13581358
DestroyVisualisation();
13591359
return false;

mythtv/libs/libmythtv/videooutbase.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,12 +246,12 @@ class VideoOutput
246246
QRect GetSafeRect(void);
247247

248248
// Visualisations
249-
bool ToggleVisualisation(AudioPlayer *audio);
249+
bool EnableVisualisation(AudioPlayer *audio, bool enable);
250250
virtual bool CanVisualise(AudioPlayer *audio, MythRender *render);
251251
virtual bool SetupVisualisation(AudioPlayer *audio, MythRender *render);
252+
VideoVisual* GetVisualisation(void) { return m_visual; }
252253
void DestroyVisualisation(void);
253254

254-
255255
protected:
256256
void InitBuffers(int numdecode, bool extra_for_pause, int need_free,
257257
int needprebuffer_normal, int needprebuffer_small,

0 commit comments

Comments
 (0)