From 878813f206768172aa13ab8b90c37bdb8e5f31ba Mon Sep 17 00:00:00 2001 From: Johns Date: Fri, 6 Jan 2012 15:39:32 +0100 Subject: Fix bug: broken device plugin stop and exit. --- ChangeLog | 1 + softhddev.c | 94 +++++++++++++++++++++++--------------------------------- softhddevice.cpp | 62 ++++++++++++++++++++----------------- 3 files changed, 72 insertions(+), 85 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8ccb05..9bbaef6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,7 @@ User johns Data: + Fix bug: broken device plugin stop and exit. Show transparent cursor to hide cursor. VDPAU: Add color standard support. VDPAU: Add denoise and sharpness support. diff --git a/softhddev.c b/softhddev.c index ed73ae8..78da0b6 100644 --- a/softhddev.c +++ b/softhddev.c @@ -42,7 +42,9 @@ #include "video.h" #include "codec.h" -static char BrokenThreadsAndPlugins; ///< broken vdr threads and plugins +////////////////////////////////////////////////////////////////////////////// +// Variables +////////////////////////////////////////////////////////////////////////////// #ifdef USE_VDPAU static char ConfigVdpauDecoder = 1; ///< use vdpau decoder, if possible @@ -50,6 +52,8 @@ static char ConfigVdpauDecoder = 1; ///< use vdpau decoder, if possible #define ConfigVdpauDecoder 0 ///< no vdpau decoder configured #endif +static const char DeviceStopped = 1; ///< flag device stopped + ////////////////////////////////////////////////////////////////////////////// // Audio ////////////////////////////////////////////////////////////////////////////// @@ -189,9 +193,6 @@ void PlayAudio(const uint8_t * data, int size, int n; AVPacket avpkt[1]; - if (BrokenThreadsAndPlugins) { - return; - } // channel switch: SetAudioChannelDevice: SetDigitalAudioDevice: if (NewAudioStream) { @@ -301,9 +302,6 @@ void PlayAudio(const uint8_t * data, int size, */ void Mute(void) { - if (BrokenThreadsAndPlugins) { - return; - } AudioSetVolume(0); } @@ -314,9 +312,6 @@ void Mute(void) */ void SetVolumeDevice(int volume) { - if (BrokenThreadsAndPlugins) { - return; - } AudioSetVolume((volume * 100) / 255); } @@ -439,6 +434,8 @@ static void VideoEnqueue(int64_t pts, const void *data, int size) /** ** Finish current packet advance to next. +** +** @param codec_id codec id of packet (MPEG/H264) */ static void VideoNextPacket(int codec_id) { @@ -637,9 +634,6 @@ int PlayVideo(const uint8_t * data, int size) int64_t pts; int n; - if (BrokenThreadsAndPlugins) { - return size; - } if (Usr1Signal) { // x11 server ready Usr1Signal = 0; StartVideo(); @@ -760,9 +754,6 @@ int PlayVideo(const uint8_t * data, int size) */ void SetPlayMode(void) { - if (BrokenThreadsAndPlugins) { - return; - } if (MyVideoDecoder) { if (VideoCodecID != CODEC_ID_NONE) { NewVideoStream = 1; @@ -850,9 +841,6 @@ void GetOsdSize(int *width, int *height, double *aspect) */ void OsdClose(void) { - if (BrokenThreadsAndPlugins) { - return; - } VideoOsdClear(); } @@ -861,9 +849,6 @@ void OsdClose(void) */ void OsdDrawARGB(int x, int y, int height, int width, const uint8_t * argb) { - if (BrokenThreadsAndPlugins) { - return; - } VideoOsdDrawARGB(x, y, height, width, argb); } @@ -1030,39 +1015,6 @@ static void StartXServer(void) */ void SoftHdDeviceExit(void) { -} - -/** -** Prepare plugin. -*/ -void Start(void) -{ - if (StartX11Server) { - StartXServer(); - } - CodecInit(); - // FIXME: AudioInit for HDMI after X11 startup - AudioInit(); - if (!StartX11Server) { - StartVideo(); - } -} - -/** -** Stop plugin. -*/ -void Stop(void) -{ -#ifdef DEBUG - Debug(3, "video: max used PES packet size: %d\n", VideoMaxPacketSize); -#endif - - // FIXME: - // don't let any thread enter our plugin, but can still crash, when - // a thread has called any function, while Stop is called. - BrokenThreadsAndPlugins = 1; - usleep(2 * 1000); - // lets hope that vdr does a good thead cleanup // no it doesn't do a good thread cleanup if (MyVideoDecoder) { @@ -1091,10 +1043,40 @@ void Stop(void) } } +/** +** Prepare plugin. +*/ +void Start(void) +{ + if (StartX11Server) { + StartXServer(); + } + CodecInit(); + // FIXME: AudioInit for HDMI after X11 startup + AudioInit(); + if (!StartX11Server) { + StartVideo(); + } +} + +/** +** Stop plugin. +** +** @note stop everything, but don't cleanup, module is still called. +*/ +void Stop(void) +{ +#ifdef DEBUG + Debug(3, "video: max used PES packet size: %d\n", VideoMaxPacketSize); +#endif +} + /** ** Main thread hook, periodic called from main thread. */ void MainThreadHook(void) { - VideoDisplayHandler(); + if (!DeviceStopped) { + VideoDisplayHandler(); + } } diff --git a/softhddevice.cpp b/softhddevice.cpp index a501409..b87b422 100644 --- a/softhddevice.cpp +++ b/softhddevice.cpp @@ -33,14 +33,15 @@ #include "softhddev.h" #include "softhddevice.h" -extern "C" { - #include "video.h" +extern "C" +{ +#include "video.h" extern void AudioPoller(void); } ////////////////////////////////////////////////////////////////////////////// -static const char *const VERSION = "0.1.5"; +static const char *const VERSION = "0.2.0"; static const char *const DESCRIPTION = trNOOP("A software and GPU emulated HD device"); @@ -56,7 +57,7 @@ static int ConfigVideoDenoise; ///< config denoise static int ConfigVideoSharpen; ///< config sharpen static char ConfigVideoScaling; ///< config scaling static int ConfigVideoAudioDelay; ///< config audio delay -static char DoMakePrimary; ///< flag switch primary +static volatile char DoMakePrimary; ///< flag switch primary ////////////////////////////////////////////////////////////////////////////// @@ -129,7 +130,7 @@ cSoftOsd::cSoftOsd(int left, int top, uint level) cSoftOsd::~cSoftOsd(void) { - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); SetActive(false); OsdClose(); @@ -206,8 +207,10 @@ void cSoftOsd::Flush(void) w = pm->ViewPort().Width(); h = pm->ViewPort().Height(); - dsyslog("[softhddev]%s: draw %dx%d+%d+%d %p\n", __FUNCTION__, w, h, x, - y, pm->Data()); + /* + dsyslog("[softhddev]%s: draw %dx%d+%d+%d %p\n", __FUNCTION__, w, h, x, + y, pm->Data()); + */ OsdDrawARGB(x, y, w, h, pm->Data()); @@ -236,7 +239,7 @@ cOsd *cSoftOsdProvider::Osd; ///< single osd */ cOsd *cSoftOsdProvider::CreateOsd(int left, int top, uint level) { - dsyslog("[softhddev]%s: %d, %d, %d\n", __FUNCTION__, left, top, level); + //dsyslog("[softhddev]%s: %d, %d, %d\n", __FUNCTION__, left, top, level); Osd = new cSoftOsd(left, top, level); return Osd; @@ -253,7 +256,7 @@ bool cSoftOsdProvider::ProvidesTrueColor(void) cSoftOsdProvider::cSoftOsdProvider(void) : cOsdProvider() { - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); } ////////////////////////////////////////////////////////////////////////////// @@ -386,14 +389,14 @@ class cSoftHdDevice:public cDevice cSoftHdDevice::cSoftHdDevice(void) { - dsyslog("[softhddev]%s\n", __FUNCTION__); + //dsyslog("[softhddev]%s\n", __FUNCTION__); spuDecoder = NULL; } cSoftHdDevice::~cSoftHdDevice(void) { - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); } void cSoftHdDevice::MakePrimaryDevice(bool on) @@ -409,7 +412,7 @@ void cSoftHdDevice::MakePrimaryDevice(bool on) int cSoftHdDevice::ProvidesCa( __attribute__ ((unused)) const cChannel * channel) const { - dsyslog("[softhddev]%s: %p\n", __FUNCTION__, channel); + //dsyslog("[softhddev]%s: %p\n", __FUNCTION__, channel); return 0; } @@ -505,7 +508,7 @@ void cSoftHdDevice::Mute(void) void cSoftHdDevice::SetVolumeDevice(int volume) { - dsyslog("[softhddev]%s: %d\n", __FUNCTION__, volume); + //dsyslog("[softhddev]%s: %d\n", __FUNCTION__, volume); ::SetVolumeDevice(volume); } @@ -558,22 +561,23 @@ int cSoftHdDevice::PlayAudio(const uchar * data, int length, uchar id) void cSoftHdDevice::SetAudioTrackDevice( __attribute__ ((unused)) eTrackType type) { - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); } -void cSoftHdDevice::SetDigitalAudioDevice(bool on) +void cSoftHdDevice::SetDigitalAudioDevice( __attribute__ ((unused)) bool on) { - dsyslog("[softhddev]%s: %s\n", __FUNCTION__, on ? "true" : "false"); + //dsyslog("[softhddev]%s: %s\n", __FUNCTION__, on ? "true" : "false"); } -void cSoftHdDevice::SetAudioChannelDevice(int audio_channel) +void cSoftHdDevice::SetAudioChannelDevice( __attribute__ ((unused)) + int audio_channel) { - dsyslog("[softhddev]%s: %d\n", __FUNCTION__, audio_channel); + //dsyslog("[softhddev]%s: %d\n", __FUNCTION__, audio_channel); } int cSoftHdDevice::GetAudioChannelDevice(void) { - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); return 0; } @@ -652,13 +656,13 @@ cPluginSoftHdDevice::cPluginSoftHdDevice(void) // Initialize any member variables here. // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); } cPluginSoftHdDevice::~cPluginSoftHdDevice(void) { // Clean up after yourself! - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); ::SoftHdDeviceExit(); } @@ -686,7 +690,7 @@ const char *cPluginSoftHdDevice::CommandLineHelp(void) */ bool cPluginSoftHdDevice::ProcessArgs(int argc, char *argv[]) { - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); return::ProcessArgs(argc, argv); } @@ -694,7 +698,7 @@ bool cPluginSoftHdDevice::ProcessArgs(int argc, char *argv[]) bool cPluginSoftHdDevice::Initialize(void) { // Start any background activities the plugin shall perform. - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); MyDevice = new cSoftHdDevice(); @@ -706,7 +710,7 @@ bool cPluginSoftHdDevice::Start(void) const cDevice *primary; // Start any background activities the plugin shall perform. - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); primary = cDevice::PrimaryDevice(); if (MyDevice != primary) { @@ -729,7 +733,7 @@ bool cPluginSoftHdDevice::Start(void) void cPluginSoftHdDevice::Stop(void) { - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); ::Stop(); } @@ -743,7 +747,7 @@ void cPluginSoftHdDevice::Housekeeping(void) const char *cPluginSoftHdDevice::MainMenuEntry(void) { - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); return tr(MAINMENUENTRY); return NULL; } @@ -756,7 +760,7 @@ const char *cPluginSoftHdDevice::MainMenuEntry(void) */ void cPluginSoftHdDevice::MainThreadHook(void) { - // dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); if (DoMakePrimary && MyDevice) { dsyslog("[softhddev]%s: switching primary device\n", __FUNCTION__); @@ -791,7 +795,7 @@ cOsdObject *cPluginSoftHdDevice::MainMenuAction(void) */ cMenuSetupPage *cPluginSoftHdDevice::SetupMenu(void) { - dsyslog("[softhddev]%s:\n", __FUNCTION__); + //dsyslog("[softhddev]%s:\n", __FUNCTION__); return new cMenuSetupSoft; } @@ -801,7 +805,7 @@ cMenuSetupPage *cPluginSoftHdDevice::SetupMenu(void) */ bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value) { - dsyslog("[softhddev]%s: '%s' = '%s'\n", __FUNCTION__, name, value); + //dsyslog("[softhddev]%s: '%s' = '%s'\n", __FUNCTION__, name, value); // FIXME: handle the values if (!strcmp(name, "MakePrimary")) { -- cgit v1.2.3