cec: poll doesn't have an opcode. bugzid: 591
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index 33d472f7acc685f0adadbaf213b51fea867ac06f..429d73fbd162f137870f8c5ed3b479c7fbe80504 100644 (file)
@@ -88,7 +88,7 @@ bool CCECBusDevice::HandleCommand(const cec_command &command)
     m_iLastActive = GetTimeMs();
 
     /* don't call GetStatus() here, just read the value with the mutex locked */
-    if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC)
+    if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC && command.opcode_set == 1)
       m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
 
     MarkBusy();
@@ -470,7 +470,7 @@ cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */)
   if (bNeedsPoll)
   {
     bool bPollAcked(false);
-    if (bNeedsPoll || NeedsPoll())
+    if (bNeedsPoll && NeedsPoll())
       bPollAcked = m_processor->PollDevice(m_iLogicalAddress);
 
     status = bPollAcked ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT;
@@ -524,6 +524,8 @@ void CCECBusDevice::SetInactiveSource(void)
 {
   {
     CLockObject lock(m_mutex);
+    if (m_bActiveSource)
+      CLibCEC::AddLog(CEC_LOG_DEBUG, "marking %s (%X) as inactive source", GetLogicalAddressName(), m_iLogicalAddress);
     m_bActiveSource = false;
   }
 
@@ -901,7 +903,10 @@ bool CCECBusDevice::TransmitPowerState(cec_logical_address dest)
   {
     CLockObject lock(m_mutex);
     if (!IsActiveSource())
+    {
+      CLibCEC::AddLog(CEC_LOG_NOTICE, "power state requested of %s (%X), but we are not the active source. setting power state to standby", GetLogicalAddressName(), m_iLogicalAddress);
       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;