X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2FCECProcessor.cpp;h=88795e92b9dde65123abe66f6b4de546371b9759;hb=fce3d4acbadffe3dacbf3d49a77f685ef8e82c02;hp=76c2465fb2dd74419822d63cf5991e4c4814af95;hpb=a38292a3c2ec93a21d74da778516276e92d431c0;p=deb_libcec.git diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 76c2465..88795e9 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -62,7 +62,8 @@ CCECProcessor::CCECProcessor(CLibCEC *libcec) : m_libcec(libcec), m_iStandardLineTimeout(3), m_iRetryLineTimeout(3), - m_iLastTransmission(0) + m_iLastTransmission(0), + m_bMonitor(true) { m_busDevices = new CCECDeviceMap(this); } @@ -665,10 +666,19 @@ bool CCECProcessor::RegisterClient(CCECClient *client) // ensure that we know the vendor id of the TV CCECBusDevice *tv = GetTV(); + cec_vendor_id tvVendor = CEC_VENDOR_UNKNOWN; if (m_communication->SupportsSourceLogicalAddress(CECDEVICE_UNREGISTERED)) - tv->GetVendorId(CECDEVICE_UNREGISTERED); + tvVendor = tv->GetVendorId(CECDEVICE_UNREGISTERED); else if (m_communication->SupportsSourceLogicalAddress(CECDEVICE_FREEUSE)) - tv->GetVendorId(CECDEVICE_FREEUSE); + tvVendor = tv->GetVendorId(CECDEVICE_FREEUSE); + + // wait until the handler is replaced, to avoid double registrations + if (tvVendor != CEC_VENDOR_UNKNOWN && + CCECCommandHandler::HasSpecificHandler(tvVendor)) + { + while (!tv->ReplaceHandler(false)) + CEvent::Sleep(5); + } // get the configuration from the client m_libcec->AddLog(CEC_LOG_NOTICE, "registering new CEC client - v%s", ToString((cec_client_version)configuration.clientVersion)); @@ -791,7 +801,7 @@ bool CCECProcessor::UnregisterClient(CCECClient *client) if (SetLogicalAddresses(addresses)) { // no more clients left, disable controlled mode - if (addresses.IsEmpty()) + if (addresses.IsEmpty() && !m_bMonitor) m_communication->SetControlledMode(false); return true; @@ -864,3 +874,13 @@ bool CCECProcessor::IsRunningLatestFirmware(void) m_communication->IsRunningLatestFirmware() : true; } + +void CCECProcessor::SwitchMonitoring(bool bSwitchTo) +{ + { + CLockObject lock(m_mutex); + m_bMonitor = bSwitchTo; + } + if (bSwitchTo) + UnregisterClients(); +}