From 446c0cfc3e477a36a63dcd0af3d3414374d751dc Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Thu, 29 Dec 2011 02:44:30 +0100 Subject: [PATCH] cec: add an 'expectedResponse' parameter to CCECCommandHandler::Transmit() --- src/lib/implementations/CECCommandHandler.cpp | 10 +++++++--- src/lib/implementations/CECCommandHandler.h | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) 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; }; -- 2.34.1