cec: make SetStreamPath() thread safe. bugzid: 19
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index 1fca4a513f04ce99073210d31c0586e806a8374e..e46e82df9dff67b300eeb9f6b96672563bc781dc 100644 (file)
@@ -216,7 +216,7 @@ cec_power_status CCECBusDevice::GetPowerStatus(void)
   return m_powerStatus;
 }
 
-const cec_vendor_id CCECBusDevice::GetVendorId(void)
+cec_vendor_id CCECBusDevice::GetVendorId(void)
 {
   if (m_vendor == CEC_VENDOR_UNKNOWN)
   {
@@ -283,6 +283,24 @@ void CCECBusDevice::SetMenuState(const cec_menu_state state)
   }
 }
 
+void CCECBusDevice::SetInactiveDevice(void)
+{
+  CLockObject lock(&m_mutex);
+  m_bActiveSource = false;
+}
+
+void CCECBusDevice::SetActiveDevice(void)
+{
+  CLockObject lock(&m_mutex);
+
+  for (int iPtr = 0; iPtr < 16; iPtr++)
+    if (iPtr != m_iLogicalAddress)
+      m_processor->m_busDevices[iPtr]->SetInactiveDevice();
+
+  m_bActiveSource = true;
+  m_powerStatus   = CEC_POWER_STATUS_ON;
+}
+
 void CCECBusDevice::SetPhysicalAddress(uint16_t iNewAddress)
 {
   if (iNewAddress > 0)