Skip to content

Commit

Permalink
TV: Enable setting volume, audio sync and picture controls directly.
Browse files Browse the repository at this point in the history
Only really useful for external apps. Allows volume, audio sync delay,
brightness, contrast, colour and hue to be set to an absolute level.

N.B. For simplicity, the Frontend SendAction method arguments have been
altered slightly. The call now accepts a generic Value argument instead
of the action specific File argument - hence ACTION_HANDLEMEDIA actions
now require Value instead of File.
  • Loading branch information
Mark Kendall committed Nov 16, 2011
1 parent e1ade9e commit c293896
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 17 deletions.
Expand Up @@ -21,7 +21,7 @@ class SERVICE_PUBLIC FrontendServices : public Service
virtual DTC::FrontendStatus* GetStatus(void) = 0;
virtual bool SendMessage(const QString &Message) = 0;
virtual bool SendAction(const QString &Action,
const QString &File,
const QString &Value,
uint Width, uint Height) = 0;
virtual QStringList GetContextList(void) = 0;
virtual DTC::FrontendActionList* GetActionList(const QString &Context) = 0;
Expand Down
11 changes: 10 additions & 1 deletion mythtv/libs/libmythtv/tv_actions.h
Expand Up @@ -19,7 +19,6 @@
#define ACTION_JUMPBKMRK "JUMPBKMRK"
#define ACTION_JUMPSTART "JUMPSTART"

#define ACTION_TOGGLESTUDIOLEVELS "TOGGLESTUDIOLEVELS"
#define ACTION_TOGGLERECORD "TOGGLERECORD"
#define ACTION_TOGGLEFAV "TOGGLEFAV"
#define ACTION_TOGGLECHANCONTROLS "TOGGLECHANCONTROLS"
Expand All @@ -42,6 +41,14 @@

#define ACTION_EXITSHOWNOPROMPTS "EXITSHOWNOPROMPTS"

/* Picture */
#define ACTION_TOGGLESTUDIOLEVELS "TOGGLESTUDIOLEVELS"
#define ACTION_SETBRIGHTNESS "SETBRIGHTNESS"
#define ACTION_SETCONTRAST "SETCONTRAST"
#define ACTION_SETCOLOUR "SETCOLOUR"
#define ACTION_SETHUE "SETHUE"

/* Subtitles */
#define ACTION_ENABLESUBS "ENABLESUBS"
#define ACTION_DISABLESUBS "DISABLESUBS"
#define ACTION_TOGGLESUBS "TOGGLECC"
Expand Down Expand Up @@ -83,6 +90,8 @@
#define ACTION_VOLUMEUP "VOLUMEUP"
#define ACTION_VOLUMEDOWN "VOLUMEDOWN"
#define ACTION_SETVOLUME "SETVOLUME"
#define ACTION_TOGGELAUDIOSYNC "TOGGLEAUDIOSYNC"
#define ACTION_SETAUDIOSYNC "SETAUDIOSYNC"

