fixed: don't call CEC_ALERT_CONNECTION_LOST when closing the connection, which caused...
[deb_libcec.git] / src / lib / adapter / Pulse-Eight / USBCECAdapterCommunication.cpp
index 2e9c790a7342cce914c28eb29c4e8ba031c33712..1be07c51fbb385e224a7fa5ec1ff0c2cb40515f9 100644 (file)
@@ -304,6 +304,7 @@ bool CUSBCECAdapterCommunication::HandlePoll(const CCECAdapterMessage &msg)
     m_lastPollDestination = msg.Destination();
     if (msg.Destination() < CECDEVICE_BROADCAST)
     {
+      CLockObject waitingLock(m_waitingMutex);
       if (!m_bWaitingForAck[msg.Destination()] && !msg.IsEOM())
       {
         if (m_callback)
@@ -328,7 +329,7 @@ void CUSBCECAdapterCommunication::MarkAsWaiting(const cec_logical_address dest)
   /* mark as waiting for an ack from the destination */
   if (dest < CECDEVICE_BROADCAST)
   {
-    CLockObject lock(m_mutex);
+    CLockObject waitingLock(m_waitingMutex);
     m_bWaitingForAck[dest] = true;
   }
 }
@@ -709,7 +710,7 @@ void *CAdapterPingThread::Process(void)
       /* send a ping to the adapter */
       bool bPinged(false);
       int iFailedCounter(0);
-      while (!bPinged && iFailedCounter < 3)
+      while (!bPinged && iFailedCounter < 3 && !IsStopped())
       {
         if (!m_com->PingAdapter())
         {
@@ -723,7 +724,7 @@ void *CAdapterPingThread::Process(void)
         }
       }
 
-      if (iFailedCounter == 3)
+      if (iFailedCounter == 3 && !IsStopped())
       {
         /* failed to ping the adapter 3 times in a row. something must be wrong with the connection */
         m_com->LIB_CEC->AddLog(CEC_LOG_ERROR, "failed to ping the adapter 3 times in a row. closing the connection.");