X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Flib%2Fdevices%2FCECBusDevice.cpp;h=3638453125809c92ef2383e4f77cad62202ff7af;hb=6bbfc3f7460c5806ffd80834b3c3c68e0738a2d5;hp=ceb311d77b731fca1b09dad283ad1f23aa57a900;hpb=9fc1bdd32ebb03b2854533dec43eb947299c674c;p=deb_libcec.git diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index ceb311d..3638453 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -117,11 +117,20 @@ bool CCECBusDevice::PowerOn(void) GetVendorId(); // ensure that we got the vendor id, because the implementations vary per vendor MarkBusy(); - CLibCEC::AddLog(CEC_LOG_NOTICE, "<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); - if (m_handler->PowerOn(GetMyLogicalAddress(), m_iLogicalAddress)) + cec_power_status currentStatus = GetPowerStatus(false); + if (currentStatus != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON && + currentStatus != CEC_POWER_STATUS_ON) { - SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); - bReturn = true; + CLibCEC::AddLog(CEC_LOG_NOTICE, "<< powering on '%s' (%X)", GetLogicalAddressName(), m_iLogicalAddress); + if (m_handler->PowerOn(GetMyLogicalAddress(), m_iLogicalAddress)) + { + SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); + bReturn = true; + } + } + else + { + CLibCEC::AddLog(CEC_LOG_NOTICE, "'%s' (%X) is already '%s'", GetLogicalAddressName(), m_iLogicalAddress, ToString(currentStatus)); } MarkReady(); @@ -141,11 +150,12 @@ bool CCECBusDevice::Standby(void) //@{ cec_version CCECBusDevice::GetCecVersion(bool bUpdate /* = false */) { + bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT); bool bRequestUpdate(false); { CLockObject lock(m_mutex); - bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && - (bUpdate || m_cecVersion == CEC_VERSION_UNKNOWN)); + bRequestUpdate = bIsPresent && + (bUpdate || m_cecVersion == CEC_VERSION_UNKNOWN); } if (bRequestUpdate) @@ -177,10 +187,11 @@ const char* CCECBusDevice::GetLogicalAddressName(void) const cec_menu_language &CCECBusDevice::GetMenuLanguage(bool bUpdate /* = false */) { + bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT); bool bRequestUpdate(false); { CLockObject lock(m_mutex); - bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && + bRequestUpdate = (bIsPresent && (bUpdate || !strcmp(m_menuLanguage.language, "???"))); } @@ -224,12 +235,13 @@ uint16_t CCECBusDevice::GetMyPhysicalAddress(void) const CStdString CCECBusDevice::GetOSDName(bool bUpdate /* = false */) { + bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT); bool bRequestUpdate(false); { CLockObject lock(m_mutex); - bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && + bRequestUpdate = bIsPresent && (bUpdate || m_strDeviceName.Equals(ToString(m_iLogicalAddress))) && - m_type != CEC_DEVICE_TYPE_TV); + m_type != CEC_DEVICE_TYPE_TV; } if (bRequestUpdate) @@ -256,11 +268,12 @@ bool CCECBusDevice::RequestOSDName(void) uint16_t CCECBusDevice::GetPhysicalAddress(bool bUpdate /* = false */) { + bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT); bool bRequestUpdate(false); { CLockObject lock(m_mutex); - bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && - (m_iPhysicalAddress == 0xFFFF || bUpdate)); + bRequestUpdate = bIsPresent && + (m_iPhysicalAddress == 0xFFFF || bUpdate); } if (bRequestUpdate && !RequestPhysicalAddress()) @@ -286,10 +299,11 @@ bool CCECBusDevice::RequestPhysicalAddress(void) cec_power_status CCECBusDevice::GetPowerStatus(bool bUpdate /* = false */) { + bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT); bool bRequestUpdate(false); { CLockObject lock(m_mutex); - bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && + bRequestUpdate = (bIsPresent && (bUpdate || m_powerStatus == CEC_POWER_STATUS_UNKNOWN || m_powerStatus == CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON || m_powerStatus == CEC_POWER_STATUS_IN_TRANSITION_ON_TO_STANDBY || @@ -320,10 +334,11 @@ bool CCECBusDevice::RequestPowerStatus(void) cec_vendor_id CCECBusDevice::GetVendorId(bool bUpdate /* = false */) { + bool bIsPresent(GetStatus() == CEC_DEVICE_STATUS_PRESENT); bool bRequestUpdate(false); { CLockObject lock(m_mutex); - bRequestUpdate = (GetStatus() == CEC_DEVICE_STATUS_PRESENT && + bRequestUpdate = (bIsPresent && (bUpdate || m_vendor == CEC_VENDOR_UNKNOWN)); } @@ -528,6 +543,8 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) switch (newStatus) { case CEC_DEVICE_STATUS_UNKNOWN: + if (m_deviceStatus != newStatus) + CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'unknown'", ToString(m_iLogicalAddress)); m_iStreamPath = 0; m_powerStatus = CEC_POWER_STATUS_UNKNOWN; m_vendor = CEC_VENDOR_UNKNOWN; @@ -538,6 +555,8 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) m_deviceStatus = newStatus; break; case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC: + if (m_deviceStatus != newStatus) + CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'handled by libCEC'", ToString(m_iLogicalAddress)); m_iStreamPath = 0; m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON; m_vendor = CEC_VENDOR_UNKNOWN; @@ -548,7 +567,13 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) m_deviceStatus = newStatus; break; case CEC_DEVICE_STATUS_PRESENT: + if (m_deviceStatus != newStatus) + CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'present'", ToString(m_iLogicalAddress)); + m_deviceStatus = newStatus; + break; case CEC_DEVICE_STATUS_NOT_PRESENT: + if (m_deviceStatus != newStatus) + CLibCEC::AddLog(CEC_LOG_DEBUG, "device status of %s changed into 'not present'", ToString(m_iLogicalAddress)); m_deviceStatus = newStatus; break; }