1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Switched VDR's own player to the new cPlayer/cControl structures

This commit is contained in:
Klaus Schmidinger 2002-06-23 11:23:34 +02:00
parent 0bb9a1a77b
commit cd030554e5
8 changed files with 84 additions and 56 deletions

View File

@ -1354,3 +1354,4 @@ Video Disk Recorder Revision History
- Activated cutting. - Activated cutting.
- Activated transfer mode. - Activated transfer mode.
- Moved handling of the Menu key entirely into vdr.c. - Moved handling of the Menu key entirely into vdr.c.
- Switched VDR's own player to the new cPlayer/cControl structures.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: device.c 1.3 2002/06/22 13:45:53 kls Exp $ * $Id: device.c 1.4 2002/06/23 11:16:21 kls Exp $
*/ */
#include "device.h" #include "device.h"
@ -460,7 +460,7 @@ bool cDevice::SetPid(int fd, dmxPesType_t PesType, int Pid, dmxOutput_t Output)
eSetChannelResult cDevice::SetChannel(int ChannelNumber, int Frequency, char Polarization, int Diseqc, int Srate, int Vpid, int Apid, int Tpid, int Ca, int Pnr) eSetChannelResult cDevice::SetChannel(int ChannelNumber, int Frequency, char Polarization, int Diseqc, int Srate, int Vpid, int Apid, int Tpid, int Ca, int Pnr)
{ {
DELETENULL(transfer); DELETENULL(transfer);
//XXX+StopReplay(); StopReplay();
cStatus::MsgChannelSwitch(this, 0); cStatus::MsgChannelSwitch(this, 0);
@ -735,11 +735,6 @@ void cDevice::StillPicture(const uchar *Data, int Length)
bool cDevice::Replaying(void) bool cDevice::Replaying(void)
{ {
/*XXX+
if (replayBuffer && !replayBuffer->Active())
StopReplay();
return replayBuffer != NULL;
XXX*/
return player != NULL; return player != NULL;
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbplayer.c 1.3 2002/06/22 13:35:36 kls Exp $ * $Id: dvbplayer.c 1.4 2002/06/23 10:52:51 kls Exp $
*/ */
#include "dvbplayer.h" #include "dvbplayer.h"
@ -625,9 +625,9 @@ bool cDvbPlayer::GetReplayMode(bool &Play, bool &Forward, int &Speed)
// --- cDvbPlayerControl ----------------------------------------------------- // --- cDvbPlayerControl -----------------------------------------------------
cDvbPlayerControl::cDvbPlayerControl(void) cDvbPlayerControl::cDvbPlayerControl(const char *FileName)
:cControl(player = new cDvbPlayer(FileName))
{ {
player = NULL;
} }
cDvbPlayerControl::~cDvbPlayerControl() cDvbPlayerControl::~cDvbPlayerControl()
@ -640,16 +640,6 @@ bool cDvbPlayerControl::Active(void)
return player && player->Active(); return player && player->Active();
} }
bool cDvbPlayerControl::Start(const char *FileName)
{
delete player;
player = new cDvbPlayer(FileName);
if (cDevice::PrimaryDevice()->AttachPlayer(player))
return true;
Stop();
return false;
}
void cDvbPlayerControl::Stop(void) void cDvbPlayerControl::Stop(void)
{ {
delete player; delete player;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbplayer.h 1.1 2002/06/16 10:59:14 kls Exp $ * $Id: dvbplayer.h 1.2 2002/06/23 10:13:51 kls Exp $
*/ */
#ifndef __DVBPLAYER_H #ifndef __DVBPLAYER_H
@ -19,11 +19,10 @@ class cDvbPlayerControl : public cControl {
private: private:
cDvbPlayer *player; cDvbPlayer *player;
public: public:
cDvbPlayerControl(void); cDvbPlayerControl(const char *FileName);
// Sets up a player for the given file.
virtual ~cDvbPlayerControl(); virtual ~cDvbPlayerControl();
bool Active(void); bool Active(void);
bool Start(const char *FileName);
// Starts replaying the given file.
void Stop(void); void Stop(void);
// Stops the current replay session (if any). // Stops the current replay session (if any).
void Pause(void); void Pause(void);

12
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 1.200 2002/06/23 09:09:11 kls Exp $ * $Id: menu.c 1.201 2002/06/23 11:07:19 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -2681,18 +2681,14 @@ char *cReplayControl::fileName = NULL;
char *cReplayControl::title = NULL; char *cReplayControl::title = NULL;
cReplayControl::cReplayControl(void) cReplayControl::cReplayControl(void)
:cDvbPlayerControl(fileName)
{ {
visible = modeOnly = shown = displayFrames = false; visible = modeOnly = shown = displayFrames = false;
lastCurrent = lastTotal = -1; lastCurrent = lastTotal = -1;
timeoutShow = 0; timeoutShow = 0;
timeSearchActive = false; timeSearchActive = false;
if (fileName) { marks.Load(fileName);
marks.Load(fileName); cStatus::MsgReplaying(this, fileName);
if (!Start(fileName))
Interface->Error(tr("Channel locked (recording)!"));//XXX+
else
cStatus::MsgReplaying(this, fileName);
}
} }
cReplayControl::~cReplayControl() cReplayControl::~cReplayControl()

View File

@ -4,10 +4,11 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: player.c 1.1 2002/06/16 10:34:50 kls Exp $ * $Id: player.c 1.2 2002/06/23 11:23:17 kls Exp $
*/ */
#include "player.h" #include "player.h"
#include "i18n.h"
// --- cPlayer --------------------------------------------------------------- // --- cPlayer ---------------------------------------------------------------
@ -46,10 +47,40 @@ void cPlayer::Detach(void)
// --- cControl -------------------------------------------------------------- // --- cControl --------------------------------------------------------------
cControl::cControl(void) cControl *cControl::control = NULL;
cControl::cControl(cPlayer *Player)
{ {
attached = false;
player = Player;
} }
cControl::~cControl() cControl::~cControl()
{ {
if (this == control)
control = NULL;
}
void cControl::Launch(cControl *Control)
{
delete control;
control = Control;
}
void cControl::Attach(void)
{
if (control && !control->attached && control->player && !control->player->IsAttached()) {
if (cDevice::PrimaryDevice()->AttachPlayer(control->player))
control->attached = true;
else {
Interface->Error(tr("Channel locked (recording)!"));
Shutdown();
}
}
}
void cControl::Shutdown(void)
{
delete control;
control = NULL;
} }

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: player.h 1.2 2002/06/22 14:47:25 kls Exp $ * $Id: player.h 1.3 2002/06/23 11:20:23 kls Exp $
*/ */
#ifndef __PLAYER_H #ifndef __PLAYER_H
@ -40,13 +40,23 @@ protected:
public: public:
cPlayer(void); cPlayer(void);
virtual ~cPlayer(); virtual ~cPlayer();
bool IsAttached(void) { return device != NULL; }
}; };
class cControl : public cOsdObject { class cControl : public cOsdObject {
private:
static cControl *control;
bool attached;
protected:
cPlayer *player;
public: public:
cControl(void); cControl(cPlayer *Player);
virtual ~cControl(); virtual ~cControl();
virtual void Hide(void) = 0; virtual void Hide(void) = 0;
static void Launch(cControl *Control);
static void Attach(void);
static void Shutdown(void);
static cControl *Control(void) { return control; }
}; };
#endif //__PLAYER_H #endif //__PLAYER_H

46
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * The project's page is at http://www.cadsoft.de/people/kls/vdr
* *
* $Id: vdr.c 1.116 2002/06/23 09:35:08 kls Exp $ * $Id: vdr.c 1.117 2002/06/23 11:23:34 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -373,7 +373,6 @@ int main(int argc, char *argv[])
cOsdObject *Menu = NULL; cOsdObject *Menu = NULL;
cOsdObject *Temp = NULL; cOsdObject *Temp = NULL;
cReplayControl *ReplayControl = NULL;
int LastChannel = -1; int LastChannel = -1;
int PreviousChannel = cDevice::CurrentChannel(); int PreviousChannel = cDevice::CurrentChannel();
time_t LastActivity = 0; time_t LastActivity = 0;
@ -391,6 +390,8 @@ int main(int argc, char *argv[])
esyslog("emergency exit requested - shutting down"); esyslog("emergency exit requested - shutting down");
break; break;
} }
// Attach launched player control:
cControl::Attach();
// Restart the Watchdog timer: // Restart the Watchdog timer:
if (WatchdogTimeout > 0) { if (WatchdogTimeout > 0) {
int LatencyTime = WatchdogTimeout - alarm(WatchdogTimeout); int LatencyTime = WatchdogTimeout - alarm(WatchdogTimeout);
@ -418,8 +419,8 @@ int main(int argc, char *argv[])
} }
} }
// User Input: // User Input:
cOsdObject **Interact = Menu ? &Menu : (cOsdObject **)&ReplayControl; cOsdObject *Interact = Menu ? Menu : cControl::Control();
eKeys key = Interface->GetKey(!*Interact || !(*Interact)->NeedsFastResponse()); eKeys key = Interface->GetKey(!Interact || !Interact->NeedsFastResponse());
if (NORMALKEY(key) != kNone) { if (NORMALKEY(key) != kNone) {
EITScanner.Activity(); EITScanner.Activity();
LastActivity = time(NULL); LastActivity = time(NULL);
@ -433,9 +434,9 @@ int main(int argc, char *argv[])
if (!Temp) if (!Temp)
break; break;
} }
if (ReplayControl) if (cControl::Control())
ReplayControl->Hide(); cControl::Control()->Hide();
Menu = new cMenuMain(ReplayControl); Menu = new cMenuMain(cControl::Control());
Temp = NULL; Temp = NULL;
break; break;
// Volume Control: // Volume Control:
@ -456,7 +457,8 @@ int main(int argc, char *argv[])
break; break;
// Power off: // Power off:
case kPower: isyslog("Power button pressed"); case kPower: isyslog("Power button pressed");
DELETENULL(*Interact); DELETENULL(Menu);
cControl::Shutdown();
Temp = NULL; Temp = NULL;
if (!Shutdown) { if (!Shutdown) {
Interface->Error(tr("Can't shutdown - option '-s' not given!")); Interface->Error(tr("Can't shutdown - option '-s' not given!"));
@ -469,8 +471,8 @@ int main(int argc, char *argv[])
LastActivity = 1; // not 0, see below! LastActivity = 1; // not 0, see below!
break; break;
default: default:
if (*Interact) { if (Interact) {
switch ((*Interact)->ProcessKey(key)) { switch (Interact->ProcessKey(key)) {
case osRecord: DELETENULL(Menu); case osRecord: DELETENULL(Menu);
Temp = NULL; Temp = NULL;
if (!cRecordControls::Start()) if (!cRecordControls::Start())
@ -478,28 +480,32 @@ int main(int argc, char *argv[])
break; break;
case osRecordings: case osRecordings:
DELETENULL(Menu); DELETENULL(Menu);
DELETENULL(ReplayControl); cControl::Shutdown();
Temp = NULL; Temp = NULL;
Menu = new cMenuMain(ReplayControl, osRecordings); Menu = new cMenuMain(false, osRecordings);
break; break;
case osReplay: DELETENULL(Menu); case osReplay: DELETENULL(Menu);
DELETENULL(ReplayControl); cControl::Shutdown();
Temp = NULL; Temp = NULL;
ReplayControl = new cReplayControl; cControl::Launch(new cReplayControl);
break; break;
case osStopReplay: case osStopReplay:
DELETENULL(*Interact); DELETENULL(Menu);
DELETENULL(ReplayControl); cControl::Shutdown();
Temp = NULL; Temp = NULL;
break; break;
case osSwitchDvb: case osSwitchDvb:
DELETENULL(*Interact); DELETENULL(Menu);
cControl::Shutdown();
Temp = NULL; Temp = NULL;
Interface->Info(tr("Switching primary DVB...")); Interface->Info(tr("Switching primary DVB..."));
cDevice::SetPrimaryDevice(Setup.PrimaryDVB); cDevice::SetPrimaryDevice(Setup.PrimaryDVB);
break; break;
case osBack: case osBack:
case osEnd: DELETENULL(*Interact); case osEnd: if (Interact == Menu)
DELETENULL(Menu);
else
cControl::Shutdown();
Temp = NULL; Temp = NULL;
break; break;
default: ; default: ;
@ -552,7 +558,7 @@ int main(int argc, char *argv[])
Interface->Info(tr("Editing process finished")); Interface->Info(tr("Editing process finished"));
} }
} }
if (!*Interact && ((!cRecordControls::Active() && !cCutter::Active()) || ForceShutdown)) { if (!Interact && ((!cRecordControls::Active() && !cCutter::Active()) || ForceShutdown)) {
time_t Now = time(NULL); time_t Now = time(NULL);
if (Now - LastActivity > ACTIVITYTIMEOUT) { if (Now - LastActivity > ACTIVITYTIMEOUT) {
// Shutdown: // Shutdown:
@ -614,7 +620,7 @@ int main(int argc, char *argv[])
cRecordControls::Shutdown(); cRecordControls::Shutdown();
cCutter::Stop(); cCutter::Stop();
delete Menu; delete Menu;
delete ReplayControl; cControl::Shutdown();
delete Interface; delete Interface;
cOsd::Shutdown(); cOsd::Shutdown();
PluginManager.Shutdown(true); PluginManager.Shutdown(true);