From 329dbc5f07dd38b432a207f5f5d40793e2f7f6dd Mon Sep 17 00:00:00 2001 From: Johns Date: Sun, 22 Jan 2012 11:12:57 +0100 Subject: [PATCH] Add dummy player and control for suspend mode. --- ChangeLog | 1 + softhddev.c | 7 +++ softhddevice.cpp | 119 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 116 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 55bb187..f8f44af 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 diff --git a/softhddev.c b/softhddev.c index af0bd8c..80abe9a 100644 --- a/softhddev.c +++ b/softhddev.c @@ -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); } diff --git a/softhddevice.cpp b/softhddevice.cpp index f48f263..f496c99 100644 --- a/softhddevice.cpp +++ b/softhddevice.cpp @@ -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 ////////////////////////////////////////////////////////////////////////////// @@ -511,7 +586,7 @@ class cSoftHdDevice:public cDevice { public: cSoftHdDevice(void); - virtual ~ cSoftHdDevice(void); + virtual ~ cSoftHdDevice(void); virtual bool HasDecoder(void) const; virtual bool CanReplay(void) const; @@ -547,13 +622,13 @@ class cSoftHdDevice:public cDevice #if 0 // SPU facilities private: - cDvbSpuDecoder * spuDecoder; + cDvbSpuDecoder * spuDecoder; public: - virtual cSpuDecoder * GetSpuDecoder(void); + virtual cSpuDecoder * GetSpuDecoder(void); #endif protected: - virtual void MakePrimaryDevice(bool); + virtual void MakePrimaryDevice(bool); }; cSoftHdDevice::cSoftHdDevice(void) @@ -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(); @@ -867,7 +948,7 @@ class cPluginSoftHdDevice:public cPlugin virtual bool Initialize(void); virtual bool Start(void); virtual void Stop(void); -// virtual void Housekeeping(void); + // virtual void Housekeeping(void); virtual void MainThreadHook(void); virtual const char *MainMenuEntry(void); virtual cOsdObject *MainMenuAction(void); @@ -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; }