summaryrefslogtreecommitdiff
path: root/softhddev.c
diff options
context:
space:
mode:
authorJohns <johns98@gmx.net>2012-01-22 20:49:43 +0100
committerJohns <johns98@gmx.net>2012-01-22 20:49:43 +0100
commit95462331757b001e45b4e5c9f9d31c0e63c0f2db (patch)
treead519f26d9ff278eb010bd03e7dbf47bf5a0c4fd /softhddev.c
parent98d2e0f7285c07aef879cd667eb54f68f7234a2b (diff)
downloadvdr-plugin-softhddevice-95462331757b001e45b4e5c9f9d31c0e63c0f2db.tar.gz
vdr-plugin-softhddevice-95462331757b001e45b4e5c9f9d31c0e63c0f2db.tar.bz2
Suspend can close and open video and audio device.
Diffstat (limited to 'softhddev.c')
-rw-r--r--softhddev.c61
1 files changed, 44 insertions, 17 deletions
diff --git a/softhddev.c b/softhddev.c
index b1e29cf..649fcd3 100644
--- a/softhddev.c
+++ b/softhddev.c
@@ -58,8 +58,8 @@ static char ConfigVdpauDecoder = 1; ///< use vdpau decoder, if possible
#endif
static char ConfigFullscreen; ///< fullscreen modus
-static char ConfigSuspendClose = 1; ///< suspend should close devices
-static char ConfigSuspendX11 = 1; ///< suspend should stop x11
+char ConfigSuspendClose; ///< suspend should close devices
+char ConfigSuspendX11; ///< suspend should stop x11
static pthread_mutex_t SuspendLockMutex; ///< suspend lock mutex
@@ -347,7 +347,8 @@ void SetVolumeDevice(int volume)
#include <alsa/iatomic.h> // portable atomic_t
uint32_t VideoSwitch; ///< debug video switch ticks
-static volatile char NewVideoStream; ///< new video stream
+static volatile char NewVideoStream; ///< flag new video stream
+static VideoHwDecoder *MyHwDecoder; ///< video hw decoder
static VideoDecoder *MyVideoDecoder; ///< video decoder
static enum CodecID VideoCodecID; ///< current codec id
@@ -592,16 +593,35 @@ static void StartVideo(void)
}
VideoOsdInit();
if (!MyVideoDecoder) {
- VideoHwDecoder *hw_decoder;
-
- if ((hw_decoder = VideoNewHwDecoder())) {
- MyVideoDecoder = CodecVideoNewDecoder(hw_decoder);
+ if ((MyHwDecoder = VideoNewHwDecoder())) {
+ MyVideoDecoder = CodecVideoNewDecoder(MyHwDecoder);
}
VideoCodecID = CODEC_ID_NONE;
}
VideoPacketInit();
}
+/**
+** Stop video.
+*/
+static void StopVideo(void)
+{
+ VideoOsdExit();
+ VideoExit();
+ if (MyVideoDecoder) {
+ CodecVideoClose(MyVideoDecoder);
+ CodecVideoDelDecoder(MyVideoDecoder);
+ MyVideoDecoder = NULL;
+ }
+ if (MyHwDecoder) {
+ // done by exit: VideoDelHwDecoder(MyHwDecoder);
+ MyHwDecoder = NULL;
+ }
+ VideoPacketExit();
+
+ NewVideoStream = 0;
+}
+
#ifdef DEBUG
/**
@@ -1152,20 +1172,15 @@ void SoftHdDeviceExit(void)
{
// lets hope that vdr does a good thread cleanup
- VideoOsdExit();
- VideoExit();
AudioExit();
-
- if (MyVideoDecoder) {
- CodecVideoClose(MyVideoDecoder);
- CodecVideoDelDecoder(MyVideoDecoder);
- MyVideoDecoder = NULL;
- }
if (MyAudioDecoder) {
CodecAudioClose(MyAudioDecoder);
CodecAudioDelDecoder(MyAudioDecoder);
MyAudioDecoder = NULL;
}
+ NewAudioStream = 0;
+
+ StopVideo();
CodecExit();
VideoPacketExit();
@@ -1242,9 +1257,17 @@ void Suspend(void)
if (ConfigSuspendClose) {
pthread_mutex_lock(&SuspendLockMutex);
- // FIXME: close audio
- // FIXME: close video
+ AudioExit();
+ if (MyAudioDecoder) {
+ CodecAudioClose(MyAudioDecoder);
+ CodecAudioDelDecoder(MyAudioDecoder);
+ MyAudioDecoder = NULL;
+ }
+ NewAudioStream = 0;
+
+ StopVideo();
+
pthread_mutex_unlock(&SuspendLockMutex);
}
if (ConfigSuspendX11) {
@@ -1267,6 +1290,10 @@ void Resume(void)
}
if (ConfigSuspendClose) {
pthread_mutex_lock(&SuspendLockMutex);
+
+ StartVideo();
+ AudioInit();
+
pthread_mutex_unlock(&SuspendLockMutex);
}