X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdevices%2FCECBusDevice.cpp;h=f60b171f93adbda8d5ed71b60cd329ff00760c4e;hb=871934d36a072fbb36fea8949b09158697ceb41a;hp=c68fc0584b9ca744244965c26f175c06804df774;hpb=1344fd1a7e86aa1bbc8b1e78eed6be8cd59c4b3b;p=deb_libcec.git diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index c68fc05..f60b171 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -119,9 +119,9 @@ bool CCECBusDevice::PowerOn(void) if (m_handler->TransmitImageViewOn(GetMyLogicalAddress(), m_iLogicalAddress)) { { - CLockObject lock(m_mutex); +// CLockObject lock(m_mutex); // m_powerStatus = CEC_POWER_STATUS_UNKNOWN; - m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON; + SetPowerStatus(CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON); } // cec_power_status status = GetPowerStatus(); // if (status == CEC_POWER_STATUS_STANDBY || status == CEC_POWER_STATUS_UNKNOWN) @@ -500,7 +500,7 @@ void CCECBusDevice::SetActiveSource(void) m_processor->m_busDevices[iPtr]->SetInactiveSource(); m_bActiveSource = true; - m_powerStatus = CEC_POWER_STATUS_ON; + SetPowerStatus(CEC_POWER_STATUS_ON); } bool CCECBusDevice::TryLogicalAddress(void) @@ -538,7 +538,7 @@ void CCECBusDevice::SetDeviceStatus(const cec_bus_device_status newStatus) break; case CEC_DEVICE_STATUS_HANDLED_BY_LIBCEC: m_iStreamPath = 0; - m_powerStatus = CEC_POWER_STATUS_ON; + m_powerStatus = CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON; m_vendor = CEC_VENDOR_UNKNOWN; m_menuState = CEC_MENU_STATE_ACTIVATED; m_bActiveSource = false; @@ -605,45 +605,57 @@ void CCECBusDevice::MarkReady(void) bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */) { - CTryLockObject lock(m_mutex); - if (!lock.IsLocked()) - return false; + bool bInitHandler(false); + { + CTryLockObject lock(m_mutex); + if (!lock.IsLocked()) + return false; - CLockObject handlerLock(m_handlerMutex); - if (m_iHandlerUseCount > 0) - return false; + CLockObject handlerLock(m_handlerMutex); + if (m_iHandlerUseCount > 0) + return false; - if (m_vendor != m_handler->GetVendorId()) - { - if (CCECCommandHandler::HasSpecificHandler(m_vendor)) - { - CLibCEC::AddLog(CEC_LOG_DEBUG, "replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress()); - delete m_handler; + MarkBusy(); - switch (m_vendor) + if (m_vendor != m_handler->GetVendorId()) + { + if (CCECCommandHandler::HasSpecificHandler(m_vendor)) { - case CEC_VENDOR_SAMSUNG: - m_handler = new CANCommandHandler(this); - break; - case CEC_VENDOR_LG: - m_handler = new CSLCommandHandler(this); - break; - case CEC_VENDOR_PANASONIC: - m_handler = new CVLCommandHandler(this); - break; - default: - m_handler = new CCECCommandHandler(this); - break; + CLibCEC::AddLog(CEC_LOG_DEBUG, "replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress()); + delete m_handler; + + switch (m_vendor) + { + case CEC_VENDOR_SAMSUNG: + m_handler = new CANCommandHandler(this); + break; + case CEC_VENDOR_LG: + m_handler = new CSLCommandHandler(this); + break; + case CEC_VENDOR_PANASONIC: + m_handler = new CVLCommandHandler(this); + break; + default: + m_handler = new CCECCommandHandler(this); + break; + } + + m_handler->SetVendorId(m_vendor); + bInitHandler = true; } + } + } - m_handler->SetVendorId(m_vendor); - m_handler->InitHandler(); + if (bInitHandler) + { + m_handler->InitHandler(); - if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised() && IsActiveSource()) - m_handler->ActivateSource(); - } + if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised() && IsActiveSource()) + m_handler->ActivateSource(); } + MarkReady(); + return true; } @@ -671,7 +683,7 @@ bool CCECBusDevice::TransmitActiveSource(void) { CLockObject lock(m_mutex); - if (m_powerStatus != CEC_POWER_STATUS_ON) + if (m_powerStatus != CEC_POWER_STATUS_ON && m_powerStatus != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON) CLibCEC::AddLog(CEC_LOG_DEBUG, "<< %s (%X) is not powered on", GetLogicalAddressName(), m_iLogicalAddress); else if (m_bActiveSource) { @@ -685,7 +697,6 @@ bool CCECBusDevice::TransmitActiveSource(void) if (bSendActiveSource) { MarkBusy(); - m_handler->TransmitImageViewOn(m_iLogicalAddress, CECDEVICE_TV); m_handler->TransmitActiveSource(m_iLogicalAddress, m_iPhysicalAddress); MarkReady(); return true; @@ -709,6 +720,23 @@ bool CCECBusDevice::TransmitCECVersion(cec_logical_address dest) return bReturn; } +bool CCECBusDevice::TransmitImageViewOn(void) +{ + { + CLockObject lock(m_mutex); + if (m_powerStatus != CEC_POWER_STATUS_ON && m_powerStatus != CEC_POWER_STATUS_IN_TRANSITION_STANDBY_TO_ON) + { + CLibCEC::AddLog(CEC_LOG_DEBUG, "<< %s (%X) is not powered on", GetLogicalAddressName(), m_iLogicalAddress); + return false; + } + } + + MarkBusy(); + m_handler->TransmitImageViewOn(m_iLogicalAddress, CECDEVICE_TV); + MarkReady(); + return true; +} + bool CCECBusDevice::TransmitInactiveSource(void) { uint16_t iPhysicalAddress;