mark the adapter as (in)active source for firmware v3+
[deb_libcec.git] / src / lib / adapter / Pulse-Eight / USBCECAdapterCommunication.cpp
index 7fa78f73638b96eff4e9ace948a258f57247affd..ae404588e366ff94c47e3ab8e2c4b2aa68a98958 100644 (file)
@@ -284,7 +284,8 @@ void *CUSBCECAdapterCommunication::Process(void)
     }
 
     /* TODO sleep 5 ms so other threads can get a lock */
-    Sleep(5);
+    if (!IsStopped())
+      Sleep(5);
   }
 
   m_adapterMessageQueue->Clear();
@@ -627,6 +628,12 @@ uint16_t CUSBCECAdapterCommunication::GetAdapterProductId(void) const
   return iBuildDate >= CEC_FW_DATE_DESCRIPTOR2 ? CEC_PID2 : CEC_PID;
 }
 
+void CUSBCECAdapterCommunication::SetActiveSource(bool bSetTo, bool bClientUnregistered)
+{
+  if (m_commands)
+    m_commands->SetActiveSource(bSetTo, bClientUnregistered);
+}
+
 bool CUSBCECAdapterCommunication::IsRunningLatestFirmware(void)
 {
   return GetFirmwareBuildDate() >= CEC_LATEST_ADAPTER_FW_DATE &&
@@ -738,6 +745,7 @@ void CAdapterEepromWriteThread::Stop(void)
     CLockObject lock(m_mutex);
     if (m_iScheduleEepromWrite > 0)
       m_com->LIB_CEC->AddLog(CEC_LOG_WARNING, "write thread stopped while a write was queued");
+    m_bWrite = true;
     m_condition.Signal();
   }
   StopThread();
@@ -751,6 +759,8 @@ void *CAdapterEepromWriteThread::Process(void)
     if ((m_iScheduleEepromWrite > 0 && m_iScheduleEepromWrite < GetTimeMs()) ||
         m_condition.Wait(m_mutex, m_bWrite, 100))
     {
+      if (IsStopped())
+        break;
       m_bWrite = false;
       if (m_com->m_commands->WriteEEPROM())
       {