Add main menu entry, which suspends the plugin.

This commit is contained in:
Johns 2012-01-10 15:52:07 +01:00
parent 8d624224e9
commit 3a97700981
4 changed files with 116 additions and 31 deletions

View File

@ -95,6 +95,9 @@ Setup: /etc/vdr/setup.conf
softhddevice.MakePrimary = 1
0 = no change, 1 make softhddevice primary at start
softhddevice.HideMainMenuEntry = 0
0 = show softhddevice main menu entry, 1 = hide entry
<res> of the next parameters is 567i, 720p, 1080i_fake or 1080i.
1080i_fake is 1280x1080 or 1440x1080
1080i is "real" 1920x1080
@ -122,12 +125,30 @@ Setup: /etc/vdr/setup.conf
softhddevice.AudioPassthrough = 0
0 = none, 1 = AC-3
Setup: /etc/vdr/remote.conf
------
Add "XKeySym." definitions to /etc/vdr/remote.conf to control
the vdr and plugin with the connected input device.
fe.
XKeySym.Up Up
XKeySym.Down Down
...
Additional to the x11 input sends the window close button "Close".
fe.
XKeySym.Power Close
Commandline:
------------
Use vdr -h to see the command line arguments support by the plugin.
Running:
--------
Warning:
--------
libav is not supported, expect many bugs with it.

View File

