From: Lars Op den Kamp Date: Thu, 2 Aug 2012 15:47:09 +0000 (+0200) Subject: cec: wait until the commandhandler is replaced before registering a client, so we... X-Git-Tag: upstream/2.2.0~1^2~19^2^2~8 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=9b0a148b87b7e7e91699ba687fabd153398b4f0c cec: wait until the commandhandler is replaced before registering a client, so we don't register a client and replace it directly afterwards if the tv doesn't support the device type --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index db6f8a1..6461ca9 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -670,8 +670,14 @@ bool CCECProcessor::RegisterClient(CCECClient *client) tvVendor = tv->GetVendorId(CECDEVICE_UNREGISTERED); else if (m_communication->SupportsSourceLogicalAddress(CECDEVICE_FREEUSE)) tvVendor = tv->GetVendorId(CECDEVICE_FREEUSE); - if (tvVendor != CEC_VENDOR_UNKNOWN) - tv->ReplaceHandler(false); + + // 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));