diff options
author | Johns <johns98@gmx.net> | 2012-01-11 18:01:18 +0100 |
---|---|---|
committer | Johns <johns98@gmx.net> | 2012-01-11 18:01:18 +0100 |
commit | d983f780b326ad97b6c882900d479edee8c0db29 (patch) | |
tree | 9da9e55d04349db8e5feb9ff3760a6cc267249b8 /softhddev.c | |
parent | 712b2e0de1cf9b0ff3706ce44c079e748399c0d4 (diff) | |
download | vdr-plugin-softhddevice-d983f780b326ad97b6c882900d479edee8c0db29.tar.gz vdr-plugin-softhddevice-d983f780b326ad97b6c882900d479edee8c0db29.tar.bz2 |
Suspend when user is inactive.
Diffstat (limited to 'softhddev.c')
-rw-r--r-- | softhddev.c | 66 |
1 files changed, 53 insertions, 13 deletions
diff --git a/softhddev.c b/softhddev.c index e900890..7573049 100644 --- a/softhddev.c +++ b/softhddev.c @@ -35,6 +35,11 @@ #include <libavcodec/avcodec.h> +#ifndef __USE_GNU +#define __USE_GNU +#endif +#include <pthread.h> + #include "misc.h" #include "softhddev.h" @@ -52,6 +57,11 @@ static char ConfigVdpauDecoder = 1; ///< use vdpau decoder, if possible #define ConfigVdpauDecoder 0 ///< no vdpau decoder configured #endif +static char ConfigSuspendClose = 1; ///< suspend should close devices +static char ConfigSuspendX11 = 1; ///< suspend should stop x11 + +static pthread_mutex_t SuspendLockMutex;///< suspend lock mutex + static volatile char VideoFreezed; ///< video freezed ////////////////////////////////////////////////////////////////////////////// @@ -581,8 +591,8 @@ static void StartVideo(void) if ((hw_decoder = VideoNewHwDecoder())) { MyVideoDecoder = CodecVideoNewDecoder(hw_decoder); - VideoCodecID = CODEC_ID_NONE; } + VideoCodecID = CODEC_ID_NONE; } VideoPacketInit(); } @@ -927,7 +937,7 @@ void OsdDrawARGB(int x, int y, int height, int width, const uint8_t * argb) ////////////////////////////////////////////////////////////////////////////// -static char StartX11Server; ///< flag start the x11 server +static char ConfigStartX11Server; ///< flag start the x11 server /** ** Return command line help string. @@ -968,7 +978,7 @@ int ProcessArgs(int argc, char *const argv[]) } continue; case 'x': // x11 server - StartX11Server = 1; + ConfigStartX11Server = 1; continue; case EOF: break; @@ -1107,13 +1117,15 @@ void SoftHdDeviceExit(void) CodecExit(); VideoPacketExit(); - if (StartX11Server) { + if (ConfigStartX11Server) { Debug(3, "x-setup: Stop x11 server\n"); if (X11ServerPid) { kill(X11ServerPid, SIGTERM); } } + + pthread_mutex_destroy(&SuspendLockMutex); } /** @@ -1121,15 +1133,17 @@ void SoftHdDeviceExit(void) */ void Start(void) { - if (StartX11Server) { + if (ConfigStartX11Server) { StartXServer(); } CodecInit(); // FIXME: AudioInit for HDMI after X11 startup AudioInit(); - if (!StartX11Server) { + if (!ConfigStartX11Server) { StartVideo(); } + + pthread_mutex_init(&SuspendLockMutex, NULL); } /** @@ -1160,11 +1174,27 @@ void MainThreadHook(void) */ void Suspend(void) { - // FIXME: close audio - // FIXME: close video - // FIXME: stop x11, if started + pthread_mutex_lock(&SuspendLockMutex); + if( SkipVideo && SkipAudio ) { // already suspended + pthread_mutex_unlock(&SuspendLockMutex); + return; + } + + Debug(3, "[softhddev]%s:\n", __FUNCTION__); + SkipVideo = 1; SkipAudio = 1; + pthread_mutex_unlock(&SuspendLockMutex); + + if ( ConfigSuspendClose ) { + pthread_mutex_lock(&SuspendLockMutex); + // FIXME: close audio + // FIXME: close video + pthread_mutex_unlock(&SuspendLockMutex); + } + if ( ConfigSuspendX11 ) { + // FIXME: stop x11, if started + } } /** @@ -1172,9 +1202,19 @@ void Suspend(void) */ void Resume(void) { - if (SkipVideo && SkipAudio) { - Debug(3, "[softhddev]%s:\n", __FUNCTION__); - SkipVideo = 0; - SkipAudio = 0; + if (!SkipVideo && !SkipAudio) { // we are not suspended + return; } + + Debug(3, "[softhddev]%s:\n", __FUNCTION__); + + if ( ConfigSuspendX11 ) { + } + if ( ConfigSuspendClose ) { + pthread_mutex_lock(&SuspendLockMutex); + pthread_mutex_unlock(&SuspendLockMutex); + } + + SkipVideo = 0; + SkipAudio = 0; } |