2002-06-16 12:57:31 +02:00
|
|
|
/*
|
|
|
|
* player.c: The basic player interface
|
|
|
|
*
|
|
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
|
|
* how to reach the author.
|
|
|
|
*
|
2020-05-18 16:47:29 +02:00
|
|
|
* $Id: player.c 4.1 2020/05/18 16:47:29 kls Exp $
|
2002-06-16 12:57:31 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "player.h"
|
2002-06-23 11:23:34 +02:00
|
|
|
#include "i18n.h"
|
2002-06-16 12:57:31 +02:00
|
|
|
|
|
|
|
// --- cPlayer ---------------------------------------------------------------
|
|
|
|
|
2002-08-15 11:16:34 +02:00
|
|
|
cPlayer::cPlayer(ePlayMode PlayMode)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
|
|
|
device = NULL;
|
2002-08-15 11:16:34 +02:00
|
|
|
playMode = PlayMode;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cPlayer::~cPlayer()
|
|
|
|
{
|
|
|
|
Detach();
|
|
|
|
}
|
|
|
|
|
2004-12-17 14:55:49 +01:00
|
|
|
int cPlayer::PlayPes(const uchar *Data, int Length, bool VideoOnly)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
|
|
|
if (device)
|
2004-12-17 14:55:49 +01:00
|
|
|
return device->PlayPes(Data, Length, VideoOnly);
|
|
|
|
esyslog("ERROR: attempt to use cPlayer::PlayPes() without attaching to a cDevice!");
|
2002-06-16 12:57:31 +02:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cPlayer::Detach(void)
|
|
|
|
{
|
|
|
|
if (device)
|
|
|
|
device->Detach(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
// --- cControl --------------------------------------------------------------
|
|
|
|
|
2002-06-23 11:23:34 +02:00
|
|
|
cControl *cControl::control = NULL;
|
2006-01-01 14:46:24 +01:00
|
|
|
cMutex cControl::mutex;
|
2002-06-23 11:23:34 +02:00
|
|
|
|
2002-06-23 12:59:58 +02:00
|
|
|
cControl::cControl(cPlayer *Player, bool Hidden)
|
2002-06-16 12:57:31 +02:00
|
|
|
{
|
2002-06-23 11:23:34 +02:00
|
|
|
attached = false;
|
2002-06-23 12:59:58 +02:00
|
|
|
hidden = Hidden;
|
2002-06-23 11:23:34 +02:00
|
|
|
player = Player;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
cControl::~cControl()
|
|
|
|
{
|
2002-06-23 11:23:34 +02:00
|
|
|
if (this == control)
|
|
|
|
control = NULL;
|
|
|
|
}
|
|
|
|
|
2006-01-06 12:53:28 +01:00
|
|
|
cOsdObject *cControl::GetInfo(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-04-28 13:09:42 +02:00
|
|
|
const cRecording *cControl::GetRecording(void)
|
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
cString cControl::GetHeader(void)
|
|
|
|
{
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2020-05-18 16:47:29 +02:00
|
|
|
#if DEPRECATED_CCONTROL
|
2012-04-28 10:56:05 +02:00
|
|
|
cControl *cControl::Control(bool Hidden)
|
2002-06-23 12:59:58 +02:00
|
|
|
{
|
2006-01-01 14:46:24 +01:00
|
|
|
cMutexLock MutexLock(&mutex);
|
2012-04-28 10:56:05 +02:00
|
|
|
return (control && (!control->hidden || Hidden)) ? control : NULL;
|
2002-06-23 12:59:58 +02:00
|
|
|
}
|
2020-05-18 16:47:29 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
cControl *cControl::Control(cMutexLock &MutexLock, bool Hidden)
|
|
|
|
{
|
|
|
|
MutexLock.Lock(&mutex);
|
|
|
|
return (control && (!control->hidden || Hidden)) ? control : NULL;
|
|
|
|
}
|
2002-06-23 12:59:58 +02:00
|
|
|
|
2002-06-23 11:23:34 +02:00
|
|
|
void cControl::Launch(cControl *Control)
|
|
|
|
{
|
2006-01-01 14:46:24 +01:00
|
|
|
cMutexLock MutexLock(&mutex);
|
2020-05-18 16:47:29 +02:00
|
|
|
cControl *c = control; // keeps control from pointing to uninitialized memory TODO obsolete once DEPRECATED_CCONTROL is gone
|
2002-06-23 11:23:34 +02:00
|
|
|
control = Control;
|
2007-07-20 15:26:13 +02:00
|
|
|
delete c;
|
2002-06-23 11:23:34 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void cControl::Attach(void)
|
|
|
|
{
|
2006-01-01 14:46:24 +01:00
|
|
|
cMutexLock MutexLock(&mutex);
|
2002-06-23 11:23:34 +02:00
|
|
|
if (control && !control->attached && control->player && !control->player->IsAttached()) {
|
|
|
|
if (cDevice::PrimaryDevice()->AttachPlayer(control->player))
|
|
|
|
control->attached = true;
|
|
|
|
else {
|
2004-05-16 10:35:36 +02:00
|
|
|
Skins.Message(mtError, tr("Channel locked (recording)!"));
|
2002-06-23 11:23:34 +02:00
|
|
|
Shutdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void cControl::Shutdown(void)
|
|
|
|
{
|
2006-01-01 14:46:24 +01:00
|
|
|
cMutexLock MutexLock(&mutex);
|
2004-11-20 11:34:04 +01:00
|
|
|
cControl *c = control; // avoids recursions
|
2002-06-23 11:23:34 +02:00
|
|
|
control = NULL;
|
2004-11-20 11:34:04 +01:00
|
|
|
delete c;
|
2002-06-16 12:57:31 +02:00
|
|
|
}
|