+ CheckVendorIdRequested(initiator);
+ RequestPowerStatus(initiator, bUpdate);
+ }
+
+ CLockObject lock(m_mutex);
+ return m_powerStatus;
+}
+
+void CCECBusDevice::SetPowerStatus(const cec_power_status powerStatus)
+{
+ CLockObject lock(m_mutex);
+ if (m_powerStatus != powerStatus)
+ {
+ m_iLastPowerStateUpdate = GetTimeMs();
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_powerStatus), ToString(powerStatus));
+ m_powerStatus = powerStatus;
+ }
+}
+
+void CCECBusDevice::OnImageViewOnSent(bool bSentByLibCEC)
+{
+ CLockObject lock(m_mutex);
+ m_bImageViewOnSent = bSentByLibCEC;
+
+ if (m_powerStatus != CEC_POWER_STATUS_ON && m_powerStatus != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON)
+ {
+ m_iLastPowerStateUpdate = GetTimeMs();
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "%s (%X): power status changed from '%s' to '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(m_powerStatus), ToString(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON));
+ m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON;
+ }
+}
+
+bool CCECBusDevice::ImageViewOnSent(void)
+{
+ CLockObject lock(m_mutex);
+ return m_bImageViewOnSent;
+}
+
+bool CCECBusDevice::RequestPowerStatus(const cec_logical_address initiator, bool bUpdate, bool bWaitForResponse /* = true */)
+{
+ bool bReturn(false);
+
+ if (!IsHandledByLibCEC() &&
+ !IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS))
+ {
+ MarkBusy();
+ bReturn = m_handler->TransmitRequestPowerStatus(initiator, m_iLogicalAddress, bUpdate, bWaitForResponse);
+ if (!bReturn)
+ SetPowerStatus(CEC_POWER_STATUS_UNKNOWN);
+ MarkReady();
+ }
+ return bReturn;
+}
+
+bool CCECBusDevice::TransmitPowerState(const cec_logical_address destination, bool bIsReply)
+{
+ cec_power_status state;
+ {
+ CLockObject lock(m_mutex);
+ LIB_CEC->AddLog(CEC_LOG_DEBUG, "<< %s (%X) -> %s (%X): %s", GetLogicalAddressName(), m_iLogicalAddress, ToString(destination), destination, ToString(m_powerStatus));
+ state = m_powerStatus;
+ }
+
+ MarkBusy();
+ bool bReturn = m_handler->TransmitPowerState(m_iLogicalAddress, destination, state, bIsReply);
+ MarkReady();
+ return bReturn;
+}
+
+cec_vendor_id CCECBusDevice::GetCurrentVendorId(void)
+{
+ CLockObject lock(m_mutex);
+ return m_vendor;
+}
+
+cec_vendor_id CCECBusDevice::GetVendorId(const cec_logical_address initiator, bool bUpdate /* = false */)
+{
+ bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT);
+ bool bRequestUpdate(false);
+ {
+ CLockObject lock(m_mutex);
+ bRequestUpdate = (bIsPresent &&
+ (bUpdate || m_vendor == CEC_VENDOR_UNKNOWN));
+ }
+
+ if (bRequestUpdate)
+ RequestVendorId(initiator);
+
+ CLockObject lock(m_mutex);
+ return m_vendor;
+}
+
+const char *CCECBusDevice::GetVendorName(const cec_logical_address initiator, bool bUpdate /* = false */)
+{
+ return ToString(GetVendorId(initiator, bUpdate));
+}
+
+bool CCECBusDevice::SetVendorId(uint64_t iVendorId)
+{
+ bool bVendorChanged(false);
+
+ {
+ CLockObject lock(m_mutex);
+ bVendorChanged = (m_vendor != (cec_vendor_id)iVendorId);