cec: make SetStreamPath() thread safe. bugzid: 19
[deb_libcec.git] / src / lib / devices / CECBusDevice.cpp
index d4d3814768cbe6828c8894fafe07a6571ce24b2f..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)
@@ -535,7 +553,7 @@ bool CCECBusDevice::TransmitVendorID(cec_logical_address dest)
     AddLog(CEC_LOG_NOTICE, strLog);
 
     cec_command command;
-    cec_command::Format(command, m_iLogicalAddress, dest, CEC_OPCODE_GIVE_DEVICE_VENDOR_ID);
+    cec_command::Format(command, m_iLogicalAddress, CECDEVICE_BROADCAST, CEC_OPCODE_DEVICE_VENDOR_ID);
 
     command.parameters.PushBack((uint8_t) (((uint64_t)m_vendor >> 16) & 0xFF));
     command.parameters.PushBack((uint8_t) (((uint64_t)m_vendor >> 8) & 0xFF));