summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--device.c33
-rw-r--r--device.h10
2 files changed, 39 insertions, 4 deletions
diff --git a/device.c b/device.c
index bc346783..967abd0f 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.14 2006-08-22 21:09:49 phintuka Exp $
+ * $Id: device.c,v 1.15 2006-08-24 23:31:16 phintuka Exp $
*
*/
@@ -29,6 +29,7 @@
#include "tools/listiter.h"
#include "tools/pes.h"
+#include "tools/functor.h"
#include "frontend_local.h"
#include "frontend_svr.h"
@@ -255,10 +256,19 @@ void cXinelibDevice::MakePrimaryDevice(bool On)
void cXinelibDevice::ForcePrimaryDevice(bool On)
{
+ LOGDBG("cXinelibDevice::ForcePrimaryDevice(%s)",On?"On":"Off");
+ m_MainThreadLock.Lock();
+ m_MainThreadFunctors.Add(CreateFunctor(this, &cXinelibDevice::ForcePrimaryDeviceImpl, On));
+ m_MainThreadLock.Unlock();
+}
+
+void cXinelibDevice::ForcePrimaryDeviceImpl(bool On)
+{
static int Original = 0;
static int Counter = 0;
- TRACEF("cXinelibDevice::ForcePrimaryDevice");
+ TRACEF("cXinelibDevice::ForcePrimaryDeviceImpl");
+ LOGDBG("cXinelibDevice::ForcePrimaryDeviceImpl(%s)",On?"On":"Off");
/* TODO: All this stuff should really be done in VDR main thread context... */
@@ -305,6 +315,25 @@ void cXinelibDevice::ForcePrimaryDevice(bool On)
}
}
+void cXinelibDevice::MainThreadHook(void)
+{
+ TRACEF("cXinelibDevice::MainThreadHook");
+
+ cFunctor *f = NULL;
+ do {
+ m_MainThreadLock.Lock();
+ if(f)
+ m_MainThreadFunctors.Del(f);
+ f = m_MainThreadFunctors.First();
+ m_MainThreadLock.Unlock();
+
+ if(f) {
+ LOGDBG("cXinelibDevice::MainThreadHook: executing functor 0x%lx",(long)f);
+ f->Execute();
+ }
+
+ } while(f);
+}
//
// Configuration
diff --git a/device.h b/device.h
index 2330df42..eed10947 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.8 2006-08-22 03:45:34 phintuka Exp $
+ * $Id: device.h,v 1.9 2006-08-24 23:31:16 phintuka Exp $
*
*/
@@ -18,6 +18,7 @@
class cXinelibStatusMonitor;
class cXinelibThread;
class cChannel;
+class cFunctor;
class cXinelibDevice : public cDevice
{
@@ -30,7 +31,11 @@ class cXinelibDevice : public cDevice
cXinelibDevice(); //
cXinelibDevice(cXinelibDevice&); // no copy constructor
- //cList<cFunctorBase> *m_MainThreadFunctors; // function calls waiting to be executed in VDR main thread context
+ // function calls waiting to be executed in VDR main thread context
+ cList<cFunctor> m_MainThreadFunctors;
+ cMutex m_MainThreadLock;
+
+ void ForcePrimaryDeviceImpl(bool On);
public:
virtual ~cXinelibDevice();
@@ -40,6 +45,7 @@ class cXinelibDevice : public cDevice
virtual void MakePrimaryDevice(bool On);
void ForcePrimaryDevice(bool On);
+ void MainThreadHook(void);
virtual void Clear(void);
virtual void Play(void);