summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--menu.c83
-rw-r--r--menu.h18
-rw-r--r--osd.h14
-rw-r--r--vdr.c90
4 files changed, 122 insertions, 83 deletions
diff --git a/menu.c b/menu.c
index 82983c48..c948f8de 100644
--- a/menu.c
+++ b/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.9 2000/04/29 08:52:54 kls Exp $
+ * $Id: menu.c 1.10 2000/04/29 14:53:27 kls Exp $
*/
#include "menu.h"
@@ -947,9 +947,8 @@ eOSState cMenuRecordings::Play(void)
{
cMenuRecordingItem *ri = (cMenuRecordingItem *)Get(Current());
if (ri) {
-//XXX what if this recording's file is currently in use???
- if (DvbApi.StartReplay(ri->recording->FileName(), ri->recording->Title()))
- return osEnd;
+ cReplayControl::SetRecording(ri->recording->FileName(), ri->recording->Title());
+ return osReplay;
}
return osContinue;
}
@@ -1008,41 +1007,75 @@ eOSState cMenuMain::ProcessKey(eKeys Key)
case osChannels: return AddSubMenu(new cMenuChannels);
case osTimer: return AddSubMenu(new cMenuTimers);
case osRecordings: return AddSubMenu(new cMenuRecordings);
- default: break;
+ default: if (Key == kMenu)
+ state = osEnd;
}
return state;
}
-// --- cReplayDisplay --------------------------------------------------------
+// --- cReplayControl --------------------------------------------------------
+
+char *cReplayControl::fileName = NULL;
+char *cReplayControl::title = NULL;
+
+cReplayControl::cReplayControl(void)
+{
+ visible = shown = false;
+ if (fileName)
+ DvbApi.StartReplay(fileName, title);
+}
+
+cReplayControl::~cReplayControl()
+{
+ Hide();
+ DvbApi.StopReplay();
+}
+
+void cReplayControl::SetRecording(const char *FileName, const char *Title)
+{
+ delete fileName;
+ delete title;
+ fileName = FileName ? strdup(FileName) : NULL;
+ title = Title ? strdup(Title) : NULL;
+}
-cReplayDisplay::cReplayDisplay(void)
+void cReplayControl::Show(void)
{
- Interface.Open(MenuColumns, -3);
- shown = DvbApi.ShowProgress(true);
+ if (!visible) {
+ Interface.Open(MenuColumns, -3);
+ visible = true;
+ shown = DvbApi.ShowProgress(true);
+ }
}
-cReplayDisplay::~cReplayDisplay()
+void cReplayControl::Hide(void)
{
- Interface.Close();
+ if (visible) {
+ Interface.Close();
+ visible = false;
+ }
}
-eKeys cReplayDisplay::ProcessKey(eKeys Key)
+eOSState cReplayControl::ProcessKey(eKeys Key)
{
if (!DvbApi.Replaying())
- return kOk; // will turn off replay display
- shown = DvbApi.ShowProgress(!shown) || shown;
+ return osEnd;
+ if (visible)
+ shown = DvbApi.ShowProgress(!shown) || shown;
switch (Key) {
- case kBegin:
- case kPause:
- case kStop:
- case kSearchBack:
- case kSearchForward:
- case kSkipBack:
- case kSkipForward: break; // will be done in main loop
- case kMenu: break; // allow direct switching to menu
- case kOk: break; // switches off replay display
- default: Key = kNone; // ignore anything not explicitly known here
+ case kBegin: DvbApi.Skip(-INT_MAX); break;
+ case kPause: DvbApi.PauseReplay(); break;
+ case kStop: Hide();
+ DvbApi.StopReplay();
+ return osEnd;
+ case kSearchBack: DvbApi.FastRewind(); break;
+ case kSearchForward: DvbApi.FastForward(); break;
+ case kSkipBack: DvbApi.Skip(-60); break;
+ case kSkipForward: DvbApi.Skip(60); break;
+ case kMenu: Hide(); return osMenu; // allow direct switching to menu
+ case kOk: visible ? Hide() : Show(); break;
+ default: return osUnknown;
}
- return Key;
+ return osContinue;
}
diff --git a/menu.h b/menu.h
index f6657996..a5317f36 100644
--- a/menu.h
+++ b/menu.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: menu.h 1.5 2000/04/24 15:31:53 kls Exp $
+ * $Id: menu.h 1.6 2000/04/29 15:38:39 kls Exp $
*/
#ifndef _MENU_H
@@ -18,13 +18,19 @@ public:
virtual eOSState ProcessKey(eKeys Key);
};
-class cReplayDisplay {
+class cReplayControl : public cOsdBase {
private:
- bool shown;
+ bool visible, shown;
+ void Show(void);
+ void Hide(void);
+ static char *fileName;
+ static char *title;
public:
- cReplayDisplay(void);
- ~cReplayDisplay();
- eKeys ProcessKey(eKeys Key);
+ cReplayControl(void);
+ virtual ~cReplayControl();
+ virtual eOSState ProcessKey(eKeys Key);
+ bool Visible(void) { return visible; }
+ static void SetRecording(const char *FileName, const char *Title);
};
#endif //_MENU_H
diff --git a/osd.h b/osd.h
index 99821b87..11145319 100644
--- a/osd.h
+++ b/osd.h
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: osd.h 1.4 2000/04/24 09:44:32 kls Exp $
+ * $Id: osd.h 1.5 2000/04/29 14:45:47 kls Exp $
*/
#ifndef __OSD_H
@@ -17,11 +17,12 @@
#define MAXOSDITEMS 9
enum eOSState { osUnknown,
+ osMenu,
osContinue,
- osProcessed,
osChannels,
osTimer,
osRecordings,
+ osReplay,
osBack,
osEnd,
};
@@ -44,7 +45,14 @@ public:
virtual eOSState ProcessKey(eKeys Key);
};
-class cOsdMenu : public cList<cOsdItem> {
+class cOsdBase {
+public:
+ cOsdBase(void) {}
+ virtual ~cOsdBase() {}
+ virtual eOSState ProcessKey(eKeys Key) = 0;
+ };
+
+class cOsdMenu : public cOsdBase, public cList<cOsdItem> {
private:
char *title;
int cols[cInterface::MaxCols];
diff --git a/vdr.c b/vdr.c
index e77f529b..7964e941 100644
--- a/vdr.c
+++ b/vdr.c
@@ -22,7 +22,7 @@
*
* The project's page is at http://www.cadsoft.de/people/kls/vdr
*
- * $Id: vdr.c 1.13 2000/04/29 13:13:42 kls Exp $
+ * $Id: vdr.c 1.14 2000/04/29 15:57:42 kls Exp $
*/
#include <signal.h>
@@ -65,7 +65,7 @@ int main(int argc, char *argv[])
if (signal(SIGTERM, SignalHandler) == SIG_IGN) signal(SIGTERM, SIG_IGN);
cMenuMain *Menu = NULL;
- cReplayDisplay *ReplayDisplay = NULL;
+ cReplayControl *ReplayControl = NULL;
cTimer *Timer = NULL;
int dcTime = 0, dcNumber = 0;
int LastChannel = -1;
@@ -73,7 +73,7 @@ int main(int argc, char *argv[])
while (!Interrupted) {
// Channel display:
if (CurrentChannel != LastChannel) {
- if (!Timer && !Menu && !ReplayDisplay) {
+ if (!Timer) {
cChannel *channel = Channels.Get(CurrentChannel);
if (channel)
Interface.DisplayChannel(CurrentChannel + 1, channel->name);
@@ -81,20 +81,17 @@ int main(int argc, char *argv[])
LastChannel = CurrentChannel;
}
// Direct Channel Select (action):
- if (dcNumber) {
- Interface.DisplayChannel(dcNumber);
- if (time_ms() - dcTime > DIRECTCHANNELTIMEOUT) {
- cChannel::SwitchTo(dcNumber - 1);
- dcNumber = 0;
- LastChannel = -1; // in case an invalid channel number was entered!
- }
+ if (dcNumber && time_ms() - dcTime > DIRECTCHANNELTIMEOUT) {
+ cChannel::SwitchTo(dcNumber - 1);
+ dcNumber = 0;
+ LastChannel = -1; // in case an invalid channel number was entered!
}
// Timer Processing:
else {
AssertFreeDiskSpace();
if (!Timer && (Timer = cTimer::GetMatch()) != NULL) {
DELETENULL(Menu);
- DELETENULL(ReplayDisplay);
+ DELETENULL(ReplayControl);
// make sure the timer won't be deleted:
Timer->SetRecording(true);
// switch to channel:
@@ -119,50 +116,50 @@ int main(int argc, char *argv[])
}
}
// User Input:
- eKeys key = Interface.GetKey(!ReplayDisplay);
- if (Menu) {
- switch (Menu->ProcessKey(key)) {
- default: if (key != kMenu)
- break;
+ eKeys key = Interface.GetKey(!ReplayControl || !ReplayControl->Visible());
+ cOsdBase **Interact = Menu ? (cOsdBase **)&Menu : (cOsdBase **)&ReplayControl;
+ if (*Interact) {
+ switch ((*Interact)->ProcessKey(key)) {
+ case osMenu: DELETENULL(Menu);
+ Menu = new cMenuMain;
+ Menu->Display();
+ break;
+ case osReplay: DELETENULL(Menu);
+ DELETENULL(ReplayControl);
+ ReplayControl = new cReplayControl;
+ break;
case osBack:
- case osEnd: DELETENULL(Menu);
- break;
+ case osEnd: DELETENULL(*Interact);
+ break;
+ default: ;
}
}
- else if (!ReplayDisplay || (key = ReplayDisplay->ProcessKey(key)) != kNone) {
+ else {
switch (key) {
// Direct Channel Select (input):
case k0: case k1: case k2: case k3: case k4: case k5: case k6: case k7: case k8: case k9:
- {
- if (!(DvbApi.Recording() || DvbApi.Replaying())) {
- dcNumber = dcNumber * 10 + key - k0;
- dcTime = time_ms();
+ {
+ if (!DvbApi.Recording()) {
+ dcNumber = dcNumber * 10 + key - k0;
+ dcTime = time_ms();
+ Interface.DisplayChannel(dcNumber);
+ }
}
- }
- // Record/Replay Control:
- case kBegin: DvbApi.Skip(-INT_MAX); break;
- case kRecord: if (!(DvbApi.Recording() || DvbApi.Replaying())) {
- cTimer *timer = new cTimer(true);
- Timers.Add(timer);
- Timers.Save();
- }
- break;
- case kPause: DvbApi.PauseReplay(); break;
- case kStop: DELETENULL(ReplayDisplay);
- DvbApi.StopReplay();
- break;
- case kSearchBack: DvbApi.FastRewind(); break;
- case kSearchForward: DvbApi.FastForward(); break;
- case kSkipBack: DvbApi.Skip(-60); break;
- case kSkipForward: DvbApi.Skip(60); break;
+ break;
+ // Instant Recording:
+ case kRecord: if (!DvbApi.Recording()) {
+ cTimer *timer = new cTimer(true);
+ Timers.Add(timer);
+ Timers.Save();
+ }
+ break;
// Menu Control:
- case kMenu: DELETENULL(ReplayDisplay);
- Menu = new cMenuMain;
+ case kMenu: Menu = new cMenuMain;
Menu->Display();
break;
// Up/Down Channel Select:
case kUp:
- case kDown: if (!(DvbApi.Recording() || DvbApi.Replaying())) {
+ case kDown: if (!DvbApi.Recording()) {
int n = CurrentChannel + (key == kUp ? 1 : -1);
cChannel *channel = Channels.Get(n);
if (channel)
@@ -170,12 +167,7 @@ int main(int argc, char *argv[])
}
break;
// Viewing Control:
- case kOk: if (ReplayDisplay)
- DELETENULL(ReplayDisplay);
- else if (DvbApi.Replaying())
- ReplayDisplay = new cReplayDisplay;
- else
- LastChannel = -1; break; // forces channel display
+ case kOk: LastChannel = -1; break; // forces channel display
default: break;
}
}