Direct access to several class members is now deprecated

This commit is contained in:
Klaus Schmidinger 2011-08-21 11:34:30 +02:00
parent e5d2240bbb
commit 97ad2fa95d
9 changed files with 63 additions and 40 deletions

View File

@ -6699,7 +6699,7 @@ Video Disk Recorder Revision History
constructor is negative (avoids the "cTimeMs: using monotonic clock..." log message
before VDR's starting log message).
2011-08-20: Version 1.7.21
2011-08-21: Version 1.7.21
- Fixed detecting frames for channels that split frames into several payloads
(reported by Derek Kelly).
@ -6708,3 +6708,10 @@ Video Disk Recorder Revision History
- The start time of an edited recording is now set to the time of the first
editing mark (thanks to Udo Richter).
This obsoletes the CUTTIME patch.
- Direct access to the members start, priority, lifetime, and deleted of cRecording
as well as to position and comment of cMark is now deprecated. Plugin authors
should switch to the new access functions for these members. For now the macro
__RECORDING_H_DEPRECATED_DIRECT_MEMBER_ACCESS is defined in recording.h, which
exposes these members, so that existing plugins will still compile. Comment out
this #define to check whether a particular plugin needs to be modified.
This #define may be removed in a future version.

View File

@ -3,7 +3,7 @@
*
* See the README file for copyright information and how to reach the author.
*
* $Id: skincurses.c 2.6 2011/05/15 21:41:47 kls Exp $
* $Id: skincurses.c 2.7 2011/08/21 11:04:38 kls Exp $
*/
#include <ncurses.h>
@ -436,7 +436,7 @@ void cSkinCursesDisplayMenu::SetRecording(const cRecording *Recording)
int y = 2;
cTextScroller ts;
char t[32];
snprintf(t, sizeof(t), "%s %s", *DateString(Recording->start), *TimeString(Recording->start));
snprintf(t, sizeof(t), "%s %s", *DateString(Recording->Start()), *TimeString(Recording->Start()));
ts.Set(osd, 0, y, ScOsdWidth, ScOsdHeight - y - 2, t, &Font, clrYellow, clrBackground);
y += ts.Height();
if (Info->GetEvent()->ParentalRating()) {

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: cutter.c 2.7 2011/08/20 09:57:27 kls Exp $
* $Id: cutter.c 2.8 2011/08/21 11:08:08 kls Exp $
*/
#include "cutter.h"
@ -75,7 +75,7 @@ void cCuttingThread::Action(void)
if (!fromFile || !toFile)
return;
fromFile->SetReadAhead(MEGABYTE(20));
int Index = Mark->position;
int Index = Mark->Position();
Mark = fromMarks.Next(Mark);
off_t FileSize = 0;
int CurrentFileNumber = 0;
@ -163,14 +163,14 @@ void cCuttingThread::Action(void)
// Check editing marks:
if (Mark && Index >= Mark->position) {
if (Mark && Index >= Mark->Position()) {
Mark = fromMarks.Next(Mark);
toMarks.Add(LastIFrame);
if (Mark)
toMarks.Add(toIndex->Last() + 1);
toMarks.Save();
if (Mark) {
Index = Mark->position;
Index = Mark->Position();
Mark = fromMarks.Next(Mark);
CurrentFileNumber = 0; // triggers SetOffset before reading next frame
cutIn = true;
@ -212,7 +212,7 @@ bool cCutter::Start(const char *FileName)
cMarks FromMarks;
FromMarks.Load(FileName);
if (cMark *First = FromMarks.First())
Recording.SetStartTime(Recording.start + (int(First->position / Recording.FramesPerSecond() + 30) / 60) * 60);
Recording.SetStartTime(Recording.Start() + (int(First->Position() / Recording.FramesPerSecond() + 30) / 60) * 60);
const char *evn = Recording.PrefixFileName('%');
if (evn && RemoveVideoFile(evn) && MakeDirs(evn, true)) {

13
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: menu.c 2.29 2011/08/06 13:13:34 kls Exp $
* $Id: menu.c 2.30 2011/08/21 11:09:19 kls Exp $
*/
#include "menu.h"
@ -4667,7 +4667,7 @@ void cReplayControl::MarkJump(bool Forward)
if (GetIndex(Current, Total)) {
cMark *m = Forward ? marks.GetNext(Current) : marks.GetPrev(Current);
if (m) {
Goto(m->position, true);
Goto(m->Position(), true);
displayFrames = true;
}
}
@ -4684,14 +4684,15 @@ void cReplayControl::MarkMove(bool Forward)
int p = SkipFrames(Forward ? 1 : -1);
cMark *m2;
if (Forward) {
if ((m2 = marks.Next(m)) != NULL && m2->position <= p)
if ((m2 = marks.Next(m)) != NULL && m2->Position() <= p)
return;
}
else {
if ((m2 = marks.Prev(m)) != NULL && m2->position >= p)
if ((m2 = marks.Prev(m)) != NULL && m2->Position() >= p)
return;
}
Goto(m->position = p, true);
m->SetPosition(p);
Goto(m->Position(), true);
marks.Save();
}
}
@ -4726,7 +4727,7 @@ void cReplayControl::EditTest(void)
if ((m->Index() & 0x01) != 0)
m = marks.Next(m);
if (m) {
Goto(m->position - SecondsToFrames(3, FramesPerSecond()));
Goto(m->Position() - SecondsToFrames(3, FramesPerSecond()));
Play();
}
}

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: recording.c 2.34 2011/08/20 09:53:45 kls Exp $
* $Id: recording.c 2.35 2011/08/21 11:19:55 kls Exp $
*/
#include "recording.h"
@ -94,7 +94,7 @@ void cRemoveDeletedRecordingsThread::Action(void)
bool deleted = false;
cThreadLock DeletedRecordingsLock(&DeletedRecordings);
for (cRecording *r = DeletedRecordings.First(); r; ) {
if (r->deleted && time(NULL) - r->deleted > DELETEDLIFETIME) {
if (r->Deleted() && time(NULL) - r->Deleted() > DELETEDLIFETIME) {
cRecording *next = DeletedRecordings.Next(r);
r->Remove();
DeletedRecordings.Del(r);
@ -120,7 +120,7 @@ void RemoveDeletedRecordings(void)
if (!RemoveDeletedRecordingsThread.Active()) {
cThreadLock DeletedRecordingsLock(&DeletedRecordings);
for (cRecording *r = DeletedRecordings.First(); r; r = DeletedRecordings.Next(r)) {
if (r->deleted && time(NULL) - r->deleted > DELETEDLIFETIME) {
if (r->Deleted() && time(NULL) - r->Deleted() > DELETEDLIFETIME) {
RemoveDeletedRecordingsThread.Start();
break;
}
@ -153,7 +153,7 @@ void AssertFreeDiskSpace(int Priority, bool Force)
cRecording *r0 = NULL;
while (r) {
if (IsOnVideoDirectoryFileSystem(r->FileName())) { // only remove recordings that will actually increase the free video disk space
if (!r0 || r->start < r0->start)
if (!r0 || r->Start() < r0->Start())
r0 = r;
}
r = DeletedRecordings.Next(r);
@ -180,11 +180,11 @@ void AssertFreeDiskSpace(int Priority, bool Force)
cRecording *r0 = NULL;
while (r) {
if (IsOnVideoDirectoryFileSystem(r->FileName())) { // only delete recordings that will actually increase the free video disk space
if (!r->IsEdited() && r->lifetime < MAXLIFETIME) { // edited recordings and recordings with MAXLIFETIME live forever
if ((r->lifetime == 0 && Priority > r->priority) || // the recording has no guaranteed lifetime and the new recording has higher priority
(r->lifetime > 0 && (time(NULL) - r->start) / SECSINDAY >= r->lifetime)) { // the recording's guaranteed lifetime has expired
if (!r->IsEdited() && r->Lifetime() < MAXLIFETIME) { // edited recordings and recordings with MAXLIFETIME live forever
if ((r->Lifetime() == 0 && Priority > r->Priority()) || // the recording has no guaranteed lifetime and the new recording has higher priority
(r->Lifetime() > 0 && (time(NULL) - r->Start()) / SECSINDAY >= r->Lifetime())) { // the recording's guaranteed lifetime has expired
if (r0) {
if (r->priority < r0->priority || (r->priority == r0->priority && r->start < r0->start))
if (r->Priority() < r0->Priority() || (r->Priority() == r0->Priority() && r->Start() < r0->Start()))
r0 = r; // in any case we delete the one with the lowest priority (or the older one in case of equal priorities)
}
else
@ -1240,23 +1240,21 @@ cMutex MutexMarkFramesPerSecond;
cMark::cMark(int Position, const char *Comment, double FramesPerSecond)
{
position = Position;
comment = Comment ? strdup(Comment) : NULL;
comment = Comment;
framesPerSecond = FramesPerSecond;
}
cMark::~cMark()
{
free(comment);
}
cString cMark::ToText(void)
{
return cString::sprintf("%s%s%s\n", *IndexToHMSF(position, true, framesPerSecond), comment ? " " : "", comment ? comment : "");
return cString::sprintf("%s%s%s\n", *IndexToHMSF(position, true, framesPerSecond), Comment() ? " " : "", Comment() ? Comment() : "");
}
bool cMark::Parse(const char *s)
{
free(comment);
comment = NULL;
framesPerSecond = MarkFramesPerSecond;
position = HMSFToIndex(s, framesPerSecond);
@ -1320,7 +1318,7 @@ void cMarks::Sort(void)
{
for (cMark *m1 = First(); m1; m1 = Next(m1)) {
for (cMark *m2 = Next(m1); m2; m2 = Next(m2)) {
if (m2->position < m1->position) {
if (m2->Position() < m1->Position()) {
swap(m1->position, m2->position);
swap(m1->comment, m2->comment);
}
@ -1341,7 +1339,7 @@ cMark *cMarks::Add(int Position)
cMark *cMarks::Get(int Position)
{
for (cMark *mi = First(); mi; mi = Next(mi)) {
if (mi->position == Position)
if (mi->Position() == Position)
return mi;
}
return NULL;
@ -1350,7 +1348,7 @@ cMark *cMarks::Get(int Position)
cMark *cMarks::GetPrev(int Position)
{
for (cMark *mi = Last(); mi; mi = Prev(mi)) {
if (mi->position < Position)
if (mi->Position() < Position)
return mi;
}
return NULL;
@ -1359,7 +1357,7 @@ cMark *cMarks::GetPrev(int Position)
cMark *cMarks::GetNext(int Position)
{
for (cMark *mi = First(); mi; mi = Next(mi)) {
if (mi->position > Position)
if (mi->Position() > Position)
return mi;
}
return NULL;

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: recording.h 2.23 2011/08/20 09:52:07 kls Exp $
* $Id: recording.h 2.24 2011/08/21 11:34:03 kls Exp $
*/
#ifndef __RECORDING_H
@ -22,6 +22,8 @@
#define TIMERMACRO_TITLE "TITLE"
#define TIMERMACRO_EPISODE "EPISODE"
#define __RECORDING_H_DEPRECATED_DIRECT_MEMBER_ACCESS // Code enclosed with this macro is deprecated and may be removed in a future version
extern bool VfatFileSystem;
extern int InstanceId;
@ -97,14 +99,21 @@ private:
static char *StripEpisodeName(char *s);
char *SortName(void) const;
int GetResume(void) const;
#ifdef __RECORDING_H_DEPRECATED_DIRECT_MEMBER_ACCESS
public:
#endif
time_t start;
int priority;
int lifetime;
time_t deleted;
public:
cRecording(cTimer *Timer, const cEvent *Event);
cRecording(const char *FileName);
virtual ~cRecording();
time_t Start(void) const { return start; }
int Priority(void) const { return priority; }
int Lifetime(void) const { return lifetime; }
time_t Deleted(void) const { return deleted; }
virtual int Compare(const cListObject &ListObject) const;
const char *Name(void) const { return name; }
const char *FileName(void) const;
@ -184,13 +193,21 @@ extern cRecordings DeletedRecordings;
#define DEFAULTFRAMESPERSECOND 25.0
class cMark : public cListObject {
friend class cMarks; // for sorting
private:
double framesPerSecond;
#ifdef __RECORDING_H_DEPRECATED_DIRECT_MEMBER_ACCESS
public:
#endif
int position;
char *comment;
cString comment;
public:
cMark(int Position = 0, const char *Comment = NULL, double FramesPerSecond = DEFAULTFRAMESPERSECOND);
virtual ~cMark();
int Position(void) const { return position; }
const char *Comment(void) const { return comment; }
void SetPosition(int Position) { position = Position; }
void SetComment(const char *Comment) { comment = Comment; }
cString ToText(void);
bool Parse(const char *s);
bool Save(FILE *f);

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: skinclassic.c 2.5 2010/11/07 15:10:23 kls Exp $
* $Id: skinclassic.c 2.6 2011/08/21 11:02:06 kls Exp $
*/
#include "skinclassic.h"
@ -377,7 +377,7 @@ void cSkinClassicDisplayMenu::SetRecording(const cRecording *Recording)
int y = y2;
cTextScroller ts;
char t[32];
snprintf(t, sizeof(t), "%s %s", *DateString(Recording->start), *TimeString(Recording->start));
snprintf(t, sizeof(t), "%s %s", *DateString(Recording->Start()), *TimeString(Recording->Start()));
ts.Set(osd, x1, y, x2 - x1, y3 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
y += ts.Height();
if (Info->GetEvent()->ParentalRating()) {

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: skins.c 2.2 2011/08/06 09:41:57 kls Exp $
* $Id: skins.c 2.3 2011/08/21 11:21:19 kls Exp $
*/
#include "skins.h"
@ -136,14 +136,14 @@ cSkinDisplayReplay::cProgressBar::cProgressBar(int Width, int Height, int Curren
if (Marks) {
bool Start = true;
for (const cMark *m = Marks->First(); m; m = Marks->Next(m)) {
int p1 = Pos(m->position);
int p1 = Pos(m->Position());
if (Start) {
const cMark *m2 = Marks->Next(m);
int p2 = Pos(m2 ? m2->position : total);
int p2 = Pos(m2 ? m2->Position() : total);
int h = Height / 3;
DrawRectangle(p1, h, p2, Height - h, ColorSelected);
}
Mark(p1, Start, m->position == Current, ColorMark, ColorCurrent);
Mark(p1, Start, m->Position() == Current, ColorMark, ColorCurrent);
Start = !Start;
}
}

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: skinsttng.c 2.10 2011/06/12 15:20:59 kls Exp $
* $Id: skinsttng.c 2.11 2011/08/21 11:02:26 kls Exp $
*/
// Star Trek: The Next Generation® is a registered trademark of Paramount Pictures
@ -693,7 +693,7 @@ void cSkinSTTNGDisplayMenu::SetRecording(const cRecording *Recording)
int y = y3;
cTextScroller ts;
char t[32];
snprintf(t, sizeof(t), "%s %s", *DateString(Recording->start), *TimeString(Recording->start));
snprintf(t, sizeof(t), "%s %s", *DateString(Recording->Start()), *TimeString(Recording->Start()));
ts.Set(osd, xl, y, x4 - xl, y4 - y, t, font, Theme.Color(clrMenuEventTime), Theme.Color(clrBackground));
y += ts.Height();
if (Info->GetEvent()->ParentalRating()) {