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.
|
|
|
|
*
|
2006-01-06 12:53:28 +01:00
|
|
|
* $Id: player.c 1.11 2006/01/06 11:30:07 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;
|
|
|
|
}
|
|
|
|
|
2002-06-23 12:59:58 +02:00
|
|
|
cControl *cControl::Control(void)
|
|
|
|
{
|
2006-01-01 14:46:24 +01:00
|
|
|
cMutexLock MutexLock(&mutex);
|
2002-06-23 12:59:58 +02:00
|
|
|
return (control && !control->hidden) ? control : NULL;
|
|
|
|
}
|
|
|
|
|
2002-06-23 11:23:34 +02:00
|
|
|
void cControl::Launch(cControl *Control)
|
|
|
|
{
|
2006-01-01 14:46:24 +01:00
|
|
|
cMutexLock MutexLock(&mutex);
|
2002-06-23 11:23:34 +02:00
|
|
|
delete control;
|
|
|
|
control = Control;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
}
|