mirror of
https://github.com/VDR4Arch/vdr.git
synced 2023-10-10 13:36:52 +02:00
Fixed timers starting and ending at unexpected times
This commit is contained in:
parent
6c41138bdd
commit
6de7f7e8b2
4
HISTORY
4
HISTORY
@ -787,7 +787,7 @@ Video Disk Recorder Revision History
|
|||||||
- Made the volume, mute and power keys work when a menu is active, too (thanks
|
- Made the volume, mute and power keys work when a menu is active, too (thanks
|
||||||
to Matthias Weingart).
|
to Matthias Weingart).
|
||||||
|
|
||||||
2001-10-07: Version 0.97
|
2001-10-19: Version 0.97
|
||||||
|
|
||||||
- Implemented a lock file to prevent more than one instance of VDR from removing
|
- Implemented a lock file to prevent more than one instance of VDR from removing
|
||||||
files from the video directory at the same time.
|
files from the video directory at the same time.
|
||||||
@ -817,3 +817,5 @@ Video Disk Recorder Revision History
|
|||||||
(where these are assumed to be single line texts) and would have to be
|
(where these are assumed to be single line texts) and would have to be
|
||||||
specially handled in the 'epg.data' file and the LSTE command in SVDRP.
|
specially handled in the 'epg.data' file and the LSTE command in SVDRP.
|
||||||
- Mapping ` ("backtick") characters in EPG texts to ' (single quote).
|
- Mapping ` ("backtick") characters in EPG texts to ' (single quote).
|
||||||
|
- Fixed timers starting and ending at unexpected times. 'localtime()' was not
|
||||||
|
thread safe, now using localtime_r().
|
||||||
|
22
config.c
22
config.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: config.c 1.74 2001/09/30 11:28:47 kls Exp $
|
* $Id: config.c 1.75 2001/10/19 13:14:09 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
@ -324,7 +324,8 @@ cTimer::cTimer(bool Instant)
|
|||||||
cChannel *ch = Channels.GetByNumber(cDvbApi::CurrentChannel());
|
cChannel *ch = Channels.GetByNumber(cDvbApi::CurrentChannel());
|
||||||
channel = ch ? ch->number : 0;
|
channel = ch ? ch->number : 0;
|
||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
struct tm *now = localtime(&t);
|
struct tm tm_r;
|
||||||
|
struct tm *now = localtime_r(&t, &tm_r);
|
||||||
day = now->tm_mday;
|
day = now->tm_mday;
|
||||||
start = now->tm_hour * 100 + now->tm_min;
|
start = now->tm_hour * 100 + now->tm_min;
|
||||||
stop = start + 200; // "instant recording" records 2 hours by default
|
stop = start + 200; // "instant recording" records 2 hours by default
|
||||||
@ -349,10 +350,11 @@ cTimer::cTimer(const cEventInfo *EventInfo)
|
|||||||
time_t tstart = EventInfo->GetTime();
|
time_t tstart = EventInfo->GetTime();
|
||||||
time_t tstop = tstart + EventInfo->GetDuration() + Setup.MarginStop * 60;
|
time_t tstop = tstart + EventInfo->GetDuration() + Setup.MarginStop * 60;
|
||||||
tstart -= Setup.MarginStart * 60;
|
tstart -= Setup.MarginStart * 60;
|
||||||
struct tm *time = localtime(&tstart);
|
struct tm tm_r;
|
||||||
|
struct tm *time = localtime_r(&tstart, &tm_r);
|
||||||
day = time->tm_mday;
|
day = time->tm_mday;
|
||||||
start = time->tm_hour * 100 + time->tm_min;
|
start = time->tm_hour * 100 + time->tm_min;
|
||||||
time = localtime(&tstop);
|
time = localtime_r(&tstop, &tm_r);
|
||||||
stop = time->tm_hour * 100 + time->tm_min;
|
stop = time->tm_hour * 100 + time->tm_min;
|
||||||
if (stop >= 2400)
|
if (stop >= 2400)
|
||||||
stop -= 2400;
|
stop -= 2400;
|
||||||
@ -497,12 +499,14 @@ bool cTimer::IsSingleEvent(void)
|
|||||||
|
|
||||||
int cTimer::GetMDay(time_t t)
|
int cTimer::GetMDay(time_t t)
|
||||||
{
|
{
|
||||||
return localtime(&t)->tm_mday;
|
struct tm tm_r;
|
||||||
|
return localtime_r(&t, &tm_r)->tm_mday;
|
||||||
}
|
}
|
||||||
|
|
||||||
int cTimer::GetWDay(time_t t)
|
int cTimer::GetWDay(time_t t)
|
||||||
{
|
{
|
||||||
int weekday = localtime(&t)->tm_wday;
|
struct tm tm_r;
|
||||||
|
int weekday = localtime_r(&t, &tm_r)->tm_wday;
|
||||||
return weekday == 0 ? 6 : weekday - 1; // we start with monday==0!
|
return weekday == 0 ? 6 : weekday - 1; // we start with monday==0!
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -513,7 +517,8 @@ bool cTimer::DayMatches(time_t t)
|
|||||||
|
|
||||||
time_t cTimer::IncDay(time_t t, int Days)
|
time_t cTimer::IncDay(time_t t, int Days)
|
||||||
{
|
{
|
||||||
tm tm = *localtime(&t);
|
struct tm tm_r;
|
||||||
|
tm tm = *localtime_r(&t, &tm_r);
|
||||||
tm.tm_mday += Days; // now tm_mday may be out of its valid range
|
tm.tm_mday += Days; // now tm_mday may be out of its valid range
|
||||||
int h = tm.tm_hour; // save original hour to compensate for DST change
|
int h = tm.tm_hour; // save original hour to compensate for DST change
|
||||||
t = mktime(&tm); // normalize all values
|
t = mktime(&tm); // normalize all values
|
||||||
@ -523,7 +528,8 @@ time_t cTimer::IncDay(time_t t, int Days)
|
|||||||
|
|
||||||
time_t cTimer::SetTime(time_t t, int SecondsFromMidnight)
|
time_t cTimer::SetTime(time_t t, int SecondsFromMidnight)
|
||||||
{
|
{
|
||||||
tm tm = *localtime(&t);
|
struct tm tm_r;
|
||||||
|
tm tm = *localtime_r(&t, &tm_r);
|
||||||
tm.tm_hour = SecondsFromMidnight / 3600;
|
tm.tm_hour = SecondsFromMidnight / 3600;
|
||||||
tm.tm_min = (SecondsFromMidnight % 3600) / 60;
|
tm.tm_min = (SecondsFromMidnight % 3600) / 60;
|
||||||
tm.tm_sec = SecondsFromMidnight % 60;
|
tm.tm_sec = SecondsFromMidnight % 60;
|
||||||
|
20
eit.c
20
eit.c
@ -16,7 +16,7 @@
|
|||||||
* the Free Software Foundation; either version 2 of the License, or *
|
* the Free Software Foundation; either version 2 of the License, or *
|
||||||
* (at your option) any later version. *
|
* (at your option) any later version. *
|
||||||
* *
|
* *
|
||||||
* $Id: eit.c 1.27 2001/10/07 14:35:25 kls Exp $
|
* $Id: eit.c 1.28 2001/10/19 13:13:25 kls Exp $
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
|
||||||
#include "eit.h"
|
#include "eit.h"
|
||||||
@ -126,7 +126,8 @@ bool cMJD::SetSystemTime()
|
|||||||
struct tm *ptm;
|
struct tm *ptm;
|
||||||
time_t loctim;
|
time_t loctim;
|
||||||
|
|
||||||
ptm = localtime(&mjdtime);
|
struct tm tm_r;
|
||||||
|
ptm = localtime_r(&mjdtime, &tm_r);
|
||||||
loctim = time(NULL);
|
loctim = time(NULL);
|
||||||
|
|
||||||
if (abs(mjdtime - loctim) > 2)
|
if (abs(mjdtime - loctim) > 2)
|
||||||
@ -240,7 +241,8 @@ const char * cEventInfo::GetDate() const
|
|||||||
{
|
{
|
||||||
static char szDate[25];
|
static char szDate[25];
|
||||||
|
|
||||||
strftime(szDate, sizeof(szDate), "%d.%m.%Y", localtime(&tTime));
|
struct tm tm_r;
|
||||||
|
strftime(szDate, sizeof(szDate), "%d.%m.%Y", localtime_r(&tTime, &tm_r));
|
||||||
|
|
||||||
return szDate;
|
return szDate;
|
||||||
}
|
}
|
||||||
@ -249,7 +251,8 @@ const char * cEventInfo::GetTimeString() const
|
|||||||
{
|
{
|
||||||
static char szTime[25];
|
static char szTime[25];
|
||||||
|
|
||||||
strftime(szTime, sizeof(szTime), "%R", localtime(&tTime));
|
struct tm tm_r;
|
||||||
|
strftime(szTime, sizeof(szTime), "%R", localtime_r(&tTime, &tm_r));
|
||||||
|
|
||||||
return szTime;
|
return szTime;
|
||||||
}
|
}
|
||||||
@ -259,7 +262,8 @@ const char * cEventInfo::GetEndTimeString() const
|
|||||||
static char szEndTime[25];
|
static char szEndTime[25];
|
||||||
time_t tEndTime = tTime + lDuration;
|
time_t tEndTime = tTime + lDuration;
|
||||||
|
|
||||||
strftime(szEndTime, sizeof(szEndTime), "%R", localtime(&tEndTime));
|
struct tm tm_r;
|
||||||
|
strftime(szEndTime, sizeof(szEndTime), "%R", localtime_r(&tEndTime, &tm_r));
|
||||||
|
|
||||||
return szEndTime;
|
return szEndTime;
|
||||||
}
|
}
|
||||||
@ -467,7 +471,8 @@ void cEventInfo::FixEpgBugs(void)
|
|||||||
// correctly on the ASTRA satellite system.
|
// correctly on the ASTRA satellite system.
|
||||||
if (uServiceID == 898 // Pro-7
|
if (uServiceID == 898 // Pro-7
|
||||||
|| uServiceID == 899) { // Kabel 1
|
|| uServiceID == 899) { // Kabel 1
|
||||||
tm *t = localtime(&tTime);
|
struct tm tm_r;
|
||||||
|
tm *t = localtime_r(&tTime, &tm_r);
|
||||||
if (t->tm_hour * 3600 + t->tm_min * 60 + t->tm_sec <= 6 * 3600)
|
if (t->tm_hour * 3600 + t->tm_min * 60 + t->tm_sec <= 6 * 3600)
|
||||||
tTime += 24 * 3600;
|
tTime += 24 * 3600;
|
||||||
}
|
}
|
||||||
@ -886,7 +891,8 @@ void cSIProcessor::Action()
|
|||||||
if (masterSIProcessor)
|
if (masterSIProcessor)
|
||||||
{
|
{
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm *ptm = localtime(&now);
|
struct tm tm_r;
|
||||||
|
struct tm *ptm = localtime_r(&now, &tm_r);
|
||||||
if (now - lastCleanup > 3600 && ptm->tm_hour == 5)
|
if (now - lastCleanup > 3600 && ptm->tm_hour == 5)
|
||||||
{
|
{
|
||||||
LOCK_THREAD;
|
LOCK_THREAD;
|
||||||
|
11
recording.c
11
recording.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: recording.c 1.40 2001/10/07 15:13:34 kls Exp $
|
* $Id: recording.c 1.41 2001/10/19 13:12:17 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "recording.h"
|
#include "recording.h"
|
||||||
@ -252,7 +252,8 @@ cRecording::cRecording(const char *FileName)
|
|||||||
summary = NULL;
|
summary = NULL;
|
||||||
if (p) {
|
if (p) {
|
||||||
time_t now = time(NULL);
|
time_t now = time(NULL);
|
||||||
struct tm t = *localtime(&now); // this initializes the time zone in 't'
|
struct tm tm_r;
|
||||||
|
struct tm t = *localtime_r(&now, &tm_r); // this initializes the time zone in 't'
|
||||||
t.tm_isdst = -1; // makes sure mktime() will determine the correct dst setting
|
t.tm_isdst = -1; // makes sure mktime() will determine the correct dst setting
|
||||||
if (7 == sscanf(p + 1, DATAFORMAT, &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &priority, &lifetime)) {
|
if (7 == sscanf(p + 1, DATAFORMAT, &t.tm_year, &t.tm_mon, &t.tm_mday, &t.tm_hour, &t.tm_min, &priority, &lifetime)) {
|
||||||
t.tm_year -= 1900;
|
t.tm_year -= 1900;
|
||||||
@ -350,7 +351,8 @@ bool cRecording::operator< (const cListObject &ListObject)
|
|||||||
const char *cRecording::FileName(void)
|
const char *cRecording::FileName(void)
|
||||||
{
|
{
|
||||||
if (!fileName) {
|
if (!fileName) {
|
||||||
struct tm *t = localtime(&start);
|
struct tm tm_r;
|
||||||
|
struct tm *t = localtime_r(&start, &tm_r);
|
||||||
ExchangeChars(name, true);
|
ExchangeChars(name, true);
|
||||||
asprintf(&fileName, NAMEFORMAT, VideoDirectory, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime);
|
asprintf(&fileName, NAMEFORMAT, VideoDirectory, name, t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, priority, lifetime);
|
||||||
ExchangeChars(name, false);
|
ExchangeChars(name, false);
|
||||||
@ -368,7 +370,8 @@ const char *cRecording::Title(char Delimiter, bool NewIndicator)
|
|||||||
}
|
}
|
||||||
delete titleBuffer;
|
delete titleBuffer;
|
||||||
titleBuffer = NULL;
|
titleBuffer = NULL;
|
||||||
struct tm *t = localtime(&start);
|
struct tm tm_r;
|
||||||
|
struct tm *t = localtime_r(&start, &tm_r);
|
||||||
asprintf(&titleBuffer, "%02d.%02d%c%02d:%02d%c%c%s",
|
asprintf(&titleBuffer, "%02d.%02d%c%02d:%02d%c%c%s",
|
||||||
t->tm_mday,
|
t->tm_mday,
|
||||||
t->tm_mon + 1,
|
t->tm_mon + 1,
|
||||||
|
5
tools.c
5
tools.c
@ -4,7 +4,7 @@
|
|||||||
* See the main source file 'vdr.c' for copyright information and
|
* See the main source file 'vdr.c' for copyright information and
|
||||||
* how to reach the author.
|
* how to reach the author.
|
||||||
*
|
*
|
||||||
* $Id: tools.c 1.49 2001/10/07 15:13:45 kls Exp $
|
* $Id: tools.c 1.50 2001/10/19 13:12:45 kls Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "tools.h"
|
#include "tools.h"
|
||||||
@ -416,7 +416,8 @@ const char *DayDateTime(time_t t)
|
|||||||
static char buffer[32];
|
static char buffer[32];
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
time(&t);
|
time(&t);
|
||||||
tm *tm = localtime(&t);
|
struct tm tm_r;
|
||||||
|
tm *tm = localtime_r(&t, &tm_r);
|
||||||
int weekday = tm->tm_wday == 0 ? 6 : tm->tm_wday - 1; // we start with monday==0!
|
int weekday = tm->tm_wday == 0 ? 6 : tm->tm_wday - 1; // we start with monday==0!
|
||||||
const char *day = tr("MonTueWedThuFriSatSun");
|
const char *day = tr("MonTueWedThuFriSatSun");
|
||||||
day += weekday * 3;
|
day += weekday * 3;
|
||||||
|
Loading…
Reference in New Issue
Block a user