From: Lars Op den Kamp Date: Thu, 29 Dec 2011 01:44:30 +0000 (+0100) Subject: cec: add an 'expectedResponse' parameter to CCECCommandHandler::Transmit() X-Git-Tag: upstream/2.2.0~1^2~43^2~3 X-Git-Url: https://git.piment-noir.org/?p=deb_libcec.git;a=commitdiff_plain;h=446c0cfc3e477a36a63dcd0af3d3414374d751dc cec: add an 'expectedResponse' parameter to CCECCommandHandler::Transmit() --- diff --git a/src/lib/implementations/CECCommandHandler.cpp b/src/lib/implementations/CECCommandHandler.cpp index c72155c..91a60a3 100644 --- a/src/lib/implementations/CECCommandHandler.cpp +++ b/src/lib/implementations/CECCommandHandler.cpp @@ -46,7 +46,8 @@ CCECCommandHandler::CCECCommandHandler(CCECBusDevice *busDevice) : m_iTransmitWait(CEC_DEFAULT_TRANSMIT_WAIT), m_iTransmitRetries(CEC_DEFAULT_TRANSMIT_RETRIES), m_bHandlerInited(false), - m_iUseCounter(0) + m_iUseCounter(0), + m_expectedResponse(CEC_OPCODE_NONE) { } @@ -178,7 +179,9 @@ bool CCECCommandHandler::HandleCommand(const cec_command &command) if (bHandled && !bHandlerChanged) { CLockObject lock(&m_receiveMutex); - m_condition.Signal(); + if (m_expectedResponse == CEC_OPCODE_NONE || + m_expectedResponse == command.opcode) + m_condition.Signal(); } MarkReady(); @@ -932,7 +935,7 @@ bool CCECCommandHandler::TransmitKeyRelease(const cec_logical_address iInitiator return Transmit(command, bWait); } -bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* = true */) +bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* = true */, cec_opcode expectedResponse /* = CEC_OPCODE_NONE */) { bool bReturn(false); command.transmit_timeout = m_iTransmitTimeout; @@ -944,6 +947,7 @@ bool CCECCommandHandler::Transmit(cec_command &command, bool bExpectResponse /* ++m_iUseCounter; while (!bReturn && ++iTries <= iMaxTries) { + m_expectedResponse = expectedResponse; if (m_processor->Transmit(command)) { m_processor->AddLog(CEC_LOG_DEBUG, "command transmitted"); diff --git a/src/lib/implementations/CECCommandHandler.h b/src/lib/implementations/CECCommandHandler.h index c84424f..c99d569 100644 --- a/src/lib/implementations/CECCommandHandler.h +++ b/src/lib/implementations/CECCommandHandler.h @@ -128,7 +128,7 @@ namespace CEC virtual bool SetVendorId(const cec_command &command); virtual void SetPhysicalAddress(cec_logical_address iAddress, uint16_t iNewAddress); - virtual bool Transmit(cec_command &command, bool bExpectResponse = true); + virtual bool Transmit(cec_command &command, bool bExpectResponse = true, cec_opcode expectedResponse = CEC_OPCODE_NONE); CCECBusDevice *m_busDevice; CCECProcessor *m_processor; @@ -137,6 +137,7 @@ namespace CEC int8_t m_iTransmitRetries; bool m_bHandlerInited; uint8_t m_iUseCounter; + cec_opcode m_expectedResponse; CMutex m_receiveMutex; CCondition m_condition; };