mirror of
https://projects.vdr-developer.org/git/vdr-plugin-softhddevice.git
synced 2023-10-10 19:16:51 +02:00
Let inactivity suspend wakeup with remote keys.
This commit is contained in:
parent
d0f825f831
commit
09ba3e2993
@ -112,8 +112,9 @@ static char ConfigSuspendX11; ///< suspend should stop x11
|
|||||||
static volatile int DoMakePrimary; ///< switch primary device to this
|
static volatile int DoMakePrimary; ///< switch primary device to this
|
||||||
|
|
||||||
#define SUSPEND_EXTERNAL -1 ///< play external suspend mode
|
#define SUSPEND_EXTERNAL -1 ///< play external suspend mode
|
||||||
#define SUSPEND_NORMAL 0 ///< normal suspend mode
|
#define NOT_SUSPENDED 0 ///< not suspend mode
|
||||||
#define SUSPEND_DETACHED 1 ///< detached suspend mode
|
#define SUSPEND_NORMAL 1 ///< normal suspend mode
|
||||||
|
#define SUSPEND_DETACHED 2 ///< detached suspend mode
|
||||||
static char SuspendMode; ///< suspend mode
|
static char SuspendMode; ///< suspend mode
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -711,23 +712,23 @@ cSoftHdPlayer::~cSoftHdPlayer()
|
|||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** Dummy control for suspend mode.
|
** Dummy control class for suspend mode.
|
||||||
*/
|
*/
|
||||||
class cSoftHdControl:public cControl
|
class cSoftHdControl:public cControl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static cSoftHdPlayer *Player; ///< dummy player
|
static cSoftHdPlayer *Player; ///< dummy player
|
||||||
virtual void Hide(void)
|
virtual void Hide(void) ///< hide control
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
virtual eOSState ProcessKey(eKeys);
|
virtual eOSState ProcessKey(eKeys); ///< process input events
|
||||||
|
|
||||||
cSoftHdControl(void);
|
cSoftHdControl(void); ///< control constructor
|
||||||
|
|
||||||
virtual ~ cSoftHdControl();
|
virtual ~ cSoftHdControl(); ///< control destructor
|
||||||
};
|
};
|
||||||
|
|
||||||
cSoftHdPlayer *cSoftHdControl::Player;
|
cSoftHdPlayer *cSoftHdControl::Player; ///< dummy player instance
|
||||||
|
|
||||||
/**
|
/**
|
||||||
** Handle a key event.
|
** Handle a key event.
|
||||||
@ -744,7 +745,7 @@ eOSState cSoftHdControl::ProcessKey(eKeys key)
|
|||||||
Player = NULL;
|
Player = NULL;
|
||||||
}
|
}
|
||||||
Resume();
|
Resume();
|
||||||
SuspendMode = 0;
|
SuspendMode = NOT_SUSPENDED;
|
||||||
return osEnd;
|
return osEnd;
|
||||||
}
|
}
|
||||||
return osContinue;
|
return osContinue;
|
||||||
@ -769,8 +770,7 @@ cSoftHdControl::~cSoftHdControl()
|
|||||||
Player = NULL;
|
Player = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
dsyslog("[softhddev]%s: resume\n", __FUNCTION__);
|
dsyslog("[softhddev]%s: dummy player stopped\n", __FUNCTION__);
|
||||||
//Resume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////////
|
||||||
@ -885,7 +885,8 @@ eOSState cSoftHdMenu::ProcessKey(eKeys key)
|
|||||||
|
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case osUser1:
|
case osUser1:
|
||||||
if (!cSoftHdControl::Player) { // not already suspended
|
// not already suspended
|
||||||
|
if (SuspendMode == NOT_SUSPENDED && !cSoftHdControl::Player) {
|
||||||
cControl::Launch(new cSoftHdControl);
|
cControl::Launch(new cSoftHdControl);
|
||||||
cControl::Attach();
|
cControl::Attach();
|
||||||
Suspend(ConfigSuspendClose, ConfigSuspendClose,
|
Suspend(ConfigSuspendClose, ConfigSuspendClose,
|
||||||
@ -989,9 +990,9 @@ void cSoftHdDevice::MakePrimaryDevice(bool on)
|
|||||||
|
|
||||||
if (SuspendMode == SUSPEND_DETACHED) {
|
if (SuspendMode == SUSPEND_DETACHED) {
|
||||||
Resume();
|
Resume();
|
||||||
SuspendMode = 0;
|
SuspendMode = NOT_SUSPENDED;
|
||||||
}
|
}
|
||||||
} else if (!SuspendMode) {
|
} else if (SuspendMode == NOT_SUSPENDED) {
|
||||||
Suspend(1, 1, 0);
|
Suspend(1, 1, 0);
|
||||||
SuspendMode = SUSPEND_DETACHED;
|
SuspendMode = SUSPEND_DETACHED;
|
||||||
}
|
}
|
||||||
@ -1056,12 +1057,12 @@ bool cSoftHdDevice::SetPlayMode(ePlayMode play_mode)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SuspendMode) {
|
if (SuspendMode != NOT_SUSPENDED) {
|
||||||
if (SuspendMode != SUSPEND_EXTERNAL) {
|
if (SuspendMode != SUSPEND_EXTERNAL) {
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
Resume();
|
Resume();
|
||||||
SuspendMode = 0;
|
SuspendMode = NOT_SUSPENDED;
|
||||||
}
|
}
|
||||||
|
|
||||||
return::SetPlayMode(play_mode);
|
return::SetPlayMode(play_mode);
|
||||||
@ -1526,21 +1527,6 @@ cOsdObject *cPluginSoftHdDevice::MainMenuAction(void)
|
|||||||
{
|
{
|
||||||
//dsyslog("[softhddev]%s:\n", __FUNCTION__);
|
//dsyslog("[softhddev]%s:\n", __FUNCTION__);
|
||||||
|
|
||||||
#if 0
|
|
||||||
//MyDevice->StopReplay();
|
|
||||||
if (!cSoftHdControl::Player) { // not already suspended
|
|
||||||
cControl::Launch(new cSoftHdControl);
|
|
||||||
cControl::Attach();
|
|
||||||
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
|
|
||||||
SuspendMode = SUSPEND_NORMAL;
|
|
||||||
if (ShutdownHandler.GetUserInactiveTime()) {
|
|
||||||
dsyslog("[softhddev]%s: set user inactive\n", __FUNCTION__);
|
|
||||||
ShutdownHandler.SetUserInactive();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
return new cSoftHdMenu("SoftHdDevice");
|
return new cSoftHdMenu("SoftHdDevice");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1559,8 +1545,10 @@ void cPluginSoftHdDevice::MainThreadHook(void)
|
|||||||
DoMakePrimary = 0;
|
DoMakePrimary = 0;
|
||||||
}
|
}
|
||||||
// check if user is inactive, automatic enter suspend mode
|
// check if user is inactive, automatic enter suspend mode
|
||||||
if (ShutdownHandler.IsUserInactive()) {
|
if (SuspendMode == NOT_SUSPENDED && ShutdownHandler.IsUserInactive()) {
|
||||||
// this is regular called, but guarded against double calls
|
// don't overwrite already suspended suspend mode
|
||||||
|
cControl::Launch(new cSoftHdControl);
|
||||||
|
cControl::Attach();
|
||||||
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
|
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
|
||||||
SuspendMode = SUSPEND_NORMAL;
|
SuspendMode = SUSPEND_NORMAL;
|
||||||
}
|
}
|
||||||
@ -1754,14 +1742,19 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
|
|||||||
if (cSoftHdControl::Player) { // already suspended
|
if (cSoftHdControl::Player) { // already suspended
|
||||||
return "SoftHdDevice already suspended";
|
return "SoftHdDevice already suspended";
|
||||||
}
|
}
|
||||||
// should be after suspend, but SetPlayMode resumes
|
if (SuspendMode != NOT_SUSPENDED) {
|
||||||
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
|
return "SoftHdDevice already detached";
|
||||||
SuspendMode = SUSPEND_NORMAL;
|
}
|
||||||
cControl::Launch(new cSoftHdControl);
|
cControl::Launch(new cSoftHdControl);
|
||||||
cControl::Attach();
|
cControl::Attach();
|
||||||
|
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
|
||||||
|
SuspendMode = SUSPEND_NORMAL;
|
||||||
return "SoftHdDevice is suspended";
|
return "SoftHdDevice is suspended";
|
||||||
}
|
}
|
||||||
if (!strcasecmp(command, "RESU")) {
|
if (!strcasecmp(command, "RESU")) {
|
||||||
|
if (SuspendMode == NOT_SUSPENDED) {
|
||||||
|
return "SoftHdDevice already resumed";
|
||||||
|
}
|
||||||
if (SuspendMode != SUSPEND_NORMAL) {
|
if (SuspendMode != SUSPEND_NORMAL) {
|
||||||
return "can't resume SoftHdDevice";
|
return "can't resume SoftHdDevice";
|
||||||
}
|
}
|
||||||
@ -1772,20 +1765,20 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
|
|||||||
cControl::Shutdown(); // not need, if not suspended
|
cControl::Shutdown(); // not need, if not suspended
|
||||||
}
|
}
|
||||||
Resume();
|
Resume();
|
||||||
SuspendMode = 0;
|
SuspendMode = NOT_SUSPENDED;
|
||||||
return "SoftHdDevice is resumed";
|
return "SoftHdDevice is resumed";
|
||||||
}
|
}
|
||||||
if (!strcasecmp(command, "DETA")) {
|
if (!strcasecmp(command, "DETA")) {
|
||||||
|
if (SuspendMode == SUSPEND_DETACHED) {
|
||||||
|
return "SoftHdDevice already detached";
|
||||||
|
}
|
||||||
if (cSoftHdControl::Player) { // already suspended
|
if (cSoftHdControl::Player) { // already suspended
|
||||||
if (SuspendMode == SUSPEND_DETACHED) {
|
|
||||||
return "SoftHdDevice already detached";
|
|
||||||
}
|
|
||||||
return "can't suspend SoftHdDevice already suspended";
|
return "can't suspend SoftHdDevice already suspended";
|
||||||
}
|
}
|
||||||
Suspend(1, 1, 0);
|
|
||||||
SuspendMode = SUSPEND_DETACHED;
|
|
||||||
cControl::Launch(new cSoftHdControl);
|
cControl::Launch(new cSoftHdControl);
|
||||||
cControl::Attach();
|
cControl::Attach();
|
||||||
|
Suspend(1, 1, 0);
|
||||||
|
SuspendMode = SUSPEND_DETACHED;
|
||||||
return "SoftHdDevice is detached";
|
return "SoftHdDevice is detached";
|
||||||
}
|
}
|
||||||
if (!strcasecmp(command, "ATTA")) {
|
if (!strcasecmp(command, "ATTA")) {
|
||||||
@ -1799,7 +1792,7 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
|
|||||||
cControl::Shutdown(); // not need, if not suspended
|
cControl::Shutdown(); // not need, if not suspended
|
||||||
}
|
}
|
||||||
Resume();
|
Resume();
|
||||||
SuspendMode = 0;
|
SuspendMode = NOT_SUSPENDED;
|
||||||
return "SoftHdDevice is attached";
|
return "SoftHdDevice is attached";
|
||||||
}
|
}
|
||||||
if (!strcasecmp(command, "HOTK")) {
|
if (!strcasecmp(command, "HOTK")) {
|
||||||
|
Loading…
Reference in New Issue
Block a user