vdr/vdr.c

548 lines
21 KiB
C
Raw Normal View History

2000-02-19 13:36:48 +01:00
/*
2000-04-24 09:46:05 +02:00
* vdr.c: Video Disk Recorder main program
2000-02-19 13:36:48 +01:00
*
* Copyright (C) 2000 Klaus Schmidinger
2001-08-03 14:18:08 +02:00
*
2000-02-19 13:36:48 +01:00
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
2001-08-03 14:18:08 +02:00
*
2000-02-19 13:36:48 +01:00
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
2001-08-03 14:18:08 +02:00
*
2000-02-19 13:36:48 +01:00
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
* Or, point your browser to http://www.gnu.org/copyleft/gpl.html
2001-08-03 14:18:08 +02:00
*
2000-02-19 13:36:48 +01:00
* The author can be reached at kls@cadsoft.de
*
* The project's page is at http://www.cadsoft.de/people/kls/vdr
*
2002-02-02 17:20:54 +01:00
* $Id: vdr.c 1.94 2002/02/02 15:59:18 kls Exp $
2000-02-19 13:36:48 +01:00
*/
2000-07-23 15:01:31 +02:00
#include <getopt.h>
#include <locale.h>
#include <signal.h>
2000-07-23 15:01:31 +02:00
#include <stdlib.h>
2000-07-23 15:36:43 +02:00
#include <unistd.h>
2000-02-19 13:36:48 +01:00
#include "config.h"
2000-05-01 16:29:46 +02:00
#include "dvbapi.h"
2001-08-06 16:19:20 +02:00
#ifdef DVDSUPPORT
2001-08-03 14:18:08 +02:00
#include "dvd.h"
2001-08-06 16:19:20 +02:00
#endif //DVDSUPPORT
2000-11-11 10:39:27 +01:00
#include "i18n.h"
2000-02-19 13:36:48 +01:00
#include "interface.h"
#include "menu.h"
#include "recording.h"
2000-02-19 13:36:48 +01:00
#include "tools.h"
#include "videodir.h"
2000-02-19 13:36:48 +01:00
2000-07-15 12:39:20 +02:00
#ifdef REMOTE_KBD
2000-02-19 13:36:48 +01:00
#define KEYS_CONF "keys-pc.conf"
#else
#define KEYS_CONF "keys.conf"
#endif
2001-02-11 14:53:44 +01:00
#define ACTIVITYTIMEOUT 60 // seconds before starting housekeeping
2001-09-01 09:04:37 +02:00
#define SHUTDOWNWAIT 300 // seconds to wait in user prompt before automatic shutdown
2001-09-07 15:37:26 +02:00
#define MANUALSTART 600 // seconds the next timer must be in the future to assume manual start
2001-02-11 14:53:44 +01:00
#define VOLUMEDELTA 5 // used to increase/decrease the volume
static int Interrupted = 0;
static void SignalHandler(int signum)
{
2001-09-01 09:04:37 +02:00
if (signum != SIGPIPE) {
Interrupted = signum;
2001-09-01 09:04:37 +02:00
Interface->Interrupt();
}
signal(signum, SignalHandler);
}
2001-02-24 16:18:43 +01:00
static void Watchdog(int signum)
{
// Something terrible must have happened that prevented the 'alarm()' from
// being called in time, so let's get out of here:
esyslog(LOG_ERR, "PANIC: watchdog timer expired - exiting!");
exit(1);
}
2000-02-19 13:36:48 +01:00
int main(int argc, char *argv[])
{
// Initiate locale:
setlocale(LC_ALL, "");
2000-07-23 15:01:31 +02:00
// Command line options:
#define DEFAULTSVDRPPORT 2001
2001-02-24 16:18:43 +01:00
#define DEFAULTWATCHDOG 0 // seconds
2000-07-23 15:01:31 +02:00
int SVDRPport = DEFAULTSVDRPPORT;
const char *ConfigDirectory = NULL;
2000-07-23 15:36:43 +02:00
bool DaemonMode = false;
2001-02-24 16:18:43 +01:00
int WatchdogTimeout = DEFAULTWATCHDOG;
2001-09-01 09:04:37 +02:00
const char *Terminal = NULL;
const char *Shutdown = NULL;
2000-07-23 15:01:31 +02:00
static struct option long_options[] = {
2001-06-24 17:42:19 +02:00
{ "audio", required_argument, NULL, 'a' },
2001-02-24 16:18:43 +01:00
{ "config", required_argument, NULL, 'c' },
{ "daemon", no_argument, NULL, 'd' },
{ "device", required_argument, NULL, 'D' },
2001-08-11 09:38:12 +02:00
{ "epgfile", required_argument, NULL, 'E' },
2001-02-24 16:18:43 +01:00
{ "help", no_argument, NULL, 'h' },
{ "log", required_argument, NULL, 'l' },
{ "port", required_argument, NULL, 'p' },
2001-09-22 14:23:55 +02:00
{ "record", required_argument, NULL, 'r' },
2001-09-01 09:04:37 +02:00
{ "shutdown", required_argument, NULL, 's' },
{ "terminal", required_argument, NULL, 't' },
2001-02-24 16:18:43 +01:00
{ "video", required_argument, NULL, 'v' },
2001-08-03 14:18:08 +02:00
{ "dvd", required_argument, NULL, 'V' },
2001-02-24 16:18:43 +01:00
{ "watchdog", required_argument, NULL, 'w' },
2001-08-11 09:38:12 +02:00
{ NULL }
2000-07-23 15:01:31 +02:00
};
2001-08-03 14:18:08 +02:00
2000-07-23 15:01:31 +02:00
int c;
int option_index = 0;
2001-09-22 14:23:55 +02:00
while ((c = getopt_long(argc, argv, "a:c:dD:E:hl:p:r:s:t:v:V:w:", long_options, &option_index)) != -1) {
2000-07-23 15:01:31 +02:00
switch (c) {
2001-06-24 17:42:19 +02:00
case 'a': cDvbApi::SetAudioCommand(optarg);
break;
case 'c': ConfigDirectory = optarg;
break;
2000-07-23 15:36:43 +02:00
case 'd': DaemonMode = true; break;
2001-02-02 15:49:46 +01:00
case 'D': if (isnumber(optarg)) {
int n = atoi(optarg);
if (0 <= n && n < MAXDVBAPI) {
cDvbApi::SetUseDvbApi(n);
break;
}
}
fprintf(stderr, "vdr: invalid DVB device number: %s\n", optarg);
2001-04-01 11:18:28 +02:00
return 2;
2001-02-02 15:49:46 +01:00
break;
2001-08-11 09:38:12 +02:00
case 'E': cSIProcessor::SetEpgDataFileName(*optarg != '-' ? optarg : NULL);
break;
case 'h': printf("Usage: vdr [OPTION]\n\n" // for easier orientation, this is column 80|
2001-06-24 17:42:19 +02:00
" -a CMD, --audio=CMD send Dolby Digital audio to stdin of command CMD\n"
2001-02-24 16:18:43 +01:00
" -c DIR, --config=DIR read config files from DIR (default is to read them\n"
" from the video directory)\n"
" -d, --daemon run in daemon mode\n"
" -D NUM, --device=NUM use only the given DVB device (NUM = 0, 1, 2...)\n"
" there may be several -D options (default: all DVB\n"
" devices will be used)\n"
2001-08-11 09:38:12 +02:00
" -E FILE --epgfile=FILE write the EPG data into the given FILE (default is\n"
" %s); use '-E-' to disable this\n"
" if FILE is a directory, the default EPG file will be\n"
" created in that directory\n"
" -h, --help display this help and exit\n"
2001-02-24 16:18:43 +01:00
" -l LEVEL, --log=LEVEL set log level (default: 3)\n"
" 0 = no logging, 1 = errors only,\n"
" 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"
2001-09-22 14:23:55 +02:00
" -r CMD, --record=CMD call CMD before and after a recording\n"
2001-09-01 09:04:37 +02:00
" -s CMD, --shutdown=CMD call CMD to shutdown the computer\n"
2001-08-11 09:38:12 +02:00
" -t TTY, --terminal=TTY controlling tty\n"
2001-03-31 10:32:58 +02:00
" -v DIR, --video=DIR use DIR as video directory (default: %s)\n"
2001-08-03 14:18:08 +02:00
" -V DEV, --dvd=DEV use DEV as the DVD device (default: %s)\n"
2001-02-24 16:18:43 +01:00
" -w SEC, --watchdog=SEC activate the watchdog timer with a timeout of SEC\n"
" seconds (default: %d); '0' disables the watchdog\n"
2000-07-23 15:01:31 +02:00
"\n"
2000-07-28 13:44:31 +02:00
"Report bugs to <vdr-bugs@cadsoft.de>\n",
2001-08-11 09:38:12 +02:00
cSIProcessor::GetEpgDataFileName() ? cSIProcessor::GetEpgDataFileName() : "'-'",
2000-07-28 13:44:31 +02:00
DEFAULTSVDRPPORT,
2001-02-24 16:18:43 +01:00
VideoDirectory,
2001-08-06 16:19:20 +02:00
#ifdef DVDSUPPORT
2001-08-03 14:18:08 +02:00
cDVD::DeviceName(),
2001-08-06 16:19:20 +02:00
#else
"no DVD support",
#endif //DVDSUPPORT
2001-02-24 16:18:43 +01:00
DEFAULTWATCHDOG
2000-07-23 15:01:31 +02:00
);
return 0;
break;
case 'l': if (isnumber(optarg)) {
int l = atoi(optarg);
if (0 <= l && l <= 3) {
SysLogLevel = l;
break;
}
}
fprintf(stderr, "vdr: invalid log level: %s\n", optarg);
2001-04-01 11:18:28 +02:00
return 2;
break;
2000-07-23 15:01:31 +02:00
case 'p': if (isnumber(optarg))
SVDRPport = atoi(optarg);
2000-07-23 15:01:31 +02:00
else {
fprintf(stderr, "vdr: invalid port number: %s\n", optarg);
2001-04-01 11:18:28 +02:00
return 2;
2000-07-23 15:01:31 +02:00
}
break;
case 'r': cRecordingUserCommand::SetCommand(optarg);
2001-09-22 14:23:55 +02:00
break;
2001-09-01 09:04:37 +02:00
case 's': Shutdown = optarg;
break;
2001-03-31 10:32:58 +02:00
case 't': Terminal = optarg;
break;
2000-07-28 13:44:31 +02:00
case 'v': VideoDirectory = optarg;
while (optarg && *optarg && optarg[strlen(optarg) - 1] == '/')
optarg[strlen(optarg) - 1] = 0;
2000-07-28 13:44:31 +02:00
break;
2001-08-06 16:19:20 +02:00
case 'V':
#ifdef DVDSUPPORT
cDVD::SetDeviceName(optarg);
2001-08-05 15:11:35 +02:00
if (!cDVD::DriveExists()) {
fprintf(stderr, "vdr: DVD drive not found: %s\n", optarg);
return 2;
}
2001-08-06 16:19:20 +02:00
#else
fprintf(stderr, "vdr: DVD support has not been compiled in!");
return 2;
#endif //DVDSUPPORT
2001-08-03 14:18:08 +02:00
break;
2001-02-24 16:18:43 +01:00
case 'w': if (isnumber(optarg)) {
int t = atoi(optarg);
if (t >= 0) {
WatchdogTimeout = t;
break;
}
}
fprintf(stderr, "vdr: invalid watchdog timeout: %s\n", optarg);
2001-04-01 11:18:28 +02:00
return 2;
2001-02-24 16:18:43 +01:00
break;
2001-04-01 11:18:28 +02:00
default: return 2;
2000-07-23 15:01:31 +02:00
}
}
// Log file:
2001-08-03 14:18:08 +02:00
if (SysLogLevel > 0)
openlog("vdr", LOG_PID | LOG_CONS, LOG_USER);
2000-07-23 15:36:43 +02:00
2000-07-28 13:44:31 +02:00
// Check the video directory:
if (!DirectoryOk(VideoDirectory, true)) {
2000-07-28 13:44:31 +02:00
fprintf(stderr, "vdr: can't access video directory %s\n", VideoDirectory);
2001-04-01 11:18:28 +02:00
return 2;
2000-07-28 13:44:31 +02:00
}
2000-07-23 15:36:43 +02:00
// Daemon mode:
if (DaemonMode) {
2000-09-20 16:49:49 +02:00
#if !defined(DEBUG_OSD) && !defined(REMOTE_KBD)
2000-07-23 15:36:43 +02:00
pid_t pid = fork();
if (pid < 0) {
2000-12-08 16:23:32 +01:00
fprintf(stderr, "%m\n");
esyslog(LOG_ERR, "ERROR: %m");
2001-04-01 11:18:28 +02:00
return 2;
2000-07-23 15:36:43 +02:00
}
if (pid != 0)
return 0; // initial program immediately returns
fclose(stdin);
fclose(stdout);
fclose(stderr);
#else
2000-09-20 16:49:49 +02:00
fprintf(stderr, "vdr: can't run in daemon mode with DEBUG_OSD or REMOTE_KBD on!\n");
2001-04-01 11:18:28 +02:00
return 2;
2000-07-23 15:36:43 +02:00
#endif
}
2001-03-31 10:32:58 +02:00
else if (Terminal) {
// Claim new controlling terminal
stdin = freopen(Terminal, "r", stdin);
stdout = freopen(Terminal, "w", stdout);
stderr = freopen(Terminal, "w", stderr);
}
2000-07-29 18:19:49 +02:00
isyslog(LOG_INFO, "VDR version %s started", VDRVERSION);
2000-02-19 13:36:48 +01:00
2000-07-23 15:01:31 +02:00
// Configuration data:
if (!ConfigDirectory)
ConfigDirectory = VideoDirectory;
Setup.Load(AddDirectory(ConfigDirectory, "setup.conf"));
Channels.Load(AddDirectory(ConfigDirectory, "channels.conf"));
Timers.Load(AddDirectory(ConfigDirectory, "timers.conf"));
2000-11-11 16:38:41 +01:00
Commands.Load(AddDirectory(ConfigDirectory, "commands.conf"));
2002-02-02 17:20:54 +01:00
SVDRPhosts.Load(AddDirectory(ConfigDirectory, "svdrphosts.conf"), true);
2001-02-04 19:41:24 +01:00
#if defined(REMOTE_LIRC)
2000-07-15 16:35:18 +02:00
Keys.SetDummyValues();
2001-02-04 19:41:24 +01:00
#elif !defined(REMOTE_NONE)
2000-10-29 14:00:00 +01:00
bool KeysLoaded = Keys.Load(AddDirectory(ConfigDirectory, KEYS_CONF));
2000-07-15 12:39:20 +02:00
#endif
2000-02-19 13:36:48 +01:00
// DVB interfaces:
if (!cDvbApi::Init())
2001-04-01 11:18:28 +02:00
return 2;
2000-09-10 10:51:58 +02:00
cDvbApi::SetPrimaryDvbApi(Setup.PrimaryDVB);
Channels.SwitchTo(Setup.CurrentChannel);
2001-09-22 13:41:49 +02:00
cDvbApi::PrimaryDvbApi->SetVolume(Setup.CurrentVolume, true);
2000-02-19 13:36:48 +01:00
cEITScanner EITScanner;
2000-10-29 14:00:00 +01:00
// User interface:
Interface = new cInterface(SVDRPport);
2001-02-04 19:41:24 +01:00
#if !defined(REMOTE_LIRC) && !defined(REMOTE_NONE)
2000-10-29 14:00:00 +01:00
if (!KeysLoaded)
Interface->LearnKeys();
#endif
2000-07-23 15:01:31 +02:00
// Signal handlers:
if (signal(SIGHUP, SignalHandler) == SIG_IGN) signal(SIGHUP, SIG_IGN);
if (signal(SIGINT, SignalHandler) == SIG_IGN) signal(SIGINT, SIG_IGN);
if (signal(SIGTERM, SignalHandler) == SIG_IGN) signal(SIGTERM, SIG_IGN);
if (signal(SIGPIPE, SignalHandler) == SIG_IGN) signal(SIGPIPE, SIG_IGN);
2001-02-24 16:18:43 +01:00
if (WatchdogTimeout > 0)
if (signal(SIGALRM, Watchdog) == SIG_IGN) signal(SIGALRM, SIG_IGN);
2000-07-23 15:01:31 +02:00
// Main program loop:
cOsdBase *Menu = NULL;
cReplayControl *ReplayControl = NULL;
2000-04-22 13:51:48 +02:00
int LastChannel = -1;
2000-11-05 18:39:17 +01:00
int PreviousChannel = cDvbApi::CurrentChannel();
2001-09-01 09:04:37 +02:00
time_t LastActivity = 0;
2001-02-24 16:18:43 +01:00
int MaxLatencyTime = 0;
2001-09-01 11:44:08 +02:00
bool ForceShutdown = false;
2001-02-24 16:18:43 +01:00
if (WatchdogTimeout > 0) {
dsyslog(LOG_INFO, "setting watchdog timer to %d seconds", WatchdogTimeout);
alarm(WatchdogTimeout); // Initial watchdog timer start
}
2000-02-19 13:36:48 +01:00
while (!Interrupted) {
// Handle emergency exits:
if (cThread::EmergencyExit()) {
esyslog(LOG_ERR, "emergency exit requested - shutting down");
break;
}
2001-02-24 16:18:43 +01:00
// Restart the Watchdog timer:
if (WatchdogTimeout > 0) {
int LatencyTime = WatchdogTimeout - alarm(WatchdogTimeout);
if (LatencyTime > MaxLatencyTime) {
MaxLatencyTime = LatencyTime;
dsyslog(LOG_INFO, "max. latency time %d seconds", MaxLatencyTime);
}
}
2000-04-22 13:51:48 +02:00
// Channel display:
if (!EITScanner.Active() && cDvbApi::CurrentChannel() != LastChannel) {
2000-09-09 14:57:43 +02:00
if (!Menu)
2000-11-05 18:39:17 +01:00
Menu = new cDisplayChannel(cDvbApi::CurrentChannel(), LastChannel > 0);
if (LastChannel > 0)
PreviousChannel = LastChannel;
2000-11-05 18:39:17 +01:00
LastChannel = cDvbApi::CurrentChannel();
2000-04-22 13:51:48 +02:00
}
2000-05-01 16:29:46 +02:00
// Timers and Recordings:
if (!Menu) {
time_t Now = time(NULL); // must do both following calls with the exact same time!
cRecordControls::Process(Now);
cTimer *Timer = Timers.GetMatch(Now);
2000-04-30 10:22:13 +02:00
if (Timer) {
if (!cRecordControls::Start(Timer))
Timer->SetPending(true);
}
}
// User Input:
cOsdBase **Interact = Menu ? &Menu : (cOsdBase **)&ReplayControl;
eKeys key = Interface->GetKey(!*Interact || !(*Interact)->NeedsFastResponse());
2001-09-01 09:04:37 +02:00
if (NORMALKEY(key) != kNone) {
EITScanner.Activity();
2001-09-01 09:04:37 +02:00
LastActivity = time(NULL);
}
// 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 cMenuMain(ReplayControl, osRecordings);
break;
case osReplay: DELETENULL(Menu);
DELETENULL(ReplayControl);
ReplayControl = new cReplayControl;
break;
2001-08-06 16:19:20 +02:00
#ifdef DVDSUPPORT
case osDVD: DELETENULL(Menu);
DELETENULL(ReplayControl);
Menu = new cMenuMain(ReplayControl, osDVD);
break;
2001-08-06 16:19:20 +02:00
#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 {
// 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;
}
}
}
2000-12-28 12:57:16 +01:00
if (!Menu) {
EITScanner.Process();
if (!cVideoCutter::Active() && cVideoCutter::Ended()) {
if (cVideoCutter::Error())
Interface->Error(tr("Editing process failed!"));
else
Interface->Info(tr("Editing process finished"));
}
2000-12-28 12:57:16 +01:00
}
2001-09-01 11:44:08 +02:00
if (!*Interact && (!cRecordControls::Active() || ForceShutdown)) {
2001-09-01 09:04:37 +02:00
time_t Now = time(NULL);
if (Now - LastActivity > ACTIVITYTIMEOUT) {
// Shutdown:
if (Shutdown && (Setup.MinUserInactivity || LastActivity == 1) && Now - LastActivity > Setup.MinUserInactivity * 60) {
2001-09-01 09:04:37 +02:00
cTimer *timer = Timers.GetNextActiveTimer();
2001-09-01 11:44:08 +02:00
time_t Next = timer ? timer->StartTime() : 0;
time_t Delta = timer ? Next - Now : 0;
2001-09-07 15:37:26 +02:00
if (!LastActivity) {
if (!timer || Delta > MANUALSTART) {
2001-09-01 11:44:08 +02:00
// Apparently the user started VDR manually
dsyslog(LOG_INFO, "assuming manual start of VDR");
LastActivity = Now;
2001-09-07 15:37:26 +02:00
continue; // don't run into the actual shutdown procedure below
2001-09-01 11:44:08 +02:00
}
2001-09-07 15:37:26 +02:00
else
LastActivity = 1;
}
2001-09-08 13:02:05 +02:00
if (!Next || Delta > Setup.MinEventTimeout * 60 || ForceShutdown) {
ForceShutdown = false;
2001-09-07 15:37:26 +02:00
if (timer)
dsyslog(LOG_INFO, "next timer event at %s", ctime(&Next));
2001-09-01 11:44:08 +02:00
if (WatchdogTimeout > 0)
signal(SIGALRM, SIG_IGN);
bool UserShutdown = key == kPower;
if (Interface->Confirm(tr("Press any key to cancel shutdown"), UserShutdown ? 5 : SHUTDOWNWAIT, true)) {
int Channel = timer ? timer->channel : 0;
const char *File = timer ? timer->file : "";
2001-09-01 11:44:08 +02:00
char *cmd;
asprintf(&cmd, "%s %ld %ld %d \"%s\" %d", Shutdown, Next, Delta, Channel, strescape(File, "\"$"), UserShutdown);
2001-09-01 11:44:08 +02:00
isyslog(LOG_INFO, "executing '%s'", cmd);
SystemExec(cmd);
2001-09-01 11:44:08 +02:00
delete cmd;
}
else if (WatchdogTimeout > 0) {
alarm(WatchdogTimeout);
if (signal(SIGALRM, Watchdog) == SIG_IGN)
2001-09-01 09:04:37 +02:00
signal(SIGALRM, SIG_IGN);
}
LastActivity = time(NULL); // don't try again too soon
2001-09-01 11:44:08 +02:00
continue; // skip the rest of the housekeeping for now
2001-09-01 09:04:37 +02:00
}
}
// Disk housekeeping:
2001-02-11 14:53:44 +01:00
RemoveDeletedRecordings();
}
}
}
if (Interrupted)
isyslog(LOG_INFO, "caught signal %d", Interrupted);
Setup.CurrentChannel = cDvbApi::CurrentChannel();
Setup.CurrentVolume = cDvbApi::CurrentVolume();
Setup.Save();
2000-12-28 12:57:16 +01:00
cVideoCutter::Stop();
2000-04-30 10:22:13 +02:00
delete Menu;
delete ReplayControl;
delete Interface;
2000-05-01 16:29:46 +02:00
cDvbApi::Cleanup();
2001-02-24 16:18:43 +01:00
if (WatchdogTimeout > 0)
dsyslog(LOG_INFO, "max. latency time %d seconds", MaxLatencyTime);
2000-04-16 13:54:16 +02:00
isyslog(LOG_INFO, "exiting");
if (SysLogLevel > 0)
closelog();
if (cThread::EmergencyExit()) {
esyslog(LOG_ERR, "emergency exit!");
return 1;
}
return 0;
2000-02-19 13:36:48 +01:00
}