Guard suspend/resume against multiple calls.

This commit is contained in:
Johns 2012-02-08 23:26:49 +01:00
parent c3a1de8c7b
commit 08246b5ac3
2 changed files with 27 additions and 12 deletions

View File

@ -1,6 +1,7 @@
User johns User johns
Date: Date:
Guard suspend/resume against multiple calls.
Add support for AAC LATM audio streams. Add support for AAC LATM audio streams.
Fix bug: alsa and ffmpeg use different channel layout. Fix bug: alsa and ffmpeg use different channel layout.
Support more LPCM sample rates and number of channels. Support more LPCM sample rates and number of channels.

View File

@ -590,9 +590,8 @@ cSoftHdPlayer::~cSoftHdPlayer()
*/ */
class cSoftHdControl:public cControl class cSoftHdControl:public cControl
{ {
private:
cSoftHdPlayer * Player;
public: public:
static cSoftHdPlayer *Player; ///< dummy player
virtual void Hide(void) virtual void Hide(void)
{ {
} }
@ -603,6 +602,13 @@ class cSoftHdControl:public cControl
virtual ~ cSoftHdControl(); virtual ~ cSoftHdControl();
}; };
cSoftHdPlayer *cSoftHdControl::Player;
/**
** Handle a key event.
**
** @param key key pressed
*/
eOSState cSoftHdControl::ProcessKey(eKeys key) eOSState cSoftHdControl::ProcessKey(eKeys key)
{ {
if (!ISMODELESSKEY(key) || key == kBack || key == kStop) { if (!ISMODELESSKEY(key) || key == kBack || key == kStop) {
@ -610,8 +616,8 @@ eOSState cSoftHdControl::ProcessKey(eKeys key)
delete Player; delete Player;
Player = NULL; Player = NULL;
Resume();
} }
Resume();
return osEnd; return osEnd;
} }
return osContinue; return osContinue;
@ -884,8 +890,8 @@ bool cSoftHdDevice::Flush(int timeout_ms)
** **
** @note FIXME: this function isn't called on the initial channel ** @note FIXME: this function isn't called on the initial channel
*/ */
void cSoftHdDevice:: void cSoftHdDevice:: SetVideoDisplayFormat(eVideoDisplayFormat
SetVideoDisplayFormat(eVideoDisplayFormat video_display_format) video_display_format)
{ {
static int last = -1; static int last = -1;
@ -1162,6 +1168,7 @@ cOsdObject *cPluginSoftHdDevice::MainMenuAction(void)
//dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
//MyDevice->StopReplay(); //MyDevice->StopReplay();
if (!cSoftHdControl::Player) { // not already suspended
cControl::Launch(new cSoftHdControl); cControl::Launch(new cSoftHdControl);
cControl::Attach(); cControl::Attach();
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11); Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
@ -1169,6 +1176,7 @@ cOsdObject *cPluginSoftHdDevice::MainMenuAction(void)
dsyslog("[softhddev]%s: set user inactive\n", __FUNCTION__); dsyslog("[softhddev]%s: set user inactive\n", __FUNCTION__);
ShutdownHandler.SetUserInactive(); ShutdownHandler.SetUserInactive();
} }
}
return NULL; return NULL;
} }
@ -1344,6 +1352,10 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
__attribute__ ((unused)) int &reply_code) __attribute__ ((unused)) int &reply_code)
{ {
if (!strcasecmp(command, "SUSP")) { if (!strcasecmp(command, "SUSP")) {
if (cSoftHdControl::Player) { // already suspended
return "SoftHdDevice already suspended";
}
// should be after suspend, but SetPlayMode resumes
cControl::Launch(new cSoftHdControl); cControl::Launch(new cSoftHdControl);
cControl::Attach(); cControl::Attach();
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11); Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
@ -1353,8 +1365,10 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
if (ShutdownHandler.GetUserInactiveTime()) { if (ShutdownHandler.GetUserInactiveTime()) {
ShutdownHandler.SetUserInactiveTimeout(); ShutdownHandler.SetUserInactiveTimeout();
} }
Resume(); if (cSoftHdControl::Player) { // suspended
cControl::Shutdown(); // not need, if not suspended cControl::Shutdown(); // not need, if not suspended
}
Resume();
return "SoftHdDevice is resumed"; return "SoftHdDevice is resumed";
} }
return NULL; return NULL;