/* Visualisations */
#define ACTION_TOGGLEVISUALISATION "TOGGLEVISUALISATION"
Expand Down
51 changes: 46 additions & 5 deletions mythtv/libs/libmythtv/tv_play.cpp
Expand Up @@ -553,6 +553,8 @@ void TV::InitKeys(void)
"Volume up"), "],},F11,Volume Up");
REG_KEY("TV Playback", ACTION_MUTEAUDIO, QT_TRANSLATE_NOOP("MythControls",
"Mute"), "|,\\,F9,Volume Mute");
REG_KEY("TV Playback", ACTION_SETVOLUME, QT_TRANSLATE_NOOP("MythControls",
"Set the volume"), "");
REG_KEY("TV Playback", "CYCLEAUDIOCHAN", QT_TRANSLATE_NOOP("MythControls",
"Cycle audio channels"), "");
REG_KEY("TV Playback", ACTION_TOGGLEUPMIX, QT_TRANSLATE_NOOP("MythControls",
Expand Down Expand Up @@ -666,11 +668,23 @@ void TV::InitKeys(void)
"Decrease time stretch speed"), "");
REG_KEY("TV Playback", "TOGGLESTRETCH", QT_TRANSLATE_NOOP("MythControls",
"Toggle time stretch speed"), "");
REG_KEY("TV Playback", "TOGGLEAUDIOSYNC", QT_TRANSLATE_NOOP("MythControls",
REG_KEY("TV Playback", ACTION_TOGGELAUDIOSYNC,
QT_TRANSLATE_NOOP("MythControls",
"Turn on audio sync adjustment controls"), "");
REG_KEY("TV Playback", ACTION_SETAUDIOSYNC,
QT_TRANSLATE_NOOP("MythControls",
"Set the audio sync adjustment"), "");
REG_KEY("TV Playback", "TOGGLEPICCONTROLS",
QT_TRANSLATE_NOOP("MythControls", "Playback picture adjustments"),
"F");
REG_KEY("TV Playback", ACTION_SETBRIGHTNESS,
QT_TRANSLATE_NOOP("MythControls", "Set the picture brightness"), "");
REG_KEY("TV Playback", ACTION_SETCONTRAST,
QT_TRANSLATE_NOOP("MythControls", "Set the picture contrast"), "");
REG_KEY("TV Playback", ACTION_SETCOLOUR,
QT_TRANSLATE_NOOP("MythControls", "Set the picture colour"), "");
REG_KEY("TV Playback", ACTION_SETHUE,
QT_TRANSLATE_NOOP("MythControls", "Set the picture hue"), "");
REG_KEY("TV Playback", ACTION_TOGGLESTUDIOLEVELS,
QT_TRANSLATE_NOOP("MythControls", "Playback picture adjustments"),
"");
Expand Down Expand Up @@ -3856,7 +3870,7 @@ bool TV::AudioSyncHandleAction(PlayerContext *ctx,
ChangeAudioSync(ctx, -10);
else if (has_action(ACTION_DOWN, actions))
ChangeAudioSync(ctx, 10);
else if (has_action("TOGGLEAUDIOSYNC", actions))
else if (has_action(ACTION_TOGGELAUDIOSYNC, actions))
ClearOSD(ctx);
else
handled = false;
Expand Down Expand Up @@ -4209,7 +4223,7 @@ bool TV::ToggleHandleAction(PlayerContext *ctx,
ToggleAspectOverride(ctx);
else if (has_action("TOGGLEFILL", actions))
ToggleAdjustFill(ctx);
else if (has_action("TOGGLEAUDIOSYNC", actions))
else if (has_action(ACTION_TOGGELAUDIOSYNC, actions))
ChangeAudioSync(ctx, 0); // just display
else if (has_action(ACTION_TOGGLEVISUALISATION, actions))
EnableVisualisation(ctx, false, true /*toggle*/);
Expand Down Expand Up @@ -8326,6 +8340,33 @@ void TV::customEvent(QEvent *e)
// TODO Go through these and make sure they make sense...
QStringList tokens = message.split(" ", QString::SkipEmptyParts);

if (me->ExtraDataCount() == 1)
{
PlayerContext *ctx = GetPlayerWriteLock(0, __FILE__, __LINE__);
int value = me->ExtraData(0).toInt();
if (message == ACTION_SETVOLUME)
ChangeVolume(ctx, false, value);
else if (message == ACTION_SETAUDIOSYNC)
ChangeAudioSync(ctx, 0, value);
else if (message == ACTION_SETBRIGHTNESS)
DoChangePictureAttribute(ctx, kAdjustingPicture_Playback,
kPictureAttribute_Brightness,
false, value);
else if (message == ACTION_SETCONTRAST)
DoChangePictureAttribute(ctx, kAdjustingPicture_Playback,
kPictureAttribute_Contrast,
false, value);
else if (message == ACTION_SETCOLOUR)
DoChangePictureAttribute(ctx, kAdjustingPicture_Playback,
kPictureAttribute_Colour,
false, value);
else if (message == ACTION_SETHUE)
DoChangePictureAttribute(ctx, kAdjustingPicture_Playback,
kPictureAttribute_Hue,
false, value);
ReturnPlayerLock(ctx);
}

if (message == ACTION_SCREENSHOT)
{
PlayerContext *mctx = GetPlayerWriteLock(0, __FILE__, __LINE__);
Expand Down Expand Up @@ -9736,7 +9777,7 @@ void TV::OSDDialogEvent(int result, QString text, QString action)
if (!msg.isEmpty())
SetOSDMessage(actx, msg);
}
else if (action.left(15) == "TOGGLEAUDIOSYNC")
else if (action.left(15) == ACTION_TOGGELAUDIOSYNC)
ChangeAudioSync(actx, 0);
else if (action == ACTION_TOGGLEVISUALISATION)
EnableVisualisation(actx, false, true /*toggle*/);
Expand Down Expand Up @@ -10042,7 +10083,7 @@ void TV::FillOSDMenuAudio(const PlayerContext *ctx, OSD *osd,
selected == "AUDIOTRACKS");
}
if (avsync)
osd->DialogAddButton(tr("Adjust Audio Sync"), "TOGGLEAUDIOSYNC");
osd->DialogAddButton(tr("Adjust Audio Sync"), ACTION_TOGGELAUDIOSYNC);
if (visual && !active)
{
osd->DialogAddButton(tr("Enable Visualisation"),
Expand Down
19 changes: 10 additions & 9 deletions mythtv/programs/mythfrontend/services/frontend.cpp
Expand Up @@ -7,6 +7,7 @@
#include "mythevent.h"
#include "mythuistatetracker.h"
#include "mythmainwindow.h"
#include "tv_actions.h"

#include "frontend.h"

Expand All @@ -32,21 +33,21 @@ bool Frontend::SendMessage(const QString &Message)
return true;
}

bool Frontend::SendAction(const QString &Action, const QString &File,
bool Frontend::SendAction(const QString &Action, const QString &Value,
uint Width, uint Height)
{
if (!IsValidAction(Action))
return false;

if (ACTION_HANDLEMEDIA == Action)
{
if (File.isEmpty())
{
LOG(VB_GENERAL, LOG_ERR, LOC + QString("No file specified."));
return false;
}
static const QStringList value_actions =
QStringList() << ACTION_HANDLEMEDIA << ACTION_SETVOLUME <<
ACTION_SETAUDIOSYNC << ACTION_SETBRIGHTNESS <<
ACTION_SETCONTRAST << ACTION_SETCOLOUR <<
ACTION_SETHUE;

MythEvent* me = new MythEvent(Action, QStringList(File));
if (!Value.isEmpty() && value_actions.contains(Action))
{
MythEvent* me = new MythEvent(Action, QStringList(Value));
qApp->postEvent(GetMythMainWindow(), me);
return true;
}
Expand Down
3 changes: 2 additions & 1 deletion mythtv/programs/mythfrontend/services/frontend.h
Expand Up @@ -16,7 +16,8 @@ class Frontend : public FrontendServices
public:
DTC::FrontendStatus* GetStatus(void);
bool SendMessage(const QString &Message);
bool SendAction(const QString &Action, const QString &File,
bool SendAction(const QString &Action,
const QString &Value,
uint Width, uint Height);
QStringList GetContextList(void);
DTC::FrontendActionList* GetActionList(const QString &Context);
Expand Down

0 comments on commit c293896

Please sign in to comment.