X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fdevices%2FCECBusDevice.cpp;h=9e9145c0e76af2f4b2abcd70c60182f189166722;hb=2b2767288398d6cdcbe1201a8b52ef515a5f6591;hp=a2ce01d1aeaeabcec1edd89abe412563328c2dde;hpb=3e61b35032f69fb93869796e2f985de8cff2ae33;p=deb_libcec.git diff --git a/src/lib/devices/CECBusDevice.cpp b/src/lib/devices/CECBusDevice.cpp index a2ce01d..9e9145c 100644 --- a/src/lib/devices/CECBusDevice.cpp +++ b/src/lib/devices/CECBusDevice.cpp @@ -513,6 +513,12 @@ void CCECBusDevice::SetInactiveSource(void) void CCECBusDevice::SetActiveSource(void) { CLockObject lock(&m_mutex); + if (!m_bActiveSource) + { + CStdString strLog; + strLog.Format("making %s (%x) the active source", GetLogicalAddressName(), m_iLogicalAddress); + AddLog(CEC_LOG_DEBUG, strLog); + } for (int iPtr = 0; iPtr < 16; iPtr++) if (iPtr != m_iLogicalAddress) @@ -627,38 +633,42 @@ bool CCECBusDevice::ReplaceHandler(bool bActivateSource /* = true */) if (m_vendor != m_handler->GetVendorId()) { - CStdString strLog; - if (m_handler->InUse()) + if (CCECCommandHandler::HasSpecificHandler(m_vendor)) { - strLog.Format("handler for device '%s' (%x) is being used. not replacing the command handler", GetLogicalAddressName(), GetLogicalAddress()); - m_processor->AddLog(CEC_LOG_DEBUG, strLog); - return false; - } + CStdString strLog; + if (m_handler->InUse()) + { + strLog.Format("handler for device '%s' (%x) is being used. not replacing the command handler", GetLogicalAddressName(), GetLogicalAddress()); + m_processor->AddLog(CEC_LOG_DEBUG, strLog); + return false; + } - strLog.Format("replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress()); - m_processor->AddLog(CEC_LOG_DEBUG, strLog); - delete m_handler; + strLog.Format("replacing the command handler for device '%s' (%x)", GetLogicalAddressName(), GetLogicalAddress()); + m_processor->AddLog(CEC_LOG_DEBUG, strLog); + 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; - } + 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->InitHandler(); + m_handler->SetVendorId(m_vendor); + m_handler->InitHandler(); - if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised()) - m_handler->ActivateSource(); + if (bActivateSource && m_processor->GetLogicalAddresses().IsSet(m_iLogicalAddress) && m_processor->IsInitialised() && IsActiveSource()) + m_handler->ActivateSource(); + } } return true;