cec: don't lock the mutex when checking for the poll status of a device. this is...
[deb_libcec.git] / src / lib / adapter / USBCECAdapterCommunication.cpp
index 8e0b44e58b57e72fbf440d123f1da58b1094fcb9..e5cedb8b03e99d07652018813b0ef180c4666fb6 100644 (file)
@@ -174,9 +174,11 @@ bool CUSBCECAdapterCommunication::Open(IAdapterCommunicationCallback *cb, uint32
 void CUSBCECAdapterCommunication::Close(void)
 {
   SetAckMask(0);
-  CLockObject lock(m_mutex);
-  m_bHasData = true;
-  m_rcvCondition.Broadcast();
+  {
+    CLockObject lock(m_mutex);
+    m_bHasData = true;
+    m_rcvCondition.Broadcast();
+  }
   StopThread();
 }
 
@@ -661,6 +663,7 @@ bool CUSBCECAdapterCommunication::ReadFromDevice(uint32_t iTimeout, size_t iSize
   if (iBytesRead < 0 || iBytesRead > 256)
   {
     CLibCEC::AddLog(CEC_LOG_ERROR, "error reading from serial port: %s", m_port->GetError().c_str());
+    StopThread(false);
     return false;
   }
   else if (iBytesRead > 0)