fixed - updating the device status after a poll was broken and could reset the status...
authorLars Op den Kamp <lars@opdenkamp.eu>
Mon, 15 Oct 2012 10:13:09 +0000 (12:13 +0200)
committerLars Op den Kamp <lars@opdenkamp.eu>
Mon, 15 Oct 2012 10:13:09 +0000 (12:13 +0200)
src/lib/CECClient.cpp
src/lib/CECProcessor.cpp
src/lib/devices/CECBusDevice.cpp
src/lib/devices/CECBusDevice.h

index f85a53c2a6cae81bae6d17134ffa6b2fc3313f6e..a5a960ea36b00e4c804c3362b088e855550fdde3 100644 (file)
@@ -1255,7 +1255,7 @@ bool CCECClient::PollDevice(const cec_logical_address iAddress)
   CCECBusDevice *primary = GetPrimaryDevice();
   // poll the destination, with the primary as source
   if (primary)
-    return primary->TransmitPoll(iAddress, false);
+    return primary->TransmitPoll(iAddress, true);
 
   return m_processor ? m_processor->PollDevice(iAddress) : false;
 }
index cc6adda8bf4826bfb0c28f63975bae66e60bfd94..73c921d8120f68c0ffff4f440e6e66e2e0443b07 100644 (file)
@@ -315,11 +315,11 @@ bool CCECProcessor::PollDevice(cec_logical_address iAddress)
   CCECBusDevice *primary = GetPrimaryDevice();
   // poll the destination, with the primary as source
   if (primary)
-    return primary->TransmitPoll(iAddress, false);
+    return primary->TransmitPoll(iAddress, true);
 
   CCECBusDevice *device = m_busDevices->At(CECDEVICE_UNREGISTERED);
   if (device)
-    return device->TransmitPoll(iAddress, false);
+    return device->TransmitPoll(iAddress, true);
 
   return false;
 }
index b42230dd41201913a0331e18f3b9c57aee874ec7..a33a9c3ede3b5e152694664b7b5327a09f4dc376 100644 (file)
@@ -741,7 +741,8 @@ cec_bus_device_status CCECBusDevice::GetStatus(bool bForcePoll /* = false */, bo
     CLockObject lock(m_mutex);
     status = m_deviceStatus;
     bNeedsPoll = !bSuppressPoll &&
-        (bForcePoll || m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN);
+        (bForcePoll || m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN) &&
+        m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC;
   }
 
   if (bNeedsPoll)
@@ -782,6 +783,7 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus, cec_v
       if (m_deviceStatus != newStatus)
         LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): device status changed into 'present'", GetLogicalAddressName(), m_iLogicalAddress);
       m_deviceStatus = newStatus;
+      m_iLastActive = GetTimeMs();
       break;
     case CEC_DEVICE_STATUS_NOT_PRESENT:
       if (m_deviceStatus != newStatus)
@@ -819,7 +821,7 @@ void CCECBusDevice::ResetDeviceStatus(void)
   m_deviceStatus = CEC_DEVICE_STATUS_UNKNOWN;
 }
 
-bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bIsReply)
+bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bUpdateDeviceStatus)
 {
   bool bReturn(false);
   cec_logical_address destination(dest);
@@ -832,17 +834,11 @@ bool CCECBusDevice::TransmitPoll(const cec_logical_address dest, bool bIsReply)
 
   MarkBusy();
   LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< %s (%X) -> %s (%X): POLL", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest);
-  bReturn = m_handler->TransmitPoll(m_iLogicalAddress, destination, bIsReply);
+  bReturn = m_handler->TransmitPoll(m_iLogicalAddress, destination, false);
   LIB_CEC->AddLog(CEC_LOG_DEBUG, bReturn ? ">> POLL sent" : ">> POLL not sent");
 
-  CLockObject lock(m_mutex);
-  if (bReturn)
-  {
-    m_iLastActive = GetTimeMs();
-    SetDeviceStatus(CEC_DEVICE_STATUS_PRESENT);
-  }
-  else
-    SetDeviceStatus(CEC_DEVICE_STATUS_NOT_PRESENT);
+  if (bUpdateDeviceStatus)
+    destDevice->SetDeviceStatus(bReturn ? CEC_DEVICE_STATUS_PRESENT : CEC_DEVICE_STATUS_NOT_PRESENT);
 
   MarkReady();
   return bReturn;
index d208fd933d44bd94b7e6f6c944cff79e2e1fbdb8..fad7191e6be216ac2bd83c7898681acb5e8892c0 100644 (file)
@@ -206,7 +206,7 @@ namespace CEC
     virtual cec_bus_device_status GetStatus(bool bForcePoll = false, bool bSuppressPoll = false);
     virtual void                  SetDeviceStatus(const cec_bus_device_status newStatus, cec_version libCECSpecVersion = CEC_VERSION_1_4);
     virtual void                  ResetDeviceStatus(void);
-    virtual bool                  TransmitPoll(const cec_logical_address destination, bool bIsReply);
+    virtual bool                  TransmitPoll(const cec_logical_address destination, bool bUpdateDeviceStatus);
     virtual void                  HandlePoll(const cec_logical_address destination);
     virtual void                  HandlePollFrom(const cec_logical_address initiator);
     virtual bool                  HandleReceiveFailed(void);