Add support for attach/detach plugin.

This commit is contained in:
Johns 2012-03-01 22:12:22 +01:00
parent b5e9077c74
commit 6a28064dce
4 changed files with 70 additions and 16 deletions

View File

@ -1,6 +1,7 @@
User johns
Date:
Add support for attach/detach plugin.
OSS needs bigger audio buffers.
Improved audio drift correction support.
Experimental audio drift correction support.

View File

@ -224,8 +224,9 @@ Commandline:
SVDRP:
------
Use 'svdrpsend.pl plug softhddevice HELP' to see the SVDRP commands
help and which are supported by the plugin.
Use 'svdrpsend.pl plug softhddevice HELP'
or 'svdrpsend plug softhddevice HELP' to see the SVDRP commands help
and which are supported by the plugin.
Keymacros:
----------

View File

@ -941,7 +941,7 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
bits_per_sample = (((p[5] >> 6) & 0x3) + 4) * 4;
if (bits_per_sample != 16) {
Error(_
("softhddev: LPCM %d bits per sample aren't supported\n"),
("[softhddev] LPCM %d bits per sample aren't supported\n"),
bits_per_sample);
// FIXME: handle unsupported formats.
}
@ -951,12 +951,12 @@ int PlayAudio(const uint8_t * data, int size, uint8_t id)
AudioSetBufferTime(400);
AudioSetup(&samplerate, &channels, 0);
if (samplerate != samplerates[p[5] >> 4]) {
Error(_("softhddev: LPCM %d sample-rate is unsupported\n"),
Error(_("[softhddev] LPCM %d sample-rate is unsupported\n"),
samplerates[p[5] >> 4]);
// FIXME: support resample
}
if (channels != (p[5] & 0x7) + 1) {
Error(_("softhddev: LPCM %d channels are unsupported\n"),
Error(_("[softhddev] LPCM %d channels are unsupported\n"),
(p[5] & 0x7) + 1);
// FIXME: support resample
}
@ -1079,7 +1079,7 @@ int PlayTsAudio(const uint8_t * data, int size)
if (NewAudioStream) {
// FIXME: does this clear the audio ringbuffer?
CodecAudioClose(MyAudioDecoder);
AudioSetBufferTime(216);
AudioSetBufferTime(264);
AudioCodecID = CODEC_ID_NONE;
NewAudioStream = 0;
PesReset(PesDemuxAudio);
@ -1144,7 +1144,7 @@ static void VideoPacketInit(void)
avpkt = &VideoPacketRb[i];
// build a clean ffmpeg av packet
if (av_new_packet(avpkt, VIDEO_BUFFER_SIZE)) {
Fatal(_("[softhddev]: out of memory\n"));
Fatal(_("[softhddev] out of memory\n"));
}
avpkt->priv = NULL;
}
@ -1846,11 +1846,6 @@ uint8_t *GrabImage(int *size, int jpeg, int quality, int width, int height)
*/
int SetPlayMode(int play_mode)
{
if (ConfigStartSuspended) { // ignore first call, if start suspended
ConfigStartSuspended = 0;
return 1;
}
Resume();
VideoDisplayWakeup();
if (MyVideoDecoder) { // tell video parser we have new stream
if (VideoCodecID != CODEC_ID_NONE) {
@ -2342,6 +2337,7 @@ void Start(void)
if (!ConfigStartSuspended) {
// FIXME: AudioInit for HDMI after X11 startup
// StartAudio();
AudioInit();
av_new_packet(AudioAvPkt, AUDIO_BUFFER_SIZE);
MyAudioDecoder = CodecAudioNewDecoder();
@ -2360,6 +2356,7 @@ void Start(void)
#ifdef USE_TS_AUDIO
PesInit(PesDemuxAudio);
#endif
// FIXME: some good message here.
}
/**
@ -2448,6 +2445,7 @@ void Resume(void)
StartVideo();
}
if (!MyAudioDecoder) { // audio not running
// StartAudio();
AudioInit();
av_new_packet(AudioAvPkt, AUDIO_BUFFER_SIZE);
MyAudioDecoder = CodecAudioNewDecoder();

View File

@ -102,6 +102,11 @@ static char ConfigSuspendX11; ///< suspend should stop x11
static volatile char DoMakePrimary; ///< flag switch primary
#define SUSPEND_EXTERNAL -1 ///< play external suspend mode
#define SUSPEND_NORMAL 0 ///< normal suspend mode
#define SUSPEND_DETACHED 1 ///< detached suspend mode
static char SuspendMode; ///< suspend mode
//////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////
@ -673,13 +678,15 @@ cSoftHdPlayer *cSoftHdControl::Player;
*/
eOSState cSoftHdControl::ProcessKey(eKeys key)
{
if (!ISMODELESSKEY(key) || key == kBack || key == kStop) {
if (SuspendMode == SUSPEND_NORMAL && (!ISMODELESSKEY(key)
|| key == kMenu || key == kBack || key == kStop)) {
if (Player) {
delete Player;
Player = NULL;
}
Resume();
SuspendMode = 0;
return osEnd;
}
return osContinue;
@ -703,7 +710,9 @@ cSoftHdControl::~cSoftHdControl()
Player = NULL;
}
Resume();
dsyslog("[softhddev]%s: resume\n", __FUNCTION__);
//Resume();
}
//////////////////////////////////////////////////////////////////////////////
@ -950,6 +959,8 @@ bool cSoftHdDevice::CanReplay(void) const
/**
** Sets the device into the given play mode.
**
** @param play_mode new play mode (Audio/Video/External...)
*/
bool cSoftHdDevice::SetPlayMode(ePlayMode play_mode)
{
@ -974,6 +985,14 @@ bool cSoftHdDevice::SetPlayMode(ePlayMode play_mode)
break;
}
if (SuspendMode) {
if (SuspendMode != SUSPEND_EXTERNAL) {
return true;
}
Resume();
SuspendMode = 0;
}
return::SetPlayMode(play_mode);
}
@ -1625,6 +1644,8 @@ const char **cPluginSoftHdDevice::SVDRPHelpPages(void)
static const char *text[] = {
"SUSP\n" " Suspend plugin.\n",
"RESU\n" " Resume plugin.\n",
"DETA\n" " Detach plugin.\n",
"ATTA\n" " Attach plugin.\n",
"HOTK key\n" " Execute hotkey.\n",
NULL
};
@ -1648,12 +1669,15 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
return "SoftHdDevice already suspended";
}
// should be after suspend, but SetPlayMode resumes
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
cControl::Launch(new cSoftHdControl);
cControl::Attach();
Suspend(ConfigSuspendClose, ConfigSuspendClose, ConfigSuspendX11);
return "SoftHdDevice is suspended";
}
if (!strcasecmp(command, "RESU")) {
if (SuspendMode != SUSPEND_NORMAL) {
return "can't resume SoftHdDevice";
}
if (ShutdownHandler.GetUserInactiveTime()) {
ShutdownHandler.SetUserInactiveTimeout();
}
@ -1661,8 +1685,38 @@ cString cPluginSoftHdDevice::SVDRPCommand(const char *command,
cControl::Shutdown(); // not need, if not suspended
}
Resume();
SuspendMode = 0;
return "SoftHdDevice is resumed";
}
if (!strcasecmp(command, "DETA")) {
if (cSoftHdControl::Player) { // already suspended
if (SuspendMode == SUSPEND_DETACHED) {
return "SoftHdDevice already detached";
}
return "can't suspend SoftHdDevice already suspended";
}
Suspend(1, 1, 0);
cControl::Launch(new cSoftHdControl);
cControl::Attach();
return "SoftHdDevice is detached";
}
if (!strcasecmp(command, "ATTA")) {
if (SuspendMode) {
if (SuspendMode != SUSPEND_DETACHED) {
return "SoftHdDevice already detached";
}
return "can't attach SoftHdDevice not detached";
}
if (ShutdownHandler.GetUserInactiveTime()) {
ShutdownHandler.SetUserInactiveTimeout();
}
if (cSoftHdControl::Player) { // suspended
cControl::Shutdown(); // not need, if not suspended
}
Resume();
SuspendMode = 0;
return "SoftHdDevice is attached";
}
if (!strcasecmp(command, "HOTK")) {
int hotk;