From 390b42d67f9c62486ee6d1b9fb57927c9cd4dafc Mon Sep 17 00:00:00 2001 From: Lars Op den Kamp Date: Mon, 3 Oct 2011 01:43:53 +0200 Subject: [PATCH] cec: removed timeout parameter from Transmit() --- include/CECExports.h | 2 +- include/CECExportsC.h | 5 ++--- include/CECExportsCpp.h | 2 +- src/lib/CECParser.cpp | 19 ++++++++++--------- src/lib/CECParser.h | 6 +++--- src/lib/CECParserC.cpp | 4 ++-- src/testclient/main.cpp | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/include/CECExports.h b/include/CECExports.h index 0aef25c..b5a3b5d 100644 --- a/include/CECExports.h +++ b/include/CECExports.h @@ -56,7 +56,7 @@ extern "C" { namespace CEC { #endif #define CEC_MIN_VERSION 2 - #define CEC_LIB_VERSION 2 + #define CEC_LIB_VERSION 3 #define CEC_SETTLE_DOWN_TIME 1000 typedef std::vector cec_frame; diff --git a/include/CECExportsC.h b/include/CECExportsC.h index f76e2f3..19706f4 100644 --- a/include/CECExportsC.h +++ b/include/CECExportsC.h @@ -158,13 +158,12 @@ extern DECLSPEC bool cec_get_next_command(cec_command *command); * @brief Transmit a frame on the CEC line. * @param data The frame to send. * @param bWaitForAck Wait for an ACK message for 1 second after this frame has been sent. - * @param iTimeout Timeout if the message could not be sent for this amount of ms. Does not influence the timeout of the wait for the ACK message. That timeout is specified by the CEC standard. * @return True when the data was sent and acked, false otherwise. */ #ifdef __cplusplus -extern DECLSPEC bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000); +extern DECLSPEC bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck = true); #else -extern DECLSPEC bool cec_transmit(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000); +extern DECLSPEC bool cec_transmit(const cec_frame &data, bool bWaitForAck = true); #endif /*! diff --git a/include/CECExportsCpp.h b/include/CECExportsCpp.h index 4f40bfe..a87c2d0 100644 --- a/include/CECExportsCpp.h +++ b/include/CECExportsCpp.h @@ -104,7 +104,7 @@ namespace CEC /*! * @see cec_transmit */ - virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000) = 0; + virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true) = 0; /*! * @see cec_set_logical_address diff --git a/src/lib/CECParser.cpp b/src/lib/CECParser.cpp index 5ac1d8e..4cbdd6c 100644 --- a/src/lib/CECParser.cpp +++ b/src/lib/CECParser.cpp @@ -48,6 +48,7 @@ using namespace CEC; using namespace std; #define CEC_MAX_RETRY 5 +#define CEC_BUTTON_TIMEOUT 500 /*! * ICECDevice implementation @@ -140,7 +141,7 @@ bool CCECParser::Process(void) while (m_bRunning) { cec_frame msg; - while (m_bRunning && m_communication->IsOpen() && m_communication->Read(msg, 500)) + while (m_bRunning && m_communication->IsOpen() && m_communication->Read(msg, CEC_BUTTON_TIMEOUT)) ParseMessage(msg); now = GetTimeMs(); @@ -165,7 +166,7 @@ bool CCECParser::Ping(void) PushEscaped(output, MSGCODE_PING); output.push_back(MSGEND); - if (!TransmitFormatted(output, false, (int64_t) 5000)) + if (!TransmitFormatted(output, false)) { AddLog(CEC_LOG_ERROR, "could not send ping command"); return false; @@ -188,7 +189,7 @@ bool CCECParser::StartBootloader(void) PushEscaped(output, MSGCODE_START_BOOTLOADER); output.push_back(MSGEND); - if (!TransmitFormatted(output, false, (int64_t) 5000)) + if (!TransmitFormatted(output, false)) { AddLog(CEC_LOG_ERROR, "could not start the bootloader"); return false; @@ -376,7 +377,7 @@ void CCECParser::BroadcastActiveSource(void) Transmit(frame); } -bool CCECParser::TransmitFormatted(const cec_frame &data, bool bWaitForAck /* = true */, int64_t iTimeout /* = 2000 */) +bool CCECParser::TransmitFormatted(const cec_frame &data, bool bWaitForAck /* = true */) { if (!m_communication || m_communication->Write(data) != data.size()) return false; @@ -391,7 +392,7 @@ bool CCECParser::TransmitFormatted(const cec_frame &data, bool bWaitForAck /* = return true; } -bool CCECParser::Transmit(const cec_frame &data, bool bWaitForAck /* = true */, int64_t iTimeout /* = 5000 */) +bool CCECParser::Transmit(const cec_frame &data, bool bWaitForAck /* = true */) { CStdString txStr = "transmit "; for (unsigned int i = 0; i < data.size(); i++) @@ -432,16 +433,16 @@ bool CCECParser::Transmit(const cec_frame &data, bool bWaitForAck /* = true */, output.push_back(MSGEND); } - return TransmitFormatted(output, bWaitForAck, iTimeout); + return TransmitFormatted(output, bWaitForAck); } -bool CCECParser::WaitForAck(int64_t iTimeout /* = 1000 */) +bool CCECParser::WaitForAck(int iTimeout /* = 1000 */) { bool bGotAck(false); bool bError(false); int64_t iNow = GetTimeMs(); - int64_t iTargetTime = iNow + iTimeout; + int64_t iTargetTime = iNow + (int64_t) iTimeout; while (!bGotAck && !bError && (iTimeout <= 0 || iNow < iTargetTime)) { @@ -677,7 +678,7 @@ void CCECParser::PushEscaped(cec_frame &vec, uint8_t byte) void CCECParser::CheckKeypressTimeout(int64_t now) { - if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN && now - m_buttontime > 500) + if (m_iCurrentButton != CEC_USER_CONTROL_CODE_UNKNOWN && now - m_buttontime > CEC_BUTTON_TIMEOUT) { AddKey(); m_iCurrentButton = CEC_USER_CONTROL_CODE_UNKNOWN; diff --git a/src/lib/CECParser.h b/src/lib/CECParser.h index d429c92..1c72c1e 100644 --- a/src/lib/CECParser.h +++ b/src/lib/CECParser.h @@ -66,7 +66,7 @@ namespace CEC virtual bool GetNextLogMessage(cec_log_message *message); virtual bool GetNextKeypress(cec_keypress *key); virtual bool GetNextCommand(cec_command *command); - virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 5000); + virtual bool Transmit(const cec_frame &data, bool bWaitForAck = true); virtual bool SetLogicalAddress(cec_logical_address iLogicalAddress); virtual bool SetAckMask(uint16_t iMask); virtual int GetMinVersion(void); @@ -77,7 +77,7 @@ namespace CEC bool Process(void); void AddLog(cec_log_level level, const std::string &strMessage); protected: - virtual bool TransmitFormatted(const cec_frame &data, bool bWaitForAck = true, int64_t iTimeout = (int64_t) 2000); + virtual bool TransmitFormatted(const cec_frame &data, bool bWaitForAck = true); virtual void TransmitAbort(cec_logical_address address, cec_opcode opcode, ECecAbortReason reason = CEC_ABORT_REASON_UNRECOGNIZED_OPCODE); virtual void ReportCECVersion(cec_logical_address address = CECDEVICE_TV); virtual void ReportPowerState(cec_logical_address address = CECDEVICE_TV, bool bOn = true); @@ -91,7 +91,7 @@ namespace CEC private: void AddKey(void); void AddCommand(cec_logical_address source, cec_logical_address destination, cec_opcode opcode, cec_frame *parameters); - bool WaitForAck(int64_t iTimeout = (int64_t) 1000); + bool WaitForAck(int iTimeout = 1000); bool ReadFromDevice(int iTimeout); void ProcessMessages(void); bool GetMessage(cec_frame &msg, bool bFromBuffer = true); diff --git a/src/lib/CECParserC.cpp b/src/lib/CECParserC.cpp index b21f1c0..7deb982 100644 --- a/src/lib/CECParserC.cpp +++ b/src/lib/CECParserC.cpp @@ -135,10 +135,10 @@ bool cec_get_next_command(cec_command *command) return false; } -bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck /* = true */, int64_t iTimeout /* = 2000 */) +bool cec_transmit(const CEC::cec_frame &data, bool bWaitForAck /* = true */) { if (cec_parser) - return cec_parser->Transmit(data, bWaitForAck, iTimeout); + return cec_parser->Transmit(data, bWaitForAck); return false; } diff --git a/src/testclient/main.cpp b/src/testclient/main.cpp index deabed7..37df94d 100644 --- a/src/testclient/main.cpp +++ b/src/testclient/main.cpp @@ -42,7 +42,7 @@ using namespace CEC; using namespace std; -#define CEC_TEST_CLIENT_VERSION 2 +#define CEC_TEST_CLIENT_VERSION 3 void flush_log(ICECDevice *cecParser) { -- 2.34.1