cec: store the status of a bus device: present, not present or handled by libcec
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index 1227f8d749c6515f193bcd64fd3bb3fce8042ffd..20fe43b33179b2bf9fd23d3a669ff9a1c50df339 100644 (file)
@@ -54,7 +54,8 @@ CCECBusDevice::CCECBusDevice(CCECProcessor *processor, cec_logical_address iLogi
   m_bActiveSource(false),
   m_iLastCommandSent(0),
   m_iLastActive(0),
-  m_cecVersion(CEC_VERSION_UNKNOWN)
+  m_cecVersion(CEC_VERSION_UNKNOWN),
+  m_deviceStatus(CEC_DEVICE_STATUS_UNKNOWN)
 {
   m_handler = new CCECCommandHandler(this);
 
@@ -240,6 +241,20 @@ bool CCECBusDevice::MyLogicalAddressContains(cec_logical_address address) const
   return m_processor->HasLogicalAddress(address);
 }
 
+cec_bus_device_status CCECBusDevice::GetStatus(void)
+{
+  CLockObject lock(&m_mutex);
+  if (m_deviceStatus == CEC_DEVICE_STATUS_UNKNOWN)
+  {
+    if (m_processor->PollDevice(m_iLogicalAddress))
+      m_deviceStatus = CEC_DEVICE_STATUS_PRESENT;
+    else
+      m_deviceStatus = CEC_DEVICE_STATUS_NOT_PRESENT;
+  }
+
+  return m_deviceStatus;
+}
+
 //@}
 
 /** @name Setters */