Add dummy player and control for suspend mode.

This commit is contained in:
Johns 2012-01-22 11:12:57 +01:00
parent bc8a13e1ef
commit 329dbc5f07
3 changed files with 116 additions and 11 deletions

View File

@ -1,6 +1,7 @@
User johns
Data:
Add dummy player and control for suspend mode.
Buffertime compile time configurable in ms.
Date: Sat Jan 21 15:49:16 CET 2012

View File

@ -887,6 +887,12 @@ void StillPicture(const uint8_t * data, int size)
Error(_("[softhddev] invalid PES video packet\n"));
return;
}
if (VideoCodecID == CODEC_ID_NONE) {
// FIXME: should detect codec, see PlayVideo
Error(_("[softhddev] no codec known for still picture\n"));
return;
}
Clear(); // flush video buffers
// +1 future for deinterlace
for (i = -1; i < (VideoCodecID == CODEC_ID_MPEG2VIDEO ? 3 : 17); ++i) {
@ -1233,6 +1239,7 @@ void Suspend(void)
if (ConfigSuspendClose) {
pthread_mutex_lock(&SuspendLockMutex);
// FIXME: close audio
// FIXME: close video
pthread_mutex_unlock(&SuspendLockMutex);
}

View File

@ -503,6 +503,81 @@ void cMenuSetupSoft::Store(void)
VideoSetAutoCrop(ConfigAutoCropInterval, ConfigAutoCropDelay);
}
//////////////////////////////////////////////////////////////////////////////
// cPlayer
//////////////////////////////////////////////////////////////////////////////
/**
** Dummy player for suspend mode.
*/
class cSoftHdPlayer:public cPlayer
{
protected:
public:
cSoftHdPlayer(void);
virtual ~ cSoftHdPlayer();
};
cSoftHdPlayer::cSoftHdPlayer(void)
{
}
cSoftHdPlayer::~cSoftHdPlayer()
{
Detach();
}
//////////////////////////////////////////////////////////////////////////////
// cControl
//////////////////////////////////////////////////////////////////////////////
/**
** Dummy control for suspend mode.
*/
class cSoftHdControl:public cControl
{
private:
cSoftHdPlayer * Player;
public:
virtual void Hide(void)
{
}
virtual eOSState ProcessKey(eKeys);
cSoftHdControl(void);
virtual ~ cSoftHdControl();
};
eOSState cSoftHdControl::ProcessKey(eKeys key)
{
if (!ISMODELESSKEY(key) || key == kBack || key == kStop) {
if (Player) {
delete Player;
Player = NULL;
Resume();
}
return osEnd;
}
return osContinue;
}
cSoftHdControl::cSoftHdControl(void)
: cControl(Player = new cSoftHdPlayer)
{
}
cSoftHdControl::~cSoftHdControl()
{
if (Player) {
delete Player;
Player = NULL;
}
Resume();
}
//////////////////////////////////////////////////////////////////////////////
// cDevice
//////////////////////////////////////////////////////////////////////////////
@ -604,16 +679,22 @@ bool cSoftHdDevice::HasDecoder(void) const
return true;
}
/**
** Returns true if this device can currently start a replay session.
*/
bool cSoftHdDevice::CanReplay(void) const
{
return true;
}
bool cSoftHdDevice::SetPlayMode(ePlayMode PlayMode)
/**
** Sets the device into the given play mode.
*/
bool cSoftHdDevice::SetPlayMode(ePlayMode play_mode)
{
dsyslog("[softhddev]%s: %d\n", __FUNCTION__, PlayMode);
dsyslog("[softhddev]%s: %d\n", __FUNCTION__, play_mode);
switch (PlayMode) {
switch (play_mode) {
case pmAudioVideo:
break;
case pmAudioOnly:
@ -626,7 +707,7 @@ bool cSoftHdDevice::SetPlayMode(ePlayMode PlayMode)
case pmExtern_THIS_SHOULD_BE_AVOIDED:
break;
default:
dsyslog("[softhddev]playmode not implemented... %d\n", PlayMode);
dsyslog("[softhddev]playmode not implemented... %d\n", play_mode);
break;
}
::SetPlayMode();
@ -966,9 +1047,14 @@ void cPluginSoftHdDevice::Stop(void)
#if 0
/**
** Perform any cleanup or other regular tasks.
*/
void cPluginSoftHdDevice::Housekeeping(void)
{
// Perform any cleanup or other regular tasks.
dsyslog("[softhddev]%s:\n", __FUNCTION__);
// ::Housekeeping();
}
#endif
@ -990,7 +1076,9 @@ cOsdObject *cPluginSoftHdDevice::MainMenuAction(void)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
cDevice::PrimaryDevice()->StopReplay();
//MyDevice->StopReplay();
cControl::Launch(new cSoftHdControl);
cControl::Attach();
Suspend();
if (ShutdownHandler.GetUserInactiveTime()) {
ShutdownHandler.SetUserInactive();
@ -1139,6 +1227,8 @@ const char **cPluginSoftHdDevice::SVDRPHelpPages(void)
static const char *text[] = {
"SUSP\n",
" Suspend plugin",
"RESU\n",
" Resume plugin",
NULL
};
@ -1153,9 +1243,16 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
__attribute__ ((unused)) int &reply_code)
{
if (!strcasecmp(command, "SUSP")) {
cControl::Launch(new cSoftHdControl);
cControl::Attach();
Suspend();
return "SoftHdDevice is suspended";
}
if (!strcasecmp(command, "RESU")) {
Resume();
cControl::Shutdown();
return "SoftHdDevice is resumed";
}
return NULL;
}