cec: fixed another deadlock on exit
authorLars Op den Kamp <lars@opdenkamp.eu>
Tue, 6 Dec 2011 23:40:01 +0000 (00:40 +0100)
committerLars Op den Kamp <lars@opdenkamp.eu>
Tue, 6 Dec 2011 23:40:01 +0000 (00:40 +0100)
src/lib/AdapterCommunication.cpp
src/lib/CECProcessor.cpp
src/lib/CECProcessor.h

index 5541bf56a5381febe2a64264b897099fff2d1cc6..2bdbb04deded358fa721a2305cb254479a02f8fa 100644 (file)
@@ -328,6 +328,10 @@ void *CAdapterCommunication::Process(void)
     WriteNextCommand();
   }
 
+  CCECAdapterMessage *msg;
+  if (m_outBuffer.Pop(msg))
+    msg->condition.Broadcast();
+
   return NULL;
 }
 
index 4df840d02f48e261cac71d371cdfcda8c9b123d4..1daa7b60d2d8d421f879fa9b530ce07039725b1f 100644 (file)
@@ -118,14 +118,6 @@ CCECProcessor::CCECProcessor(CLibCEC *controller, const char *strDeviceName, con
 CCECProcessor::~CCECProcessor(void)
 {
   m_bStarted = false;
-  StopThread(false);
-
-  if (m_busScan)
-  {
-    m_busScan->StopThread();
-    delete m_busScan;
-  }
-
   m_startCondition.Broadcast();
   StopThread();
 
@@ -304,6 +296,13 @@ void *CCECProcessor::Process(void)
     m_controller->CheckKeypressTimeout();
   }
 
+  if (m_busScan)
+  {
+    m_busScan->StopThread();
+    delete m_busScan;
+    m_busScan = NULL;
+  }
+
   if (m_communication)
     m_communication->Close();
 
index 6d775f5cf4ecfcb4f9c42eb2f9a76a3f79304da5..75196eacaba51f516e1490e87694d0120ec94210 100644 (file)
@@ -127,7 +127,6 @@ namespace CEC
 
       CCECBusDevice *m_busDevices[16];
       CMutex         m_transmitMutex;
-      uint64_t       m_iLastTransmission;
 
   private:
       void ScanCECBus(void);
@@ -162,13 +161,14 @@ namespace CEC
       uint8_t                m_iLineTimeout;
       uint8_t                m_iStandardLineTimeout;
       uint8_t                m_iRetryLineTimeout;
+      uint64_t               m_iLastTransmission;
   };
 
   class CCECBusScan : public CThread
   {
   public:
     CCECBusScan(CCECProcessor *processor) { m_processor = processor; }
-    virtual ~CCECBusScan(void) {}
+    virtual ~CCECBusScan(void) { StopThread(true); }
     virtual void *Process(void);
 
   private: