Skip to content

Commit

Permalink
[vdr] Add backported changes for VDR 2.6.4
Browse files Browse the repository at this point in the history
  • Loading branch information
bittor7x0 committed Jan 28, 2024
1 parent 9b84e12 commit 8d88a14
Show file tree
Hide file tree
Showing 15 changed files with 74 additions and 37 deletions.
2 changes: 1 addition & 1 deletion vdr-m7x0/CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ Hardy Flor <HFlor@web.de>
Harald Milz <hm@seneca.muc.de>
for his CUTR patch, which was used as a base to implement the SVDRP command EDIT

Marko M�kel� <marko.makela@hut.fi>
Marko M�kel� <marko.makela@iki.fi>
for making repeat keys be ignored when waiting for a keypress to cancel an operation
for reporting that a menu was automatically closed when a replay ends
for suggesting to ignore k_Repeat when deciding whether the same key has been
Expand Down
19 changes: 17 additions & 2 deletions vdr-m7x0/README.backports
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
Speed-ups from VDR-Extensions-Patch-72 for VDR 1.7.7 (http://www.zulu-entertainment.de).

VDR 2.6.1 backports applied in this patch:
VDR 2.6.4 backports applied in this patch:
* Fixed unnecessary interruption of ongoing recordings if timers avoided the transfer
mode receiver device (thanks to Markus Ehrnsperger).
* Added a note to vdr.5 about event ids possibly changing when an event moves from
one table to another.
* Added a note to epg.h about not messing with event ids (suggested by Winfried K�hler).
* Fixed restoring the volume at program start (thanks to Matthias Senzel).
* Added periodic calls to malloc_trim(0) to reduce memory consumption (thanks to
Onur Sent�rk).
* Added missing rounding when dividing frequencies in processing the NIT (thanks to
Winfried K�hler).
* Now avoiding calling poll() in cSectionHandler::Action() if there are no filters
(reported by Marko M�kel�).
* Now assuming the lock when removing deleted recordings even if the disk is full
(reported by Claus Muus).
* Fixed printing/scanning values for systems where %ld doesn't work for time_t.
* Now using a separate fixed value for internal EPG linger time. This fixes problems with
spawned timers jumping to the next event in case Setup.EPGLinger is very small. (reported
by J�rgen Schneider).
Expand All @@ -17,7 +32,7 @@ VDR 2.6.1 backports applied in this patch:
(thanks to Peter Bieringer).
* Fixed strreplace() to handle NULL strings (reported by J�rgen Schneider).
* Replaced strncpy() with memcpy() in strreplace() to avoid a compiler warning
(reported by Marco M�kel�).
(reported by Marko M�kel�).
* Removed 'register' from libsi/util.c to avoid a warning with ISO-C++17.
* Removed the macros __STL_CONFIG_H, _STL_ALGOBASE_H and _MOVE_H from tools.h. If your
plugin insists in using "using namespace std;" you can still define
Expand Down
4 changes: 2 additions & 2 deletions vdr-m7x0/device.c
Original file line number Diff line number Diff line change
Expand Up @@ -407,9 +407,9 @@ cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsDe
uint imp = 0;
imp <<= 1; imp |= !device[i]->Receiving() || ndr; // use receiving devices if we don't need to detach existing receivers
imp <<= 1; imp |= device[i]->Receiving(); // avoid devices that are receiving
imp <<= 8; imp |= constrain(device[i]->Priority() + MAXPRIORITY, 0, 0xFF);// use the device with the lowest priority (+MAXPRIORITY to assure that values -99..99 can be used)
imp <<= 1; imp |= device[i] == cTransferControl::ReceiverDevice(); // avoid the Transfer Mode receiver device
imp <<= 8; imp |= constrain(device[i]->Priority() + MAXPRIORITY, 0, 0xFF); // use the device with the lowest priority (+MAXPRIORITY to assure that values -99..99 can be used)
imp <<= 8; imp |= constrain(device[i]->ProvidesCa(Channel), 0, 0xFF); // use the device that provides the lowest number of conditional access methods
imp <<= 8; imp |= constrain(device[i]->ProvidesCa(Channel), 0, 0xFF); // use the device that provides the lowest number of conditional access methods
imp <<= 1; imp |= ndr; // avoid detach receivers
imp <<= 1; imp |= cTShiftControl::Impact(device[i],ndr); // avoid last TShift device
imp <<= 1; imp |= device[i]->IsPrimaryDevice(); // avoid the primary device
Expand Down
4 changes: 2 additions & 2 deletions vdr-m7x0/eit.c
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ cTDT::cTDT(const u_char *Data)
timespec ts = { 0 };
ts.tv_sec = dvbtim;
if (clock_settime(CLOCK_REALTIME, &ts) == 0)
isyslog("system time changed from %s (%ld) to %s (%ld)", *TimeToString(loctim), loctim, *TimeToString(dvbtim), dvbtim);
isyslog("system time changed from %s (%jd) to %s (%jd)", *TimeToString(loctim), intmax_t(loctim), *TimeToString(dvbtim), intmax_t(dvbtim));
else {
char __errorstr[256];
strerror_r(errno,__errorstr,256);
Expand All @@ -399,7 +399,7 @@ cTDT::cTDT(const u_char *Data)
delta.tv_sec = diff;
delta.tv_usec = 0;
if (adjtime(&delta, NULL) == 0)
isyslog("system time adjustment initiated from %s (%ld) to %s (%ld)", *TimeToString(loctim), loctim, *TimeToString(dvbtim), dvbtim);
isyslog("system time adjustment initiated from %s (%jd) to %s (%jd)", *TimeToString(loctim), intmax_t(loctim), *TimeToString(dvbtim), intmax_t(dvbtim));
else {
char __errorstr[256];
strerror_r(errno,__errorstr,256);
Expand Down
10 changes: 5 additions & 5 deletions vdr-m7x0/epg.c
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ cString cEvent::GetVpsString(void) const
void cEvent::Dump(FILE *f, const char *Prefix, bool InfoOnly) const
{
if (InfoOnly || startTime + duration + EPG_LINGER_TIME >= time(NULL)) {
fprintf(f, "%sE %u %ld %d %X %X\n", Prefix, eventID, startTime, duration, tableID, version);
fprintf(f, "%sE %u %jd %d %X %X\n", Prefix, eventID, intmax_t(startTime), duration, tableID, version);
if (!isempty(title))
fprintf(f, "%sT %s\n", Prefix, title);
if (!isempty(shortText))
Expand All @@ -469,7 +469,7 @@ void cEvent::Dump(FILE *f, const char *Prefix, bool InfoOnly) const
}
}
if (vps)
fprintf(f, "%sV %ld\n", Prefix, vps);
fprintf(f, "%sV %jd\n", Prefix, intmax_t(vps));
if (!InfoOnly)
fprintf(f, "%se\n", Prefix);
}
Expand Down Expand Up @@ -506,7 +506,7 @@ bool cEvent::Parse(char *s)
components = new cComponents;
components->SetComponent(components->NumComponents(), t);
break;
case 'V': SetVps(atoi(t));
case 'V': SetVps(atol(t));
break;
default: esyslog("ERROR: unexpected tag while reading EPG data: %s", s);
return false;
Expand All @@ -527,11 +527,11 @@ bool cEvent::Read(FILE *f, cSchedule *Schedule, int &Line)
switch (*s) {
case 'E': if (!Event) {
unsigned int EventID;
time_t StartTime;
intmax_t StartTime; // actually time_t, but intmax_t for scanning with "%jd"
int Duration;
unsigned int TableID = 0;
unsigned int Version = 0xFF; // actual value is ignored
int n = sscanf(t, "%u %ld %d %X %X", &EventID, &StartTime, &Duration, &TableID, &Version);
int n = sscanf(t, "%u %jd %d %X %X", &EventID, &StartTime, &Duration, &TableID, &Version);
if (n >= 3 && n <= 5) {
Event = (cEvent *)Schedule->GetEvent(EventID, StartTime);
bool deleted = StartTime + Duration +
Expand Down
3 changes: 2 additions & 1 deletion vdr-m7x0/epg.h
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ class cEpgHandler : public cListObject {
///< therefore the EPG handlers have to take care of this. Otherwise the parsing of
///< non-updates will waste a lot of resources.
virtual bool SetEventID(cEvent *Event, tEventID EventID) { return false; }
///< Important note: if you want VPS to work, do not mess with the event ids!
virtual bool SetTitle(cEvent *Event, const char *Title) { return false; }
virtual bool SetShortText(cEvent *Event, const char *ShortText) { return false; }
virtual bool SetDescription(cEvent *Event, const char *Description) { return false; }
Expand All @@ -299,7 +300,7 @@ class cEpgHandler : public cListObject {
///< Designed to give handlers the possibility to prepare a database transaction.
///< If any EPG handler returns false in this function, it is assumed that
///< the EPG for the given Channel has to be handled later due to some transaction problems,
///> therefore the processing will aborted.
///> therefore the processing will be aborted.
///< Dummy is for backward compatibility and may be removed in a future version.
virtual bool EndSegmentTransfer(bool Modified, bool Dummy) { return false; } // TODO remove obsolete Dummy
///< Called after the segment data has been processed.
Expand Down
14 changes: 7 additions & 7 deletions vdr-m7x0/i18n.c
Original file line number Diff line number Diff line change
Expand Up @@ -1482,17 +1482,17 @@ const tI18nPhrase Phrases[] = {
"",
"",
},
{ "Recording in %ld minutes, shut down anyway?",
"Aufnahme in %ld Minuten - trotzdem ausschalten?",
{ "Recording in %jd minutes, shut down anyway?",
"Aufnahme in %jd Minuten - trotzdem ausschalten?",
"",
"",
"",
"",
"Enregistrement dans %ld minutes - confirmez l'arrêt",
"Enregistrement dans %jd minutes - confirmez l'arrêt",
"",
"",
"",
"Grabación dentro de %ld minutos, ¿apagar realmente?",
"Grabación dentro de %jd minutos, ¿apagar realmente?",
"",
"",
"",
Expand Down Expand Up @@ -1636,8 +1636,8 @@ const tI18nPhrase Phrases[] = {
"",
"",
},
{ "Plugin %s wakes up in %ld min, continue?",
"Plugin %s wacht in %ld Min auf, weiter?",
{ "Plugin %s wakes up in %jd min, continue?",
"Plugin %s wacht in %jd Min auf, weiter?",
"",
"",
"",
Expand All @@ -1646,7 +1646,7 @@ const tI18nPhrase Phrases[] = {
"",
"",
"",
"El plugin %s iniciará en %ld min, ¿continuar?",
"El plugin %s iniciará en %jd min, ¿continuar?",
"",
"",
"",
Expand Down
8 changes: 4 additions & 4 deletions vdr-m7x0/nit.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,8 @@ void cNitFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
for (SI::Loop::Iterator it3; fld->frequencies.hasNext(it3); ) {
int f = fld->frequencies.getNext(it3);
switch (ct) {
case 1: f = BCD2INT(f) / 100; break;
case 2: f = BCD2INT(f) / 10; break;
case 1: f = round(BCD2INT(f) / 100.0); break;
case 2: f = round(BCD2INT(f) / 10.0); break;
case 3: f = f * 10; break;
default: ;
}
Expand All @@ -127,7 +127,7 @@ void cNitFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
case SI::SatelliteDeliverySystemDescriptorTag: {
SI::SatelliteDeliverySystemDescriptor *sd = (SI::SatelliteDeliverySystemDescriptor *)d;
int Source = cSource::FromData(cSource::stSat, BCD2INT(sd->getOrbitalPosition()), sd->getWestEastFlag());
int Frequency = Frequencies[0] = BCD2INT(sd->getFrequency()) / 100;
int Frequency = Frequencies[0] = round(BCD2INT(sd->getFrequency()) / 100.0);
static char Polarizations[] = { 'h', 'v', 'l', 'r' };
char Polarization = Polarizations[sd->getPolarization()];
static int CodeRates[] = { FEC_NONE, FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_NONE };
Expand Down Expand Up @@ -176,7 +176,7 @@ void cNitFilter::Process(u_short Pid, u_char Tid, const u_char *Data, int Length
case SI::CableDeliverySystemDescriptorTag: {
SI::CableDeliverySystemDescriptor *sd = (SI::CableDeliverySystemDescriptor *)d;
int Source = cSource::FromData(cSource::stCable);
int Frequency = Frequencies[0] = BCD2INT(sd->getFrequency()) / 10;
int Frequency = Frequencies[0] = round(BCD2INT(sd->getFrequency()) / 10.0);
//XXX FEC_outer???
static int CodeRates[] = { FEC_NONE, FEC_1_2, FEC_2_3, FEC_3_4, FEC_5_6, FEC_7_8, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_AUTO, FEC_NONE };
int CodeRate = CodeRates[sd->getFecInner()];
Expand Down
4 changes: 2 additions & 2 deletions vdr-m7x0/recording.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,11 +430,11 @@ bool cRecordingInfo::Read(FILE *f)
break;
case 'E': {
unsigned int EventID;
time_t StartTime;
intmax_t StartTime; // actually time_t, but intmax_t for scanning with "%jd"
int Duration;
unsigned int TableID = 0;
unsigned int Version = 0xFF;
int n = sscanf(t, "%u %ld %d %X %X", &EventID, &StartTime, &Duration, &TableID, &Version);
int n = sscanf(t, "%u %jd %d %X %X", &EventID, &StartTime, &Duration, &TableID, &Version);
if (n >= 3 && n <= 5) {
ownEvent->SetEventID(EventID);
ownEvent->SetStartTime(StartTime);
Expand Down
5 changes: 5 additions & 0 deletions vdr-m7x0/sections.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,11 @@ void cSectionHandler::Action(void)
startFilters = false;
}
int NumFilters = filterHandles.Count();
if (NumFilters == 0) {
Unlock();
cCondWait::SleepMs(100);
continue;
}
pollfd pfd[NumFilters];
for (cFilterHandle *fh = filterHandles.First(); fh; fh = filterHandles.Next(fh)) {
int i = fh->Index();
Expand Down
6 changes: 3 additions & 3 deletions vdr-m7x0/shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ void cShutdownHandler::SetShutdownCommand(const char *ShutdownCommand)
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);
cString cmd = cString::sprintf("%s %jd %jd %d \"%s\" %d", shutdownCommand, intmax_t(WakeupTime), intmax_t(Delta), Channel, *strescape(File, "\\\"$"), UserShutdown);
isyslog("executing '%s'", *cmd);
int Status = SystemExec(cmd, true);
if (!WIFEXITED(Status) || WEXITSTATUS(Status))
Expand Down Expand Up @@ -217,7 +217,7 @@ bool cShutdownHandler::ConfirmShutdown(bool Interactive)
if (!Interactive)
return false;
/*
cString buf = cString::sprintf(tr("Recording in %ld minutes, shut down anyway?"), Delta / 60);
cString buf = cString::sprintf(tr("Recording in %jd minutes, shut down anyway?"), intmax_t(Delta / 60));
if (!Interface->Confirm(buf))
return false;
*/
Expand All @@ -238,7 +238,7 @@ bool cShutdownHandler::ConfirmShutdown(bool Interactive)
}
return false;
}
//cString buf = cString::sprintf(tr("Plugin %s wakes up in %ld min, continue?"), Plugin->Name(), Delta / 60);
//cString buf = cString::sprintf(tr("Plugin %s wakes up in %jd min, continue?"), Plugin->Name(), intmax_t(Delta / 60));
//if (!Interface->Confirm(buf))
// return false;
}
Expand Down
4 changes: 2 additions & 2 deletions vdr-m7x0/svdrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1497,9 +1497,9 @@ void cSVDRP::CmdNEXT(const char *Option)
if (!*Option)
Reply(250, "%d %s", Number, *TimeToString(Start));
else if (strcasecmp(Option, "ABS") == 0)
Reply(250, "%d %ld", Number, Start);
Reply(250, "%d %jd", Number, intmax_t(Start));
else if (strcasecmp(Option, "REL") == 0)
Reply(250, "%d %ld", Number, Start - time(NULL));
Reply(250, "%d %jd", Number, intmax_t(Start - time(NULL)));
else
Reply(501, "Unknown option: \"%s\"", Option);
}
Expand Down
10 changes: 7 additions & 3 deletions vdr-m7x0/tools.c
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ time_t LastModifiedTime(const char *FileName)
{
LastUpdateFileTime=0;
FirstUpdateFileTime=time(NULL);
isyslog("VideoDirectory detected %s %ld file(%ld)",FileName,FirstUpdateFileTime,fs.st_mtime);
isyslog("VideoDirectory detected %s %jd file(%jd)",FileName,intmax_t(FirstUpdateFileTime),intmax_t(fs.st_mtime));
}
if(FirstUpdateFileTime>fs.st_mtime)
return FirstUpdateFileTime;
Expand All @@ -620,15 +620,15 @@ time_t LastModifiedTime(const char *FileName)
{
LastUpdateFileTime=0;
FirstUpdateFileTime=time(NULL);
isyslog("VideoDirectory detected %s %ld",FileName,FirstUpdateFileTime);
isyslog("VideoDirectory detected %s %jd",FileName,intmax_t(FirstUpdateFileTime));
}
return FirstUpdateFileTime;
}
if((!LastUpdateFileTime)&&(FirstUpdateFileTime))
{
FirstUpdateFileTime=0;
LastUpdateFileTime=time(NULL);
isyslog("VideoDirectory lost %s %ld",FileName,LastUpdateFileTime);
isyslog("VideoDirectory lost %s %jd",FileName,intmax_t(LastUpdateFileTime));
}
return LastUpdateFileTime;
}
Expand Down Expand Up @@ -1588,6 +1588,10 @@ bool cLockFile::Lock(int WaitSeconds)
}
else {
LOG_ERROR_STR(fileName);
if (errno == ENOSPC) {
esyslog("ERROR: can't create lock file '%s' - assuming lock anyway!", fileName);
return true;
}
break;
}
if (WaitSeconds)
Expand Down
4 changes: 3 additions & 1 deletion vdr-m7x0/vdr.5
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ tab (@);
l l.
<channel id> @is the "channel ID", made up from the parameters defined in 'channels.conf'
<channel name> @is the "name" as in 'channels.conf' (for information only, may be left out)
<event id> @is a 32 bit unsigned int, uniquely identifying this event
<event id> @is a 32 bit unsigned int, uniquely identifying this event (see note)
<start time> @is the time (as a time_t integer) in UTC when this event starts
<duration> @is the time (in seconds) that this event will take
<table id> @is a hex number that indicates the table this event is contained in (if this is left empty or 0 this event will not be overwritten or modified by data that comes from the DVB stream)
Expand All @@ -712,6 +712,8 @@ Note that the \fBevent id\fR that comes from the DVB data stream is actually
just 16 bit wide. The internal representation in VDR allows for 32 bit to
be used, so that external tools can generate EPG data that is guaranteed
not to collide with the ids of existing data.
Also note that some broadcasters change the \fBevent id\fR when an event is moved
from one table to another.
.SH SEE ALSO
.BR vdr (1)
.SH AUTHOR
Expand Down
14 changes: 12 additions & 2 deletions vdr-m7x0/vdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
#include <getopt.h>
#include <grp.h>
#include <locale.h>
#include <malloc.h>
#include <pwd.h>
#include <signal.h>
#include <stdlib.h>
Expand Down Expand Up @@ -102,6 +103,7 @@

#define MINCHANNELWAIT 10 // seconds to wait between failed channel switchings
#define ACTIVITYTIMEOUT 60 // seconds before starting housekeeping
#define MEMCLEANUPDELTA 3600 // seconds between memory cleanups
#define SHUTDOWNWAIT 300 // seconds to wait in user prompt before automatic shutdown
#define SHUTDOWNRETRY 360 // seconds before trying again to shut down
#define SHUTDOWNFORCEPROMPT 5 // seconds to wait in user prompt to allow forcing shutdown
Expand Down Expand Up @@ -854,10 +856,12 @@ int main(int argc, char *argv[])
if (Setup.InitialVolume >= 0)
Setup.CurrentVolume = Setup.InitialVolume;
Channels.SwitchTo(Setup.CurrentChannel);

// Restore volume:

cDevice::PrimaryDevice()->SetVolume(Setup.CurrentVolume, true);
if (MuteAudio)
cDevice::PrimaryDevice()->ToggleMute();
else
cDevice::PrimaryDevice()->SetVolume(Setup.CurrentVolume, true);

// Signal handlers:

Expand Down Expand Up @@ -1522,6 +1526,12 @@ int main(int argc, char *argv[])
cSchedules::Cleanup();
// Plugins housekeeping:
PluginManager.Housekeeping();
// Memory cleanup:
static time_t LastMemoryCleanup = 0;
if ((Now - LastMemoryCleanup) > MEMCLEANUPDELTA) {
malloc_trim(0);
LastMemoryCleanup = Now;
}
}

// Main thread hooks of plugins:
Expand Down

0 comments on commit 8d88a14

Please sign in to comment.