@ -52,7 +52,7 @@ 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
static volatile char VideoFreezed; ///< video freezed
//////////////////////////////////////////////////////////////////////////////
// Audio
@ -195,13 +195,16 @@ int PlayAudio(const uint8_t * data, int size,
// channel switch: SetAudioChannelDevice: SetDigitalAudioDevice:
if (VideoFreezed) { // video freezed
return 0;
}
if (NewAudioStream) {
// FIXME: does this clear the audio ringbuffer?
CodecAudioClose(MyAudioDecoder);
AudioCodecID = CODEC_ID_NONE;
NewAudioStream = 0;
}
if (SkipAudio) {
if (SkipAudio) { // skip audio
return size;
}
// PES header 0x00 0x00 0x01 ID
@ -348,8 +351,8 @@ static AVPacket VideoPacketRb[VIDEO_PACKET_MAX];
static int VideoPacketWrite; ///< write pointer
static int VideoPacketRead; ///< read pointer
static atomic_t VideoPacketsFilled; ///< how many of the buffer is used
static volatile char VideoFreezed; ///< video freezed
static volatile char VideoClearBuffers; ///< clear video buffers
static volatile char SkipVideo; ///< skip video
#ifdef DEBUG
static int VideoMaxPacketSize; ///< biggest used packet buffer
@ -648,6 +651,12 @@ int PlayVideo(const uint8_t * data, int size)
if (!MyVideoDecoder) { // no x11 video started
return size;
}
if (SkipVideo) { // skip video
return size;
}
if (VideoFreezed) { // video freezed
return 0;
}
if (NewVideoStream) { // channel switched
Debug(3, "video: new stream %d\n", GetMsTicks() - VideoSwitch);
// FIXME: hack to test results
@ -668,7 +677,7 @@ int PlayVideo(const uint8_t * data, int size)
n = data[8]; // header size
// wrong size
if (size < 9 + n + 4) {
Error(_("[softhddev] invalid video packet\n"));
Error(_("[softhddev] invalid video packet %d bytes\n"), size);
return size;
}
// FIXME: hack to test results
@ -761,6 +770,7 @@ int PlayVideo(const uint8_t * data, int size)
*/
void SetPlayMode(void)
{
Resume();
if (MyVideoDecoder) {
if (VideoCodecID != CODEC_ID_NONE) {
NewVideoStream = 1;
@ -774,6 +784,7 @@ void SetPlayMode(void)
}
VideoFreezed = 0;
SkipAudio = 0;
SkipVideo = 0;
}
/**
@ -910,6 +921,7 @@ void OsdClose(void)
*/
void OsdDrawARGB(int x, int y, int height, int width, const uint8_t * argb)
{
Resume();
VideoOsdDrawARGB(x, y, height, width, argb);
}
@ -1138,3 +1150,31 @@ void Stop(void)
void MainThreadHook(void)
{
}
//////////////////////////////////////////////////////////////////////////////
// Suspend/Resume
//////////////////////////////////////////////////////////////////////////////
/**
** Suspend plugin.
*/
void Suspend(void)
{
// FIXME: close audio
// FIXME: close video
// FIXME: stop x11, if started
SkipVideo = 1;
SkipAudio = 1;
}
/**
** Resume plugin.
*/
void Resume(void)
{
if (SkipVideo && SkipAudio) {
Debug(3, "[softhddev]%s:\n", __FUNCTION__);
SkipVideo = 0;
SkipAudio = 0;
}
}

View File

@ -76,6 +76,10 @@ extern "C"
/// C plugin main thread hook
extern void MainThreadHook(void);
/// Suspend plugin
extern void Suspend(void);
/// Resume plugin
extern void Resume(void);
#ifdef __cplusplus
}
#endif

View File

@ -46,7 +46,7 @@ static const char *const VERSION = "0.3.0";
static const char *const DESCRIPTION =
trNOOP("A software and GPU emulated HD device");
//static const char *MAINMENUENTRY = trNOOP("Soft-HD-Device");
static const char *MAINMENUENTRY = trNOOP("Suspend Soft-HD-Device");
static class cSoftHdDevice *MyDevice;
//////////////////////////////////////////////////////////////////////////////
@ -58,6 +58,7 @@ static const char *const Resolution[RESOLUTIONS] = {
};
static char ConfigMakePrimary; ///< config primary wanted
static char ConfigHideMainMenuEntry; ///< config hide main menu entry
/// config deinterlace
static int ConfigVideoDeinterlace[RESOLUTIONS];
@ -306,6 +307,7 @@ class cMenuSetupSoft:public cMenuSetupPage
{
protected:
int MakePrimary;
int HideMainMenuEntry;
int Scaling[RESOLUTIONS];
int Deinterlace[RESOLUTIONS];
int SkipChromaDeinterlace[RESOLUTIONS];
@ -356,6 +358,9 @@ cMenuSetupSoft::cMenuSetupSoft(void)
MakePrimary = ConfigMakePrimary;
Add(new cMenuEditBoolItem(tr("Make primary device"), &MakePrimary,
tr("no"), tr("yes")));
HideMainMenuEntry = ConfigHideMainMenuEntry;
Add(new cMenuEditBoolItem(tr("Hide main menu entry"), &HideMainMenuEntry,
tr("no"), tr("yes")));
//
// video
//
@ -397,6 +402,8 @@ void cMenuSetupSoft::Store(void)
int i;
SetupStore("MakePrimary", ConfigMakePrimary = MakePrimary);
SetupStore("HideMainMenuEntry", ConfigHideMainMenuEntry =
HideMainMenuEntry);
for (i = 0; i < RESOLUTIONS; ++i) {
char buf[128];
@ -584,6 +591,9 @@ void cSoftHdDevice::Play(void)
::Play();
}
/**
** Puts the device into "freeze frame" mode.
*/
void cSoftHdDevice::Freeze(void)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
@ -759,8 +769,8 @@ class cPluginSoftHdDevice:public cPlugin
virtual void Stop(void);
// virtual void Housekeeping(void);
virtual void MainThreadHook(void);
// virtual const char *MainMenuEntry(void);
// virtual cOsdObject *MainMenuAction(void);
virtual const char *MainMenuEntry(void);
virtual cOsdObject *MainMenuAction(void);
virtual cMenuSetupPage *SetupMenu(void);
virtual bool SetupParse(const char *, const char *);
// virtual bool Service(const char *Id, void *Data = NULL);
@ -860,14 +870,29 @@ void cPluginSoftHdDevice::Housekeeping(void)
// Perform any cleanup or other regular tasks.
}
#endif
/**
** Create main menu entry.
*/
const char *cPluginSoftHdDevice::MainMenuEntry(void)
{
//dsyslog("[softhddev]%s:\n", __FUNCTION__);
return tr(MAINMENUENTRY);
return NULL;
return ConfigHideMainMenuEntry ? NULL : tr(MAINMENUENTRY);
}
#endif
/**
** Perform the action when selected from the main VDR menu.
*/
cOsdObject *cPluginSoftHdDevice::MainMenuAction(void)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
Suspend();
return NULL;
}
/**
** Called for every plugin once during every cycle of VDR's main program
@ -886,25 +911,6 @@ void cPluginSoftHdDevice::MainThreadHook(void)
::MainThreadHook();
}
#if 0
bool cPluginSoftHdDevice::Service(const char *Id, void *Data)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
return false;
}
cOsdObject *cPluginSoftHdDevice::MainMenuAction(void)
{
// Perform the action when selected from the main VDR menu.
dsyslog("[softhddev]%s:\n", __FUNCTION__);
return NULL;
}
#endif
/**
** Return our setup menu.
*/
@ -923,13 +929,16 @@ bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value)
int i;
char buf[128];
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")) {
ConfigMakePrimary = atoi(value);
return true;
}
if (!strcmp(name, "HideMainMenuEntry")) {
ConfigHideMainMenuEntry = atoi(value);
return true;
}
for (i = 0; i < RESOLUTIONS; ++i) {
snprintf(buf, sizeof(buf), "%s.%s", Resolution[i], "Scaling");
if (!strcmp(name, buf)) {
@ -975,4 +984,15 @@ bool cPluginSoftHdDevice::SetupParse(const char *name, const char *value)
return false;
}
#if 0
bool cPluginSoftHdDevice::Service(const char *Id, void *Data)
{
dsyslog("[softhddev]%s:\n", __FUNCTION__);
return false;
}
#endif
VDRPLUGINCREATOR(cPluginSoftHdDevice); // Don't touch this!