summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Gmeiner <christian.gmeiner@gmail.com>2010-06-29 17:29:32 +0200
committerChristian Gmeiner <christian.gmeiner@gmail.com>2010-06-29 17:29:32 +0200
commitb8c967e8f99bbc52aafe3cf8c98a3fba7f44eaa8 (patch)
tree8943c8942584b471165f6939ca8f548fd7cbf844
parent0a0f6568422dc019a420aaf93d9a5aa36aee53a9 (diff)
downloadvdr-plugin-dxr3-b8c967e8f99bbc52aafe3cf8c98a3fba7f44eaa8.tar.gz
vdr-plugin-dxr3-b8c967e8f99bbc52aafe3cf8c98a3fba7f44eaa8.tar.bz2
store last written video frame
There is one limitation with this way to keep track of played video frame. We store the last written video frame, which is not the current shown video frame, as we buffer about 500ms video in hardware buffer of the dxr3 device.
-rw-r--r--dxr3device.c21
-rw-r--r--dxr3device.h3
2 files changed, 24 insertions, 0 deletions
diff --git a/dxr3device.c b/dxr3device.c
index a7d6f2d..1616759 100644
--- a/dxr3device.c
+++ b/dxr3device.c
@@ -43,6 +43,7 @@ static const int TIMESTAMPS_500MS = 45000;
cDxr3Device::cDxr3Device() : spuDecoder(NULL), pluginOn(true), vPts(0), scrSet(false), aspectRatio(EM8300_ASPECTRATIO_4_3)
{
+ lastVideoFrame.data = NULL;
claimDevices();
switch (cSettings::instance()->audioDriver()) {
@@ -75,6 +76,9 @@ cDxr3Device::~cDxr3Device()
if (spuDecoder)
delete spuDecoder;
+
+ if (lastVideoFrame.data)
+ delete[] lastVideoFrame.data;
}
cDxr3Device *cDxr3Device::instance()
@@ -593,6 +597,23 @@ void cDxr3Device::playVideoFrame(cDxr3PesFrame *frame, uint32_t pts)
uint32_t len = frame->payloadSize();
WriteAllOrNothing(fdVideo, data, len, 1000, 10);
+
+ // store last written video frame
+ lastVideoFrameMutex.Lock();
+
+ // make sure that there is space to store video data
+ if (!lastVideoFrame.data) {
+ lastVideoFrame.data = new uint8_t[len];
+ } else if (lastVideoFrame.size < len) {
+ delete[] lastVideoFrame.data;
+ lastVideoFrame.data = new uint8_t[len];
+ }
+
+ // update data
+ memcpy(lastVideoFrame.data, data, sizeof(uint8_t)*len);
+ lastVideoFrame.size = len;
+
+ lastVideoFrameMutex.Unlock();
}
void cDxr3Device::playBlackFrame(uint32_t pts)
diff --git a/dxr3device.h b/dxr3device.h
index f2675f0..9b1af70 100644
--- a/dxr3device.h
+++ b/dxr3device.h
@@ -136,6 +136,9 @@ private:
uint32_t vertical;
uint32_t aspectRatio;
+ cMutex lastVideoFrameMutex;
+ AVPacket lastVideoFrame;
+
static cDxr3Device *inst;
};