X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdevices%2FCECBusDevice.cpp;h=1f612c4b551601fa38deaa2b85509951d0e7188a;hb=5d355340846c8fa87486dd85d817405c9619b544;hp=1793cc4c5af3431a42b07836908f85eee7b8ec55;hpb=fe6f8e370bff46ba50defc31698f369763c68455;p=deb_libcec.git diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index 1793cc4..1f612c4 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -84,6 +84,9 @@ bool CCECBusDevice::HandleCommand(const cec_command &command) { CLockObject lock(&m_writeMutex); m_iLastActive = GetTimeMs(); + + if (m_deviceStatus != CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC) + m_deviceStatus = CEC_DEVICE_STATUS_PRESENT; } /* handle the command */ @@ -191,7 +194,8 @@ cec_menu_language &CCECBusDevice::GetMenuLanguage(bool bUpdate /* = false */) bool CCECBusDevice::RequestMenuLanguage(void) { bool bReturn(false); - if (!MyLogicalAddressContains(m_iLogicalAddress)) + if (!MyLogicalAddressContains(m_iLogicalAddress) && + !IsUnsupportedFeature(CEC_OPCODE_GET_MENU_LANGUAGE)) { CStdString strLog; strLog.Format("<< requesting menu language of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); @@ -225,7 +229,8 @@ CStdString CCECBusDevice::GetOSDName(bool bUpdate /* = false */) bool CCECBusDevice::RequestOSDName(void) { bool bReturn(false); - if (!MyLogicalAddressContains(m_iLogicalAddress)) + if (!MyLogicalAddressContains(m_iLogicalAddress) && + !IsUnsupportedFeature(CEC_OPCODE_GIVE_OSD_NAME)) { CStdString strLog; strLog.Format("<< requesting OSD name of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); @@ -274,7 +279,8 @@ cec_power_status CCECBusDevice::GetPowerStatus(bool bUpdate /* = false */) bool CCECBusDevice::RequestPowerStatus(void) { bool bReturn(false); - if (!MyLogicalAddressContains(m_iLogicalAddress)) + if (!MyLogicalAddressContains(m_iLogicalAddress) && + !IsUnsupportedFeature(CEC_OPCODE_GIVE_DEVICE_POWER_STATUS)) { CStdString strLog; strLog.Format("<< requesting power status of '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); @@ -431,19 +437,24 @@ void CCECBusDevice::SetMenuState(const cec_menu_state state) } } -void CCECBusDevice::SetInactiveDevice(void) +void CCECBusDevice::SetInactiveSource(void) { - CLockObject lock(&m_writeMutex); - m_bActiveSource = false; + { + CLockObject lock(&m_writeMutex); + m_bActiveSource = false; + } + + if (MyLogicalAddressContains(m_iLogicalAddress)) + SetPowerStatus(CEC_POWER_STATUS_STANDBY); } -void CCECBusDevice::SetActiveDevice(void) +void CCECBusDevice::SetActiveSource(void) { CLockObject lock(&m_writeMutex); for (int iPtr = 0; iPtr < 16; iPtr++) if (iPtr != m_iLogicalAddress) - m_processor->m_busDevices[iPtr]->SetInactiveDevice(); + m_processor->m_busDevices[iPtr]->SetInactiveSource(); m_bActiveSource = true; m_powerStatus = CEC_POWER_STATUS_ON; @@ -580,7 +591,7 @@ bool CCECBusDevice::SetVendorId(uint64_t iVendorId, bool bInitHandler /* = true } } - if (bVendorChanged && bInitHandler) + if (bVendorChanged && bInitHandler && m_handler->GetVendorId() != CEC_VENDOR_UNKNOWN) m_handler->InitHandler(); CStdString strLog; @@ -681,11 +692,15 @@ bool CCECBusDevice::TransmitOSDName(cec_logical_address dest) bool CCECBusDevice::TransmitOSDString(cec_logical_address dest, cec_display_control duration, const char *strMessage) { - CStdString strLog; - strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage); - AddLog(CEC_LOG_NOTICE, strLog.c_str()); + if (!IsUnsupportedFeature(CEC_OPCODE_SET_OSD_STRING)) + { + CStdString strLog; + strLog.Format("<< %s (%X) -> %s (%X): display OSD message '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(dest), dest, strMessage); + AddLog(CEC_LOG_NOTICE, strLog.c_str()); - return m_handler->TransmitOSDString(m_iLogicalAddress, dest, duration, strMessage); + return m_handler->TransmitOSDString(m_iLogicalAddress, dest, duration, strMessage); + } + return false; } bool CCECBusDevice::TransmitPhysicalAddress(void) @@ -780,13 +795,23 @@ bool CCECBusDevice::TransmitVendorID(cec_logical_address dest, bool bSendAbort / } } -bool CCECBusDevice::TransmitKeypress(cec_user_control_code key) +bool CCECBusDevice::TransmitKeypress(cec_user_control_code key, bool bWait /* = true */) +{ + return m_handler->TransmitKeypress(m_processor->GetLogicalAddress(), m_iLogicalAddress, key, bWait); +} + +bool CCECBusDevice::TransmitKeyRelease(bool bWait /* = true */) +{ + return m_handler->TransmitKeyRelease(m_processor->GetLogicalAddress(), m_iLogicalAddress, bWait); +} + +bool CCECBusDevice::IsUnsupportedFeature(cec_opcode opcode) const { - return m_handler->TransmitKeypress(m_processor->GetLogicalAddress(), m_iLogicalAddress, key); + return m_unsupportedFeatures.find(opcode) != m_unsupportedFeatures.end(); } -bool CCECBusDevice::TransmitKeyRelease(void) +void CCECBusDevice::SetUnsupportedFeature(cec_opcode opcode) { - return m_handler->TransmitKeyRelease(m_processor->GetLogicalAddress(), m_iLogicalAddress); + m_unsupportedFeatures.insert(opcode); } //@}