vdr-1.4.7/player.c

Go to the documentation of this file.
00001 /*
00002  * player.c: The basic player interface
00003  *
00004  * See the main source file 'vdr.c' for copyright information and
00005  * how to reach the author.
00006  *
00007  * $Id: player.c 1.11 2006/01/06 11:30:07 kls Exp $
00008  */
00009 
00010 #include "player.h"
00011 #include "i18n.h"
00012 
00013 // --- cPlayer ---------------------------------------------------------------
00014 
00015 cPlayer::cPlayer(ePlayMode PlayMode)
00016 {
00017   device = NULL;
00018   playMode = PlayMode;
00019 }
00020 
00021 cPlayer::~cPlayer()
00022 {
00023   Detach();
00024 }
00025 
00026 int cPlayer::PlayPes(const uchar *Data, int Length, bool VideoOnly)
00027 {
00028   if (device)
00029      return device->PlayPes(Data, Length, VideoOnly);
00030   esyslog("ERROR: attempt to use cPlayer::PlayPes() without attaching to a cDevice!");
00031   return -1;
00032 }
00033 
00034 void cPlayer::Detach(void)
00035 {
00036   if (device)
00037      device->Detach(this);
00038 }
00039 
00040 // --- cControl --------------------------------------------------------------
00041 
00042 cControl *cControl::control = NULL;
00043 cMutex cControl::mutex;
00044 
00045 cControl::cControl(cPlayer *Player, bool Hidden)
00046 {
00047   attached = false;
00048   hidden = Hidden;
00049   player = Player;
00050 }
00051 
00052 cControl::~cControl()
00053 {
00054   if (this == control)
00055      control = NULL;
00056 }
00057 
00058 cOsdObject *cControl::GetInfo(void)
00059 {
00060   return NULL;
00061 }
00062 
00063 cControl *cControl::Control(void)
00064 {
00065   cMutexLock MutexLock(&mutex);
00066   return (control && !control->hidden) ? control : NULL;
00067 }
00068 
00069 void cControl::Launch(cControl *Control)
00070 {
00071   cMutexLock MutexLock(&mutex);
00072   delete control;
00073   control = Control;
00074 }
00075 
00076 void cControl::Attach(void)
00077 {
00078   cMutexLock MutexLock(&mutex);
00079   if (control && !control->attached && control->player && !control->player->IsAttached()) {
00080      if (cDevice::PrimaryDevice()->AttachPlayer(control->player))
00081         control->attached = true;
00082      else {
00083         Skins.Message(mtError, tr("Channel locked (recording)!"));
00084         Shutdown();
00085         }
00086      }
00087 }
00088 
00089 void cControl::Shutdown(void)
00090 {
00091   cMutexLock MutexLock(&mutex);
00092   cControl *c = control; // avoids recursions
00093   control = NULL;
00094   delete c;
00095 }

Generated on Tue Nov 6 19:57:54 2007 for VDR by  doxygen 1.5.3-20071008