summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorphintuka <phintuka>2010-03-15 12:26:53 +0000
committerphintuka <phintuka>2010-03-15 12:26:53 +0000
commitfd98f36bf7e58ceb172dbd1b56b2cd377f5186d1 (patch)
tree858b9f969c9ce8bd58a2558433d029c20f2812e5
parent1a6a6d9e2c3943d6cf53a8c00726cff1b32cf31a (diff)
downloadxineliboutput-fd98f36bf7e58ceb172dbd1b56b2cd377f5186d1.tar.gz
xineliboutput-fd98f36bf7e58ceb172dbd1b56b2cd377f5186d1.tar.bz2
Properly lock m_TsBuf access
-rw-r--r--device.c19
-rw-r--r--device.h7
2 files changed, 23 insertions, 3 deletions
diff --git a/device.c b/device.c
index e58315af..70b12458 100644
--- a/device.c
+++ b/device.c
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: device.c,v 1.103 2010-03-15 11:43:26 phintuka Exp $
+ * $Id: device.c,v 1.104 2010-03-15 12:26:53 phintuka Exp $
*
*/
@@ -36,6 +36,7 @@
#include "tools/pes.h"
#include "tools/ts.h"
#include "tools/functor.h"
+#include "tools/section_lock.h"
#include "frontend_local.h"
#include "frontend_svr.h"
@@ -1146,8 +1147,16 @@ int cXinelibDevice::PlayTs(const uchar *Data, int Length, bool VideoOnly)
return Result;
}
+/*
+ * TS buffer
+ */
+
+#define TS_BUFFER_LOCK cSectionLock(m_TsBufLock)
+
int cXinelibDevice::TsBufferFlush(void)
{
+ TS_BUFFER_LOCK;
+
if (m_TsBufSize) {
int n;
if ((n = PlayAny(m_TsBuf, m_TsBufSize)) == (int)m_TsBufSize) {
@@ -1161,6 +1170,12 @@ int cXinelibDevice::TsBufferFlush(void)
return 0;
}
+void cXinelibDevice::TsBufferClear(void)
+{
+ TS_BUFFER_LOCK;
+ m_TsBufSize = 0;
+}
+
int cXinelibDevice::PlayTsAny(const uchar *buf, int length)
{
if (!DATA_IS_TS(buf))
@@ -1168,6 +1183,8 @@ int cXinelibDevice::PlayTsAny(const uchar *buf, int length)
if (length != TS_SIZE)
LOGMSG("PlayTsAny(): length == %d !", length);
+ TS_BUFFER_LOCK;
+
// cache full ? try to flush it
if (m_TsBufSize >= 2048)
if (!TsBufferFlush())
diff --git a/device.h b/device.h
index 34a16d85..d1bf3571 100644
--- a/device.h
+++ b/device.h
@@ -4,7 +4,7 @@
* See the main source file 'xineliboutput.c' for copyright information and
* how to reach the author.
*
- * $Id: device.h,v 1.56 2010-03-15 11:43:26 phintuka Exp $
+ * $Id: device.h,v 1.57 2010-03-15 12:26:53 phintuka Exp $
*
*/
@@ -14,6 +14,7 @@
#include <vdr/config.h>
#include <vdr/device.h>
#include <vdr/tools.h>
+#include <vdr/thread.h>
class cXinelibStatusMonitor;
class cXinelibThread;
@@ -250,10 +251,12 @@ class cXinelibDevice : public cDevice
#if VDRVERSNUM >= 10701
/* join multiple TS packets to xineliboutput transport packet */
+ cMutex m_TsBufLock;
uint8_t m_TsBuf[4096];
uint m_TsBufSize;
+
int TsBufferFlush(void);
- void TsBufferClear(void) { m_TsBufSize = 0; };
+ void TsBufferClear(void);
int PlayTsAny(const uchar *Data, int Length);