mirror of
https://github.com/vdr-projects/vdr.git
synced 2025-03-01 10:50:46 +00:00
VDR developer version 2.1.1 is now available at ftp://ftp.tvdr.de/vdr/Developer/vdr-2.1.1.tar.bz2 A 'diff' against the previous version is available at ftp://ftp.tvdr.de/vdr/Developer/vdr-2.0.0-2.1.1.diff MD5 checksums: b17f9838bb8ddee9620f838fea7a171d vdr-2.1.1.tar.bz2 8b8ca593885c380cd370e6d19a5b16a1 vdr-2.0.0-2.1.1.diff WARNING: ======== This is a *developer* version. Even though *I* use it in my productive environment, I strongly recommend that you only use it under controlled conditions and for testing and debugging. The main focus of this version is on adding basic support for positioners to control steerable satellite dishes. Manually controlling the dish position and storing individual positions will follow later. The fixes contained in this version will be released in a stable version 2.0.3 later, if there are no problems. From the HISTORY file: - Fixed initializing cDevice::keepTracks. - Fixed an endless loop in cTextWrapper::Set() in case the given Width is smaller than one character (reported by Stefan Braun). - Removed all "modified since version 1.6" markers from PLUGINS.html. - Added definitions for older DVB API versions, back until 5.0 (based on a patch from Udo Richter). - Changed cThread::SetIOPriority() from "best effort class" to "idle class" in order to improve overall performance when an editing process is running (thanks to Jochen Dolze). - Fixed handling '/' and '~' in recording file names in case DirectoryEncoding is used (thanks to Lars Hanisch). - Changed the sign of the satellite position value in cSource to reflect the standard of western values being negative. The new member function cSource::Position() can be used to retrieve the orbital position of a satellite. - Fixed multiple occurrences of the same directory in the recordings list in case there are directories that only differ in non-alphanumeric characters (was broken by "Fixed selecting the last replayed recording in the Recordings menu in case there are folders and plain recordings with names that differ only in non-alphanumeric characters" in version 1.7.36). - Fixed displaying the frame number when setting an editing mark (thanks to Thomas Günther). - Fixed no longer generating any editing marks if the edited recording results in just one single sequence (reported by Halim Sahin). - Fixed an error message when parsing SCR values in diseqc.conf. - Fixed an unexpected RCS version tag in the newplugin script. - Fixed an endless loop in the DrawEllipse() functions for very small ellipses (reported by Stefan Braun). - Fixed a crash in the LCARS skin's main menu in case there is no current channel (reported by Dominique Dumont). - Added basic support for positioners to control steerable satellite dishes (based on a patch from Seppo Ingalsuo and Ales Jurik). + Supports GotoN (aka "DiSEqC 1.2") and GotoX (aka "USALS"). + The new DiSEqC command code 'P' can be used to instruct a positioner to move the dish to the required satellite position. When a 'P' code is processed, further execution of the remaining DiSEqC sequence (if any) is postponed until the positioner has reached the new satellite position. + The new special source value of "S360E" can be used in diseqc.conf to indicate that an entry using a positioner can move the dish to any requested position within its range. Think of it as "full circle". + The devices a particular cDiseqc or cScr applies to are now stored directly in each cDiseqc or cScr, respectively. + A plugin can implement a custom positioner control (see PLUGINS.html, section "Positioners"). + The new function cSkinDisplayChannel::SetPositioner() can be implemented by skins to show the user a progress display when the dish is being moved. The default implementation calls SetMessage() with a string indicating the new position the dish is being moved to. The LCARS skin shows a progress bar indicating the movement of the dish. + The new parameters "Site latitude", "Site longitude", "Positioner speed", and "Positioner swing" in the "Setup/LNB" menu can be used to configure the necessary values for a steerable dish. + The cDvbTuner now has a new status tsPositioning, in which it waits until a steerable dish has reached its target position. Parsing SI data is paused until the target position has been reached. - The LCARS skin now shows the source value of the current channel in its channel display. - Fixed asserting free disk space in the cutter. - No longer trying to delete old recordings in AssertFreeDiskSpace() if the given Priority is less than 1. - Fixed handling LIRC events in case repeated events are lost. - Fixed a possible crash when shutting down VDR while subtitles are being displayed (reported by Ville Skyttä). - cDevice::IsPrimaryDevice() now also checks whether the primary device actually has a decoder and returns false otherwise. This should improve device allocation on systems that are only used as a receiver and don't actually display anything. - Increased the value of MAXRETRIES to 20 to reduce the probability of disturbances in transfer mode. - All bonded devices (except for the master) now turn off their LNB power completely to avoid problems when receiving vertically polarized transponders (suggested by Manfred Völkel and Oliver Endriss). - Reverted the change from version 1.5.7 that made all logging go to LOG_ERR (thanks to Christopher Reimer). - Added Begin/EndSegmentTransfer() to the EPG handler interface (thanks to Jörg Wendel). - The code for distributing recordings over several video directories is now deprecated and disabled by default. You can re-enable this feature by removing the comment sign ('//') from the beginning of the line //#define DEPRECATED_DISTRIBUTED_VIDEODIR // Code enclosed with this macro is ... in the file videodir.c. Note, though, that this can only be a temporary workaround. This feature will be completely removed in one of the next developer versions. Distributing the video directory over several disks was a useful feature in times when disks were still relatively small, but it also caused serious problems in case one of the disks failed. Nowadays hard disks come in sizes measured in terabytes, and tools like "mhddfs" can be used to combine several disks to form one large volume. A recommended method for a relatively safe disk setup in a VDR system is to use two 1TB (or larger) disks and use them as a RAID-1 (mirrored). That way, if one disk fails, you can replace it without data loss.
270 lines
7.2 KiB
C
270 lines
7.2 KiB
C
/*
|
|
* shutdown.c: Handling of shutdown and inactivity
|
|
*
|
|
* See the main source file 'vdr.c' for copyright information and
|
|
* how to reach the author.
|
|
*
|
|
* Original version written by Udo Richter <udo_richter@gmx.de>.
|
|
*
|
|
* $Id: shutdown.c 3.0 2013/02/18 10:33:26 kls Exp $
|
|
*/
|
|
|
|
#include "shutdown.h"
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <sys/types.h>
|
|
#include <sys/wait.h>
|
|
#include "channels.h"
|
|
#include "config.h"
|
|
#include "cutter.h"
|
|
#include "i18n.h"
|
|
#include "interface.h"
|
|
#include "menu.h"
|
|
#include "plugin.h"
|
|
#include "timers.h"
|
|
#include "tools.h"
|
|
|
|
cShutdownHandler ShutdownHandler;
|
|
|
|
cCountdown::cCountdown(void)
|
|
{
|
|
timeout = 0;
|
|
counter = 0;
|
|
timedOut = false;
|
|
message = NULL;
|
|
}
|
|
|
|
void cCountdown::Start(const char *Message, int Seconds)
|
|
{
|
|
timeout = time(NULL) + Seconds;
|
|
counter = -1;
|
|
timedOut = false;
|
|
message = Message;
|
|
Update();
|
|
}
|
|
|
|
void cCountdown::Cancel(void)
|
|
{
|
|
if (timeout) {
|
|
timeout = 0;
|
|
timedOut = false;
|
|
Skins.Message(mtStatus, NULL);
|
|
}
|
|
}
|
|
|
|
bool cCountdown::Done(void)
|
|
{
|
|
if (timedOut) {
|
|
Cancel();
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool cCountdown::Update(void)
|
|
{
|
|
if (timeout) {
|
|
int NewCounter = (timeout - time(NULL) + 9) / 10;
|
|
if (NewCounter <= 0)
|
|
timedOut = true;
|
|
if (counter != NewCounter) {
|
|
counter = NewCounter;
|
|
char time[10];
|
|
snprintf(time, sizeof(time), "%d:%d0", counter > 0 ? counter / 6 : 0, counter > 0 ? counter % 6 : 0);
|
|
cString Message = cString::sprintf(message, time);
|
|
Skins.Message(mtStatus, Message);
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
cShutdownHandler::cShutdownHandler(void)
|
|
{
|
|
activeTimeout = 0;
|
|
retry = 0;
|
|
shutdownCommand = NULL;
|
|
exitCode = -1;
|
|
emergencyExitRequested = false;
|
|
}
|
|
|
|
cShutdownHandler::~cShutdownHandler()
|
|
{
|
|
free(shutdownCommand);
|
|
}
|
|
|
|
void cShutdownHandler::RequestEmergencyExit(void)
|
|
{
|
|
if (Setup.EmergencyExit) {
|
|
esyslog("initiating emergency exit");
|
|
emergencyExitRequested = true;
|
|
Exit(1);
|
|
}
|
|
else
|
|
dsyslog("emergency exit request ignored according to setup");
|
|
}
|
|
|
|
void cShutdownHandler::CheckManualStart(int ManualStart)
|
|
{
|
|
time_t Delta = Setup.NextWakeupTime ? Setup.NextWakeupTime - time(NULL) : 0;
|
|
|
|
if (!Setup.NextWakeupTime || abs(Delta) > ManualStart) {
|
|
// Apparently the user started VDR manually
|
|
dsyslog("assuming manual start of VDR");
|
|
// Set inactive after MinUserInactivity
|
|
SetUserInactiveTimeout();
|
|
}
|
|
else {
|
|
// Set inactive from now on
|
|
dsyslog("scheduled wakeup time in %ld minutes, assuming automatic start of VDR", Delta / 60);
|
|
SetUserInactiveTimeout(-3, true);
|
|
}
|
|
}
|
|
|
|
void cShutdownHandler::SetShutdownCommand(const char *ShutdownCommand)
|
|
{
|
|
free(shutdownCommand);
|
|
shutdownCommand = ShutdownCommand ? strdup(ShutdownCommand) : NULL;
|
|
}
|
|
|
|
void cShutdownHandler::CallShutdownCommand(time_t WakeupTime, int Channel, const char *File, bool UserShutdown)
|
|
{
|
|
time_t Delta = WakeupTime ? WakeupTime - time(NULL) : 0;
|
|
cString cmd = cString::sprintf("%s %ld %ld %d \"%s\" %d", shutdownCommand, WakeupTime, Delta, Channel, *strescape(File, "\\\"$"), UserShutdown);
|
|
isyslog("executing '%s'", *cmd);
|
|
int Status = SystemExec(cmd, true);
|
|
if (!WIFEXITED(Status) || WEXITSTATUS(Status))
|
|
esyslog("SystemExec() failed with status %d", Status);
|
|
else {
|
|
Setup.NextWakeupTime = WakeupTime; // Remember this wakeup time for comparison on reboot
|
|
Setup.Save();
|
|
}
|
|
}
|
|
|
|
void cShutdownHandler::SetUserInactiveTimeout(int Seconds, bool Force)
|
|
{
|
|
if (!Setup.MinUserInactivity && !Force) {
|
|
activeTimeout = 0;
|
|
return;
|
|
}
|
|
if (Seconds >= 0)
|
|
activeTimeout = time(NULL) + Seconds;
|
|
else if (Seconds == -1)
|
|
activeTimeout = time(NULL) + Setup.MinUserInactivity * 60;
|
|
else if (Seconds == -2)
|
|
activeTimeout = 0;
|
|
else if (Seconds == -3)
|
|
activeTimeout = 1;
|
|
}
|
|
|
|
bool cShutdownHandler::ConfirmShutdown(bool Interactive)
|
|
{
|
|
if (!Interactive && !cRemote::Enabled())
|
|
return false;
|
|
|
|
if (!shutdownCommand) {
|
|
if (Interactive)
|
|
Skins.Message(mtError, tr("Can't shutdown - option '-s' not given!"));
|
|
return false;
|
|
}
|
|
if (cCutter::Active()) {
|
|
if (!Interactive || !Interface->Confirm(tr("Editing - shut down anyway?")))
|
|
return false;
|
|
}
|
|
|
|
cTimer *timer = Timers.GetNextActiveTimer();
|
|
time_t Next = timer ? timer->StartTime() : 0;
|
|
time_t Delta = timer ? Next - time(NULL) : 0;
|
|
|
|
if (cRecordControls::Active() || (Next && Delta <= 0)) {
|
|
// VPS recordings in timer end margin may cause Delta <= 0
|
|
if (!Interactive || !Interface->Confirm(tr("Recording - shut down anyway?")))
|
|
return false;
|
|
}
|
|
else if (Next && Delta <= Setup.MinEventTimeout * 60) {
|
|
// Timer within Min Event Timeout
|
|
if (!Interactive)
|
|
return false;
|
|
cString buf = cString::sprintf(tr("Recording in %ld minutes, shut down anyway?"), Delta / 60);
|
|
if (!Interface->Confirm(buf))
|
|
return false;
|
|
}
|
|
|
|
if (cPluginManager::Active(Interactive ? tr("shut down anyway?") : NULL))
|
|
return false;
|
|
|
|
cPlugin *Plugin = cPluginManager::GetNextWakeupPlugin();
|
|
Next = Plugin ? Plugin->WakeupTime() : 0;
|
|
Delta = Next ? Next - time(NULL) : 0;
|
|
if (Next && Delta <= Setup.MinEventTimeout * 60) {
|
|
// Plugin wakeup within Min Event Timeout
|
|
if (!Interactive)
|
|
return false;
|
|
cString buf = cString::sprintf(tr("Plugin %s wakes up in %ld min, continue?"), Plugin->Name(), Delta / 60);
|
|
if (!Interface->Confirm(buf))
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
bool cShutdownHandler::ConfirmRestart(bool Interactive)
|
|
{
|
|
if (cCutter::Active()) {
|
|
if (!Interactive || !Interface->Confirm(tr("Editing - restart anyway?")))
|
|
return false;
|
|
}
|
|
|
|
cTimer *timer = Timers.GetNextActiveTimer();
|
|
time_t Next = timer ? timer->StartTime() : 0;
|
|
time_t Delta = timer ? Next - time(NULL) : 0;
|
|
|
|
if (cRecordControls::Active() || (Next && Delta <= 0)) {
|
|
// VPS recordings in timer end margin may cause Delta <= 0
|
|
if (!Interactive || !Interface->Confirm(tr("Recording - restart anyway?")))
|
|
return false;
|
|
}
|
|
|
|
if (cPluginManager::Active(Interactive ? tr("restart anyway?") : NULL))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool cShutdownHandler::DoShutdown(bool Force)
|
|
{
|
|
time_t Now = time(NULL);
|
|
cTimer *timer = Timers.GetNextActiveTimer();
|
|
cPlugin *Plugin = cPluginManager::GetNextWakeupPlugin();
|
|
|
|
time_t Next = timer ? timer->StartTime() : 0;
|
|
time_t NextPlugin = Plugin ? Plugin->WakeupTime() : 0;
|
|
if (NextPlugin && (!Next || Next > NextPlugin)) {
|
|
Next = NextPlugin;
|
|
timer = NULL;
|
|
}
|
|
time_t Delta = Next ? Next - Now : 0;
|
|
|
|
if (Next && Delta < Setup.MinEventTimeout * 60) {
|
|
if (!Force)
|
|
return false;
|
|
Delta = Setup.MinEventTimeout * 60;
|
|
Next = Now + Delta;
|
|
timer = NULL;
|
|
dsyslog("reboot at %s", *TimeToString(Next));
|
|
}
|
|
|
|
if (Next && timer) {
|
|
dsyslog("next timer event at %s", *TimeToString(Next));
|
|
CallShutdownCommand(Next, timer->Channel()->Number(), timer->File(), Force);
|
|
}
|
|
else if (Next && Plugin) {
|
|
CallShutdownCommand(Next, 0, Plugin->Name(), Force);
|
|
dsyslog("next plugin wakeup at %s", *TimeToString(Next));
|
|
}
|
|
else
|
|
CallShutdownCommand(Next, 0, "", Force); // Next should always be 0 here. Just for safety, pass it.
|
|
|
|
return true;
|
|
}
|