cec: don't lock the mutex when checking for the poll status of a device. this is...
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index b6ca75ca1835bf330ccb371e0aa74d4705376626..ceb311d77b731fca1b09dad283ad1f23aa57a900 100644 (file)
@@ -114,28 +114,13 @@ bool CCECBusDevice::HandleCommand(const cec_command &command)
 bool CCECBusDevice::PowerOn(void)
 {
   bool bReturn(false);
-  GetVendorId(); // ensure that we got the vendor id
+  GetVendorId(); // ensure that we got the vendor id, because the implementations vary per vendor
 
   MarkBusy();
   CLibCEC::AddLog(CEC_LOG_NOTICE, "<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
   if (m_handler->PowerOn(GetMyLogicalAddress(), m_iLogicalAddress))
   {
-    {
-//      CLockObject lock(m_mutex);
-//      m_powerStatus = CEC_POWER_STATUS_UNKNOWN;
-      SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
-    }
-//    cec_power_status status = GetPowerStatus();
-//    if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN)
-//    {
-//      /* sending the normal power on command appears to have failed */
-//      CStdString strLog;
-//      strLog.Format("<< sending power on keypress to '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress);
-//      CLibCEC::AddLog(CEC_LOG_DEBUG, strLog.c_str());
-//
-//      TransmitKeypress(CEC_USER_CONTROL_CODE_POWER);
-//      return TransmitKeyRelease();
-//    }
+    SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON);
     bReturn = true;
   }
 
@@ -864,6 +849,9 @@ bool CCECBusDevice::TransmitPowerState(cec_logical_address dest)
   cec_power_status state;
   {
     CLockObject lock(m_mutex);
+    if (!IsActiveSource())
+      SetPowerStatus(CEC_POWER_STATUS_STANDBY);
+
     CLibCEC::AddLog(CEC_LOG_NOTICE, "<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, ToString(m_powerStatus));
     state = m_powerStatus;
   }
@@ -938,14 +926,12 @@ bool CCECBusDevice::ActivateSource(void)
 
 void CCECBusDevice::HandlePoll(cec_logical_address iDestination)
 {
-  CLockObject lock(m_mutex);
   CLibCEC::AddLog(CEC_LOG_DEBUG, "<< POLL: %s (%x) -> %s (%x)", ToString(m_iLogicalAddress), m_iLogicalAddress, ToString(iDestination), iDestination);
   m_bAwaitingReceiveFailed = true;
 }
 
 bool CCECBusDevice::HandleReceiveFailed(void)
 {
-  CLockObject lock(m_mutex);
   bool bReturn = m_bAwaitingReceiveFailed;
   m_bAwaitingReceiveFailed = false;
   return bReturn;