Fix bug: broken device plugin stop and exit.

This commit is contained in:
Johns 2012-01-06 15:39:32 +01:00
parent cb2314837c
commit 878813f206
3 changed files with 72 additions and 85 deletions

View File

@ -1,6 +1,7 @@
User johns User johns
Data: Data:
Fix bug: broken device plugin stop and exit.
Show transparent cursor to hide cursor. Show transparent cursor to hide cursor.
VDPAU: Add color standard support. VDPAU: Add color standard support.
VDPAU: Add denoise and sharpness support. VDPAU: Add denoise and sharpness support.

View File

@ -42,7 +42,9 @@
#include "video.h" #include "video.h"
#include "codec.h" #include "codec.h"
static char BrokenThreadsAndPlugins; ///< broken vdr threads and plugins //////////////////////////////////////////////////////////////////////////////
// Variables
//////////////////////////////////////////////////////////////////////////////
#ifdef USE_VDPAU #ifdef USE_VDPAU
static char ConfigVdpauDecoder = 1; ///< use vdpau decoder, if possible 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 #define ConfigVdpauDecoder 0 ///< no vdpau decoder configured
#endif #endif
static const char DeviceStopped = 1; ///< flag device stopped
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
// Audio // Audio
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -189,9 +193,6 @@ void PlayAudio(const uint8_t * data, int size,
int n; int n;
AVPacket avpkt[1]; AVPacket avpkt[1];
if (BrokenThreadsAndPlugins) {
return;
}
// channel switch: SetAudioChannelDevice: SetDigitalAudioDevice: // channel switch: SetAudioChannelDevice: SetDigitalAudioDevice:
if (NewAudioStream) { if (NewAudioStream) {
@ -301,9 +302,6 @@ void PlayAudio(const uint8_t * data, int size,
*/ */
void Mute(void) void Mute(void)
{ {
if (BrokenThreadsAndPlugins) {
return;
}
AudioSetVolume(0); AudioSetVolume(0);
} }
@ -314,9 +312,6 @@ void Mute(void)
*/ */
void SetVolumeDevice(int volume) void SetVolumeDevice(int volume)
{ {
if (BrokenThreadsAndPlugins) {
return;
}
AudioSetVolume((volume * 100) / 255); 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. ** Finish current packet advance to next.
**
** @param codec_id codec id of packet (MPEG/H264)
*/ */
static void VideoNextPacket(int codec_id) static void VideoNextPacket(int codec_id)
{ {
@ -637,9 +634,6 @@ int PlayVideo(const uint8_t * data, int size)
int64_t pts; int64_t pts;
int n; int n;
if (BrokenThreadsAndPlugins) {
return size;
}
if (Usr1Signal) { // x11 server ready if (Usr1Signal) { // x11 server ready
Usr1Signal = 0; Usr1Signal = 0;
StartVideo(); StartVideo();
@ -760,9 +754,6 @@ int PlayVideo(const uint8_t * data, int size)
*/ */
void SetPlayMode(void) void SetPlayMode(void)
{ {
if (BrokenThreadsAndPlugins) {
return;
}
if (MyVideoDecoder) { if (MyVideoDecoder) {
if (VideoCodecID != CODEC_ID_NONE) { if (VideoCodecID != CODEC_ID_NONE) {
NewVideoStream = 1; NewVideoStream = 1;
@ -850,9 +841,6 @@ void GetOsdSize(int *width, int *height, double *aspect)
*/ */
void OsdClose(void) void OsdClose(void)
{ {
if (BrokenThreadsAndPlugins) {
return;
}
VideoOsdClear(); VideoOsdClear();
} }
@ -861,9 +849,6 @@ void OsdClose(void)
*/ */
void OsdDrawARGB(int x, int y, int height, int width, const uint8_t * argb) void OsdDrawARGB(int x, int y, int height, int width, const uint8_t * argb)
{ {
if (BrokenThreadsAndPlugins) {
return;
}
VideoOsdDrawARGB(x, y, height, width, argb); VideoOsdDrawARGB(x, y, height, width, argb);
} }
@ -1030,39 +1015,6 @@ static void StartXServer(void)
*/ */
void SoftHdDeviceExit(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 // lets hope that vdr does a good thead cleanup
// no it doesn't do a good thread cleanup // no it doesn't do a good thread cleanup
if (MyVideoDecoder) { 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. ** Main thread hook, periodic called from main thread.
*/ */
void MainThreadHook(void) void MainThreadHook(void)
{ {
VideoDisplayHandler(); if (!DeviceStopped) {
VideoDisplayHandler();
}
} }

View File

@ -33,14 +33,15 @@
#include "softhddev.h" #include "softhddev.h"
#include "softhddevice.h" #include "softhddevice.h"
extern "C" { extern "C"
#include "video.h" {
#include "video.h"
extern void AudioPoller(void); 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 = static const char *const DESCRIPTION =
trNOOP("A software and GPU emulated HD device"); trNOOP("A software and GPU emulated HD device");
@ -56,7 +57,7 @@ static int ConfigVideoDenoise; ///< config denoise
static int ConfigVideoSharpen; ///< config sharpen static int ConfigVideoSharpen; ///< config sharpen
static char ConfigVideoScaling; ///< config scaling static char ConfigVideoScaling; ///< config scaling
static int ConfigVideoAudioDelay; ///< config audio delay 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) cSoftOsd::~cSoftOsd(void)
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
SetActive(false); SetActive(false);
OsdClose(); OsdClose();
@ -206,8 +207,10 @@ void cSoftOsd::Flush(void)
w = pm->ViewPort().Width(); w = pm->ViewPort().Width();
h = pm->ViewPort().Height(); 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()); 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) 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); Osd = new cSoftOsd(left, top, level);
return Osd; return Osd;
@ -253,7 +256,7 @@ bool cSoftOsdProvider::ProvidesTrueColor(void)
cSoftOsdProvider::cSoftOsdProvider(void) cSoftOsdProvider::cSoftOsdProvider(void)
: cOsdProvider() : cOsdProvider()
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
} }
////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////
@ -386,14 +389,14 @@ class cSoftHdDevice:public cDevice
cSoftHdDevice::cSoftHdDevice(void) cSoftHdDevice::cSoftHdDevice(void)
{ {
dsyslog("[softhddev]%s\n", __FUNCTION__); //dsyslog("[softhddev]%s\n", __FUNCTION__);
spuDecoder = NULL; spuDecoder = NULL;
} }
cSoftHdDevice::~cSoftHdDevice(void) cSoftHdDevice::~cSoftHdDevice(void)
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
} }
void cSoftHdDevice::MakePrimaryDevice(bool on) void cSoftHdDevice::MakePrimaryDevice(bool on)
@ -409,7 +412,7 @@ void cSoftHdDevice::MakePrimaryDevice(bool on)
int cSoftHdDevice::ProvidesCa( int cSoftHdDevice::ProvidesCa(
__attribute__ ((unused)) const cChannel * channel) const __attribute__ ((unused)) const cChannel * channel) const
{ {
dsyslog("[softhddev]%s: %p\n", __FUNCTION__, channel); //dsyslog("[softhddev]%s: %p\n", __FUNCTION__, channel);
return 0; return 0;
} }
@ -505,7 +508,7 @@ void cSoftHdDevice::Mute(void)
void cSoftHdDevice::SetVolumeDevice(int volume) void cSoftHdDevice::SetVolumeDevice(int volume)
{ {
dsyslog("[softhddev]%s: %d\n", __FUNCTION__, volume); //dsyslog("[softhddev]%s: %d\n", __FUNCTION__, volume);
::SetVolumeDevice(volume); ::SetVolumeDevice(volume);
} }
@ -558,22 +561,23 @@ int cSoftHdDevice::PlayAudio(const uchar * data, int length, uchar id)
void cSoftHdDevice::SetAudioTrackDevice( void cSoftHdDevice::SetAudioTrackDevice(
__attribute__ ((unused)) eTrackType type) __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) int cSoftHdDevice::GetAudioChannelDevice(void)
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
return 0; return 0;
} }
@ -652,13 +656,13 @@ cPluginSoftHdDevice::cPluginSoftHdDevice(void)
// Initialize any member variables here. // Initialize any member variables here.
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL // DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT! // VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
} }
cPluginSoftHdDevice::~cPluginSoftHdDevice(void) cPluginSoftHdDevice::~cPluginSoftHdDevice(void)
{ {
// Clean up after yourself! // Clean up after yourself!
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
::SoftHdDeviceExit(); ::SoftHdDeviceExit();
} }
@ -686,7 +690,7 @@ const char *cPluginSoftHdDevice::CommandLineHelp(void)
*/ */
bool cPluginSoftHdDevice::ProcessArgs(int argc, char *argv[]) bool cPluginSoftHdDevice::ProcessArgs(int argc, char *argv[])
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
return::ProcessArgs(argc, argv); return::ProcessArgs(argc, argv);
} }
@ -694,7 +698,7 @@ bool cPluginSoftHdDevice::ProcessArgs(int argc, char *argv[])
bool cPluginSoftHdDevice::Initialize(void) bool cPluginSoftHdDevice::Initialize(void)
{ {
// Start any background activities the plugin shall perform. // Start any background activities the plugin shall perform.
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
MyDevice = new cSoftHdDevice(); MyDevice = new cSoftHdDevice();
@ -706,7 +710,7 @@ bool cPluginSoftHdDevice::Start(void)
const cDevice *primary; const cDevice *primary;
// Start any background activities the plugin shall perform. // Start any background activities the plugin shall perform.
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
primary = cDevice::PrimaryDevice(); primary = cDevice::PrimaryDevice();
if (MyDevice != primary) { if (MyDevice != primary) {
@ -729,7 +733,7 @@ bool cPluginSoftHdDevice::Start(void)
void cPluginSoftHdDevice::Stop(void) void cPluginSoftHdDevice::Stop(void)
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
::Stop(); ::Stop();
} }
@ -743,7 +747,7 @@ void cPluginSoftHdDevice::Housekeeping(void)
const char *cPluginSoftHdDevice::MainMenuEntry(void) const char *cPluginSoftHdDevice::MainMenuEntry(void)
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
return tr(MAINMENUENTRY); return tr(MAINMENUENTRY);
return NULL; return NULL;
} }
@ -756,7 +760,7 @@ const char *cPluginSoftHdDevice::MainMenuEntry(void)
*/ */
void cPluginSoftHdDevice::MainThreadHook(void) void cPluginSoftHdDevice::MainThreadHook(void)
{ {
// dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
if (DoMakePrimary && MyDevice) { if (DoMakePrimary && MyDevice) {
dsyslog("[softhddev]%s: switching primary device\n", __FUNCTION__); dsyslog("[softhddev]%s: switching primary device\n", __FUNCTION__);
@ -791,7 +795,7 @@ cOsdObject *cPluginSoftHdDevice::MainMenuAction(void)
*/ */
cMenuSetupPage *cPluginSoftHdDevice::SetupMenu(void) cMenuSetupPage *cPluginSoftHdDevice::SetupMenu(void)
{ {
dsyslog("[softhddev]%s:\n", __FUNCTION__); //dsyslog("[softhddev]%s:\n", __FUNCTION__);
return new cMenuSetupSoft; return new cMenuSetupSoft;
} }
@ -801,7 +805,7 @@ cMenuSetupPage *cPluginSoftHdDevice::SetupMenu(void)
*/ */
bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value) 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 // FIXME: handle the values
if (!strcmp(name, "MakePrimary")) { if (!strcmp(name, "MakePrimary")) {