From 9b0a148b87b7e7e91699ba687fabd153398b4f0c Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 2 Aug 2012 17:47:09 +0200 Subject: [PATCH] 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 --- src/lib/CECProcessor.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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)); -- 2.34.1