diff options
Diffstat (limited to 'vdr.c')
-rw-r--r-- | vdr.c | 220 |
1 files changed, 120 insertions, 100 deletions
@@ -22,7 +22,7 @@ * * The project's page is at http://www.cadsoft.de/people/kls/vdr * - * $Id: vdr.c 1.73 2001/09/16 14:54:45 kls Exp $ + * $Id: vdr.c 1.79 2001/09/23 14:33:39 kls Exp $ */ #define _GNU_SOURCE @@ -96,6 +96,7 @@ int main(int argc, char *argv[]) { "help", no_argument, NULL, 'h' }, { "log", required_argument, NULL, 'l' }, { "port", required_argument, NULL, 'p' }, + { "record", required_argument, NULL, 'r' }, { "shutdown", required_argument, NULL, 's' }, { "terminal", required_argument, NULL, 't' }, { "video", required_argument, NULL, 'v' }, @@ -106,7 +107,7 @@ int main(int argc, char *argv[]) int c; int option_index = 0; - while ((c = getopt_long(argc, argv, "a:c:dD:E:hl:p:s:t:v:V:w:", long_options, &option_index)) != -1) { + while ((c = getopt_long(argc, argv, "a:c:dD:E:hl:p:r:s:t:v:V:w:", long_options, &option_index)) != -1) { switch (c) { case 'a': cDvbApi::SetAudioCommand(optarg); break; @@ -143,6 +144,7 @@ int main(int argc, char *argv[]) " 2 = errors and info, 3 = errors, info and debug\n" " -p PORT, --port=PORT use PORT for SVDRP (default: %d)\n" " 0 turns off SVDRP\n" + " -r CMD, --record=CMD call CMD before and after a recording\n" " -s CMD, --shutdown=CMD call CMD to shutdown the computer\n" " -t TTY, --terminal=TTY controlling tty\n" " -v DIR, --video=DIR use DIR as video directory (default: %s)\n" @@ -180,6 +182,8 @@ int main(int argc, char *argv[]) return 2; } break; + case 'r': cRecordingUserCommand::SetCommand(optarg); + break; case 's': Shutdown = optarg; break; case 't': Terminal = optarg; @@ -278,6 +282,7 @@ int main(int argc, char *argv[]) cDvbApi::SetPrimaryDvbApi(Setup.PrimaryDVB); Channels.SwitchTo(Setup.CurrentChannel); + cDvbApi::PrimaryDvbApi->SetVolume(Setup.CurrentVolume, true); cEITScanner EITScanner; @@ -305,6 +310,7 @@ int main(int argc, char *argv[]) int LastChannel = -1; int PreviousChannel = cDvbApi::CurrentChannel(); time_t LastActivity = 0; + time_t LinearTime = time(NULL); int MaxLatencyTime = 0; bool ForceShutdown = false; @@ -314,6 +320,14 @@ int main(int argc, char *argv[]) } while (!Interrupted) { + // Test if we are running in the Einstein continuum: + time_t Now = time(NULL); + time_t LinearDelta = Now - LinearTime; + if (LinearDelta) { + if (LinearDelta < 0 || LinearDelta > 300) // assuming nothing will block for more than 5 minutes + esyslog(LOG_ERR, "ERROR: time warp detected (%d seconds)", LinearDelta); + LinearTime = Now; + } // Handle emergency exits: if (cThread::EmergencyExit()) { esyslog(LOG_ERR, "emergency exit requested - shutting down"); @@ -341,6 +355,7 @@ int main(int argc, char *argv[]) cRecordControls::Process(Now); cTimer *Timer = Timers.GetMatch(Now); if (Timer) { + dsyslog(LOG_INFO, "system time seen is %s", ctime(&Now)); if (!cRecordControls::Start(Timer)) Timer->SetPending(true); } @@ -352,106 +367,111 @@ int main(int argc, char *argv[]) EITScanner.Activity(); LastActivity = time(NULL); } - if (*Interact && key != kPower) { - switch ((*Interact)->ProcessKey(key)) { - case osMenu: DELETENULL(Menu); - Menu = new cMenuMain(ReplayControl); - break; - case osRecord: DELETENULL(Menu); - if (!cRecordControls::Start()) - Interface->Error(tr("No free DVB device to record!")); - break; - case osRecordings: - DELETENULL(Menu); - DELETENULL(ReplayControl); - Menu = new cMenuRecordings; - break; - case osReplay: DELETENULL(Menu); - DELETENULL(ReplayControl); - ReplayControl = new cReplayControl; - break; + // Keys that must work independent of any interactive mode: + switch (key) { + // Volume Control: + case kVolUp|k_Repeat: + case kVolUp: + case kVolDn|k_Repeat: + case kVolDn: + cDvbApi::PrimaryDvbApi->SetVolume(NORMALKEY(key) == kVolDn ? -VOLUMEDELTA : VOLUMEDELTA); + break; + case kMute: + cDvbApi::PrimaryDvbApi->ToggleMute(); + break; + // Power off: + case kPower: isyslog(LOG_INFO, "Power button pressed"); + DELETENULL(*Interact); + if (!Shutdown) { + Interface->Error(tr("Can't shutdown - option '-s' not given!")); + break; + } + if (cRecordControls::Active()) { + if (Interface->Confirm(tr("Recording - shut down anyway?"))) + ForceShutdown = true; + } + LastActivity = 1; // not 0, see below! + break; + default: + if (*Interact) { + switch ((*Interact)->ProcessKey(key)) { + case osMenu: DELETENULL(Menu); + Menu = new cMenuMain(ReplayControl); + break; + case osRecord: DELETENULL(Menu); + if (!cRecordControls::Start()) + Interface->Error(tr("No free DVB device to record!")); + break; + case osRecordings: + DELETENULL(Menu); + DELETENULL(ReplayControl); + Menu = new cMenuRecordings; + break; + case osReplay: DELETENULL(Menu); + DELETENULL(ReplayControl); + ReplayControl = new cReplayControl; + break; #ifdef DVDSUPPORT - case osDVD: DELETENULL(Menu); - DELETENULL(ReplayControl); - Menu = new cMenuDVD; - break; + case osDVD: DELETENULL(Menu); + DELETENULL(ReplayControl); + Menu = new cMenuDVD; + break; #endif //DVDSUPPORT - case osStopReplay: - DELETENULL(*Interact); - DELETENULL(ReplayControl); - break; - case osSwitchDvb: - DELETENULL(*Interact); - Interface->Info(tr("Switching primary DVB...")); - cDvbApi::SetPrimaryDvbApi(Setup.PrimaryDVB); - break; - case osBack: - case osEnd: DELETENULL(*Interact); - break; - default: ; - } - } - else { - switch (key) { - // Toggle channels: - case k0: { - int CurrentChannel = cDvbApi::CurrentChannel(); - Channels.SwitchTo(PreviousChannel); - PreviousChannel = CurrentChannel; - break; - } - // Direct Channel Select: - case k1 ... k9: - Menu = new cDisplayChannel(key); - break; - // Left/Right rotates trough channel groups: - case kLeft|k_Repeat: - case kLeft: - case kRight|k_Repeat: - case kRight: - Menu = new cDisplayChannel(NORMALKEY(key)); - break; - // Up/Down Channel Select: - case kUp|k_Repeat: - case kUp: - case kDown|k_Repeat: - case kDown: { - int n = cDvbApi::CurrentChannel() + (NORMALKEY(key) == kUp ? 1 : -1); - cChannel *channel = Channels.GetByNumber(n); - if (channel) - channel->Switch(); - break; - } - // Menu Control: - case kMenu: Menu = new cMenuMain(ReplayControl); break; - // Viewing Control: - case kOk: LastChannel = -1; break; // forces channel display - // Volume Control: - case kVolUp|k_Repeat: - case kVolUp: - case kVolDn|k_Repeat: - case kVolDn: - cDvbApi::PrimaryDvbApi->SetVolume(NORMALKEY(key) == kVolDn ? -VOLUMEDELTA : VOLUMEDELTA); - break; - case kMute: - cDvbApi::PrimaryDvbApi->ToggleMute(); - break; - // Power off: - case kPower: isyslog(LOG_INFO, "Power button pressed"); - DELETENULL(*Interact); - if (!Shutdown) { - Interface->Error(tr("Can't shutdown - option '-s' not given!")); - break; - } - if (cRecordControls::Active()) { - if (Interface->Confirm(tr("Recording - shut down anyway?"))) - ForceShutdown = true; - } - LastActivity = 1; // not 0, see below! - break; - default: break; - } - } + case osStopReplay: + DELETENULL(*Interact); + DELETENULL(ReplayControl); + break; + case osSwitchDvb: + DELETENULL(*Interact); + Interface->Info(tr("Switching primary DVB...")); + cDvbApi::SetPrimaryDvbApi(Setup.PrimaryDVB); + break; + case osBack: + case osEnd: DELETENULL(*Interact); + break; + default: ; + } + } + else { + // Key functions in "normal" viewing mode: + switch (key) { + // Toggle channels: + case k0: { + int CurrentChannel = cDvbApi::CurrentChannel(); + Channels.SwitchTo(PreviousChannel); + PreviousChannel = CurrentChannel; + break; + } + // Direct Channel Select: + case k1 ... k9: + Menu = new cDisplayChannel(key); + break; + // Left/Right rotates trough channel groups: + case kLeft|k_Repeat: + case kLeft: + case kRight|k_Repeat: + case kRight: + Menu = new cDisplayChannel(NORMALKEY(key)); + break; + // Up/Down Channel Select: + case kUp|k_Repeat: + case kUp: + case kDown|k_Repeat: + case kDown: { + int n = cDvbApi::CurrentChannel() + (NORMALKEY(key) == kUp ? 1 : -1); + cChannel *channel = Channels.GetByNumber(n); + if (channel) + channel->Switch(); + break; + } + // Menu Control: + case kMenu: Menu = new cMenuMain(ReplayControl); break; + // Viewing Control: + case kOk: LastChannel = -1; break; // forces channel display + default: break; + } + } + } if (!Menu) { EITScanner.Process(); cVideoCutter::Active(); |