summaryrefslogtreecommitdiff
path: root/dvbplayer.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2015-02-06 15:42:21 +0100
committerKlaus Schmidinger <vdr@tvdr.de>2015-02-06 15:42:21 +0100
commitf3e6d393829878980eea821a068ef04a5ac5adf4 (patch)
tree3b1f2a88ba1bf0947aefb53b7f2c590caa8460a0 /dvbplayer.c
parent4ffd2d6ccdd4c5e679ded76c879d75377e478325 (diff)
downloadvdr-f3e6d393829878980eea821a068ef04a5ac5adf4.tar.gz
vdr-f3e6d393829878980eea821a068ef04a5ac5adf4.tar.bz2
cDvbPlayer and cReplayControl now use the same list of editing marks
Diffstat (limited to 'dvbplayer.c')
-rw-r--r--dvbplayer.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/dvbplayer.c b/dvbplayer.c
index 9e561ca1..94882e29 100644
--- a/dvbplayer.c
+++ b/dvbplayer.c
@@ -4,13 +4,12 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: dvbplayer.c 3.4 2015/02/02 09:51:32 kls Exp $
+ * $Id: dvbplayer.c 3.5 2015/02/06 15:08:51 kls Exp $
*/
#include "dvbplayer.h"
#include <math.h>
#include <stdlib.h>
-#include "recording.h"
#include "remux.h"
#include "ringbuffer.h"
#include "thread.h"
@@ -211,7 +210,7 @@ private:
cNonBlockingFileReader *nonBlockingFileReader;
cRingBufferFrame *ringBuffer;
cPtsIndex ptsIndex;
- cMarks marks;
+ cMarks *marks;
cFileName *fileName;
cIndexFile *index;
cUnbufferedFile *replayFile;
@@ -240,6 +239,7 @@ protected:
public:
cDvbPlayer(const char *FileName, bool PauseLive);
virtual ~cDvbPlayer();
+ void SetMarks(cMarks *Marks);
bool Active(void) { return cThread::Running(); }
void Pause(void);
void Play(void);
@@ -265,6 +265,7 @@ cDvbPlayer::cDvbPlayer(const char *FileName, bool PauseLive)
{
nonBlockingFileReader = NULL;
ringBuffer = NULL;
+ marks = NULL;
index = NULL;
cRecording Recording(FileName);
framesPerSecond = Recording.FramesPerSecond();
@@ -297,8 +298,6 @@ cDvbPlayer::cDvbPlayer(const char *FileName, bool PauseLive)
}
else if (PauseLive)
framesPerSecond = cRecording(FileName).FramesPerSecond(); // the fps rate might have changed from the default
- if (Setup.SkipEdited || Setup.PauseAtLastMark)
- marks.Load(FileName, framesPerSecond, isPesRecording);
}
cDvbPlayer::~cDvbPlayer()
@@ -309,6 +308,12 @@ cDvbPlayer::~cDvbPlayer()
delete index;
delete fileName;
delete ringBuffer;
+ // don't delete marks here, we don't own them!
+}
+
+void cDvbPlayer::SetMarks(cMarks *Marks)
+{
+ marks = Marks;
}
void cDvbPlayer::TrickSpeed(int Increment)
@@ -377,8 +382,12 @@ bool cDvbPlayer::Save(void)
if (index) {
int Index = ptsIndex.FindIndex(DeviceGetSTC());
if (Index >= 0) {
- if (Setup.SkipEdited && marks.First() && abs(Index - marks.First()->Position()) <= int(round(RESUMEBACKUP * framesPerSecond)))
- Index = 0; // when stopping within RESUMEBACKUP seconds of the first mark the recording shall still be considered unviewed
+ if (Setup.SkipEdited && marks) {
+ marks->Lock();
+ if (marks->First() && abs(Index - marks->First()->Position()) <= int(round(RESUMEBACKUP * framesPerSecond)))
+ Index = 0; // when stopping within RESUMEBACKUP seconds of the first mark the recording shall still be considered unviewed
+ marks->Unlock();
+ }
Index -= int(round(RESUMEBACKUP * framesPerSecond));
if (Index > 0)
Index = index->GetNextIFrame(Index, false);
@@ -409,9 +418,10 @@ void cDvbPlayer::Action(void)
readIndex = Resume();
if (readIndex > 0)
isyslog("resuming replay at index %d (%s)", readIndex, *IndexToHMSF(readIndex, true, framesPerSecond));
- else if (Setup.SkipEdited) {
- if (marks.First() && index) {
- int Index = marks.First()->Position();
+ else if (Setup.SkipEdited && marks) {
+ marks->Lock();
+ if (marks->First() && index) {
+ int Index = marks->First()->Position();
uint16_t FileNumber;
off_t FileOffset;
if (index->Get(Index, &FileNumber, &FileOffset) && NextFile(FileNumber, FileOffset)) {
@@ -419,6 +429,7 @@ void cDvbPlayer::Action(void)
readIndex = Index;
}
}
+ marks->Unlock();
}
nonBlockingFileReader = new cNonBlockingFileReader;
@@ -488,11 +499,11 @@ void cDvbPlayer::Action(void)
off_t FileOffset;
if (index->Get(readIndex + 1, &FileNumber, &FileOffset, &readIndependent, &Length) && NextFile(FileNumber, FileOffset)) {
readIndex++;
- if (Setup.SkipEdited || Setup.PauseAtLastMark) {
- marks.Update();
- cMark *m = marks.Get(readIndex);
+ if ((Setup.SkipEdited || Setup.PauseAtLastMark) && marks) {
+ marks->Lock();
+ cMark *m = marks->Get(readIndex);
if (m && (m->Index() & 0x01) != 0) { // we're at an end mark
- m = marks.GetNextBegin(m);
+ m = marks->GetNextBegin(m);
int Index = -1;
if (m)
Index = m->Position(); // skip to next begin mark
@@ -508,6 +519,7 @@ void cDvbPlayer::Action(void)
CutIn = true;
}
}
+ marks->Unlock();
}
}
else
@@ -931,6 +943,12 @@ cDvbPlayerControl::~cDvbPlayerControl()
Stop();
}
+void cDvbPlayerControl::SetMarks(cMarks *Marks)
+{
+ if (player)
+ player->SetMarks(Marks);
+}
+
bool cDvbPlayerControl::Active(void)
{
return player && player->Active();