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:
parent
0bb9a1a77b
commit
cd030554e5
1
HISTORY
1
HISTORY
@ -1354,3 +1354,4 @@ Video Disk Recorder Revision History
|
||||
- Activated cutting.
|
||||
- Activated transfer mode.
|
||||
- Moved handling of the Menu key entirely into vdr.c.
|
||||
- Switched VDR's own player to the new cPlayer/cControl structures.
|
||||
|
9
device.c
9
device.c
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* 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"
|
||||
@ -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)
|
||||
{
|
||||
DELETENULL(transfer);
|
||||
//XXX+StopReplay();
|
||||
StopReplay();
|
||||
|
||||
cStatus::MsgChannelSwitch(this, 0);
|
||||
|
||||
@ -735,11 +735,6 @@ void cDevice::StillPicture(const uchar *Data, int Length)
|
||||
|
||||
bool cDevice::Replaying(void)
|
||||
{
|
||||
/*XXX+
|
||||
if (replayBuffer && !replayBuffer->Active())
|
||||
StopReplay();
|
||||
return replayBuffer != NULL;
|
||||
XXX*/
|
||||
return player != NULL;
|
||||
}
|
||||
|
||||
|
16
dvbplayer.c
16
dvbplayer.c
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* 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"
|
||||
@ -625,9 +625,9 @@ bool cDvbPlayer::GetReplayMode(bool &Play, bool &Forward, int &Speed)
|
||||
|
||||
// --- cDvbPlayerControl -----------------------------------------------------
|
||||
|
||||
cDvbPlayerControl::cDvbPlayerControl(void)
|
||||
cDvbPlayerControl::cDvbPlayerControl(const char *FileName)
|
||||
:cControl(player = new cDvbPlayer(FileName))
|
||||
{
|
||||
player = NULL;
|
||||
}
|
||||
|
||||
cDvbPlayerControl::~cDvbPlayerControl()
|
||||
@ -640,16 +640,6 @@ bool cDvbPlayerControl::Active(void)
|
||||
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)
|
||||
{
|
||||
delete player;
|
||||
|
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* 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
|
||||
@ -19,11 +19,10 @@ class cDvbPlayerControl : public cControl {
|
||||
private:
|
||||
cDvbPlayer *player;
|
||||
public:
|
||||
cDvbPlayerControl(void);
|
||||
cDvbPlayerControl(const char *FileName);
|
||||
// Sets up a player for the given file.
|
||||
virtual ~cDvbPlayerControl();
|
||||
bool Active(void);
|
||||
bool Start(const char *FileName);
|
||||
// Starts replaying the given file.
|
||||
void Stop(void);
|
||||
// Stops the current replay session (if any).
|
||||
void Pause(void);
|
||||
|
12
menu.c
12
menu.c
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* 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"
|
||||
@ -2681,18 +2681,14 @@ char *cReplayControl::fileName = NULL;
|
||||
char *cReplayControl::title = NULL;
|
||||
|
||||
cReplayControl::cReplayControl(void)
|
||||
:cDvbPlayerControl(fileName)
|
||||
{
|
||||
visible = modeOnly = shown = displayFrames = false;
|
||||
lastCurrent = lastTotal = -1;
|
||||
timeoutShow = 0;
|
||||
timeSearchActive = false;
|
||||
if (fileName) {
|
||||
marks.Load(fileName);
|
||||
if (!Start(fileName))
|
||||
Interface->Error(tr("Channel locked (recording)!"));//XXX+
|
||||
else
|
||||
cStatus::MsgReplaying(this, fileName);
|
||||
}
|
||||
marks.Load(fileName);
|
||||
cStatus::MsgReplaying(this, fileName);
|
||||
}
|
||||
|
||||
cReplayControl::~cReplayControl()
|
||||
|
35
player.c
35
player.c
@ -4,10 +4,11 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* 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 "i18n.h"
|
||||
|
||||
// --- cPlayer ---------------------------------------------------------------
|
||||
|
||||
@ -46,10 +47,40 @@ void cPlayer::Detach(void)
|
||||
|
||||
// --- cControl --------------------------------------------------------------
|
||||
|
||||
cControl::cControl(void)
|
||||
cControl *cControl::control = NULL;
|
||||
|
||||
cControl::cControl(cPlayer *Player)
|
||||
{
|
||||
attached = false;
|
||||
player = Player;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
14
player.h
14
player.h
@ -4,7 +4,7 @@
|
||||
* See the main source file 'vdr.c' for copyright information and
|
||||
* 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
|
||||
@ -40,13 +40,23 @@ protected:
|
||||
public:
|
||||
cPlayer(void);
|
||||
virtual ~cPlayer();
|
||||
bool IsAttached(void) { return device != NULL; }
|
||||
};
|
||||
|
||||
class cControl : public cOsdObject {
|
||||
private:
|
||||
static cControl *control;
|
||||
bool attached;
|
||||
protected:
|
||||
cPlayer *player;
|
||||
public:
|
||||
cControl(void);
|
||||
cControl(cPlayer *Player);
|
||||
virtual ~cControl();
|
||||
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
|
||||
|
46
vdr.c
46
vdr.c
@ -22,7 +22,7 @@
|
||||
*
|
||||
* 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>
|
||||
@ -373,7 +373,6 @@ int main(int argc, char *argv[])
|
||||
|
||||
cOsdObject *Menu = NULL;
|
||||
cOsdObject *Temp = NULL;
|
||||
cReplayControl *ReplayControl = NULL;
|
||||
int LastChannel = -1;
|
||||
int PreviousChannel = cDevice::CurrentChannel();
|
||||
time_t LastActivity = 0;
|
||||
@ -391,6 +390,8 @@ int main(int argc, char *argv[])
|
||||
esyslog("emergency exit requested - shutting down");
|
||||
break;
|
||||
}
|
||||
// Attach launched player control:
|
||||
cControl::Attach();
|
||||
// Restart the Watchdog timer:
|
||||
if (WatchdogTimeout > 0) {
|
||||
int LatencyTime = WatchdogTimeout - alarm(WatchdogTimeout);
|
||||
@ -418,8 +419,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
// User Input:
|
||||
cOsdObject **Interact = Menu ? &Menu : (cOsdObject **)&ReplayControl;
|
||||
eKeys key = Interface->GetKey(!*Interact || !(*Interact)->NeedsFastResponse());
|
||||
cOsdObject *Interact = Menu ? Menu : cControl::Control();
|
||||
eKeys key = Interface->GetKey(!Interact || !Interact->NeedsFastResponse());
|
||||
if (NORMALKEY(key) != kNone) {
|
||||
EITScanner.Activity();
|
||||
LastActivity = time(NULL);
|
||||
@ -433,9 +434,9 @@ int main(int argc, char *argv[])
|
||||
if (!Temp)
|
||||
break;
|
||||
}
|
||||
if (ReplayControl)
|
||||
ReplayControl->Hide();
|
||||
Menu = new cMenuMain(ReplayControl);
|
||||
if (cControl::Control())
|
||||
cControl::Control()->Hide();
|
||||
Menu = new cMenuMain(cControl::Control());
|
||||
Temp = NULL;
|
||||
break;
|
||||
// Volume Control:
|
||||
@ -456,7 +457,8 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
// Power off:
|
||||
case kPower: isyslog("Power button pressed");
|
||||
DELETENULL(*Interact);
|
||||
DELETENULL(Menu);
|
||||
cControl::Shutdown();
|
||||
Temp = NULL;
|
||||
if (!Shutdown) {
|
||||
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!
|
||||
break;
|
||||
default:
|
||||
if (*Interact) {
|
||||
switch ((*Interact)->ProcessKey(key)) {
|
||||
if (Interact) {
|
||||
switch (Interact->ProcessKey(key)) {
|
||||
case osRecord: DELETENULL(Menu);
|
||||
Temp = NULL;
|
||||
if (!cRecordControls::Start())
|
||||
@ -478,28 +480,32 @@ int main(int argc, char *argv[])
|
||||
break;
|
||||
case osRecordings:
|
||||
DELETENULL(Menu);
|
||||
DELETENULL(ReplayControl);
|
||||
cControl::Shutdown();
|
||||
Temp = NULL;
|
||||
Menu = new cMenuMain(ReplayControl, osRecordings);
|
||||
Menu = new cMenuMain(false, osRecordings);
|
||||
break;
|
||||
case osReplay: DELETENULL(Menu);
|
||||
DELETENULL(ReplayControl);
|
||||
cControl::Shutdown();
|
||||
Temp = NULL;
|
||||
ReplayControl = new cReplayControl;
|
||||
cControl::Launch(new cReplayControl);
|
||||
break;
|
||||
case osStopReplay:
|
||||
DELETENULL(*Interact);
|
||||
DELETENULL(ReplayControl);
|
||||
DELETENULL(Menu);
|
||||
cControl::Shutdown();
|
||||
Temp = NULL;
|
||||
break;
|
||||
case osSwitchDvb:
|
||||
DELETENULL(*Interact);
|
||||
DELETENULL(Menu);
|
||||
cControl::Shutdown();
|
||||
Temp = NULL;
|
||||
Interface->Info(tr("Switching primary DVB..."));
|
||||
cDevice::SetPrimaryDevice(Setup.PrimaryDVB);
|
||||
break;
|
||||
case osBack:
|
||||
case osEnd: DELETENULL(*Interact);
|
||||
case osEnd: if (Interact == Menu)
|
||||
DELETENULL(Menu);
|
||||
else
|
||||
cControl::Shutdown();
|
||||
Temp = NULL;
|
||||
break;
|
||||
default: ;
|
||||
@ -552,7 +558,7 @@ int main(int argc, char *argv[])
|
||||
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);
|
||||
if (Now - LastActivity > ACTIVITYTIMEOUT) {
|
||||
// Shutdown:
|
||||
@ -614,7 +620,7 @@ int main(int argc, char *argv[])
|
||||
cRecordControls::Shutdown();
|
||||
cCutter::Stop();
|
||||
delete Menu;
|
||||
delete ReplayControl;
|
||||
cControl::Shutdown();
|
||||
delete Interface;
|
||||
cOsd::Shutdown();
|
||||
PluginManager.Shutdown(true);
|
||||
|
Loading…
Reference in New Issue
Block a user