From: Lars Op den Kamp Date: Wed, 5 Sep 2012 13:05:19 +0000 (+0200) Subject: stall outgoing messages when the logical address was lost, until we got a new address X-Git-Tag: upstream/2.2.0~1^2~18^2^2~8 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=6f99b2bb55d7c7659b39bda7fe54c6c3e33611ec;p=deb_libcec.git stall outgoing messages when the logical address was lost, until we got a new address --- diff --git a/src/lib/CECProcessor.cpp b/src/lib/CECProcessor.cpp index 8df3884..9d49640 100644 --- a/src/lib/CECProcessor.cpp +++ b/src/lib/CECProcessor.cpp @@ -64,13 +64,15 @@ CCECProcessor::CCECProcessor(CLibCEC *libcec) : m_iRetryLineTimeout(3), m_iLastTransmission(0), m_bMonitor(true), - m_addrAllocator(NULL) + m_addrAllocator(NULL), + m_bStallCommunication(false) { m_busDevices = new CCECDeviceMap(this); } CCECProcessor::~CCECProcessor(void) { + m_bStallCommunication = false; DELETE_AND_NULL(m_addrAllocator); Close(); DELETE_AND_NULL(m_busDevices); @@ -412,6 +414,9 @@ bool CCECProcessor::Transmit(const cec_command &data, bool bIsReply) } } + // wait until we finished allocating a new LA if it got lost + while (m_bStallCommunication) Sleep(5); + { CLockObject lock(m_mutex); m_iLastTransmission = GetTimeMs(); @@ -686,6 +691,9 @@ bool CCECProcessor::AllocateLogicalAddresses(CCECClient* client) // set the new ackmask SetLogicalAddresses(GetLogicalAddresses()); + // resume outgoing communication + m_bStallCommunication = false; + return true; } @@ -918,6 +926,9 @@ void CCECProcessor::SwitchMonitoring(bool bSwitchTo) void CCECProcessor::HandleLogicalAddressLost(cec_logical_address oldAddress) { + // stall outgoing messages until we know our new LA + m_bStallCommunication = true; + m_libcec->AddLog(CEC_LOG_NOTICE, "logical address %x was taken by another device, allocating a new address", oldAddress); CCECClient* client = GetClient(oldAddress); if (client) diff --git a/src/lib/CECProcessor.h b/src/lib/CECProcessor.h index 6ad60c5..e1f6d68 100644 --- a/src/lib/CECProcessor.h +++ b/src/lib/CECProcessor.h @@ -170,5 +170,6 @@ namespace CEC std::map m_clients; bool m_bMonitor; CCECAllocateLogicalAddress* m_addrAllocator; + bool m_bStallCommunication; }; };