From: Lars Op den Kamp Date: Fri, 21 Sep 2012 18:19:33 +0000 (+0200) Subject: fixed - set the message state to ADAPTER_MESSAGE_STATE_ERROR when receiving an error... X-Git-Tag: upstream/2.2.0~1^2~17^2~6 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=815dbda2b98152be728b3b3b60c123e848c68378;p=deb_libcec.git fixed - set the message state to ADAPTER_MESSAGE_STATE_ERROR when receiving an error reply --- diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.cpp index 64efd06..a5be412 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.cpp @@ -377,18 +377,27 @@ bool CCECAdapterMessage::IsACK(void) const false; } -bool CCECAdapterMessage::IsError(void) const +bool CCECAdapterMessage::MessageCodeIsError(const cec_adapter_messagecode code) { - cec_adapter_messagecode code = Message(); return (code == MSGCODE_HIGH_ERROR || - code == MSGCODE_LOW_ERROR || - code == MSGCODE_RECEIVE_FAILED || - code == MSGCODE_COMMAND_REJECTED || - code == MSGCODE_TRANSMIT_LINE_TIMEOUT || - code == MSGCODE_TRANSMIT_FAILED_LINE || - code == MSGCODE_TRANSMIT_FAILED_ACK || - code == MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA || - code == MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE); + code == MSGCODE_LOW_ERROR || + code == MSGCODE_RECEIVE_FAILED || + code == MSGCODE_COMMAND_REJECTED || + code == MSGCODE_TRANSMIT_LINE_TIMEOUT || + code == MSGCODE_TRANSMIT_FAILED_LINE || + code == MSGCODE_TRANSMIT_FAILED_ACK || + code == MSGCODE_TRANSMIT_FAILED_TIMEOUT_DATA || + code == MSGCODE_TRANSMIT_FAILED_TIMEOUT_LINE); +} + +bool CCECAdapterMessage::IsError(void) const +{ + return MessageCodeIsError(Message()); +} + +bool CCECAdapterMessage::ReplyIsError(void) const +{ + return MessageCodeIsError(Reply()); } bool CCECAdapterMessage::NeedsRetry(void) const diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.h b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.h index f8ae413..1b03d72 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.h +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessage.h @@ -202,10 +202,22 @@ namespace CEC bool IsACK(void) const; /*! - * @return True when this message has been replied with an error code, false otherwise. + * @brief Checks whether the given messagecode is an error message. + * @param code The code to check. + * @return True when it's an error, false otherwise. + */ + static bool MessageCodeIsError(const cec_adapter_messagecode code); + + /*! + * @return True when this message contains an error code, false otherwise. */ bool IsError(void) const; + /*! + * @return True when this message has been replied with an error code, false otherwise. + */ + bool ReplyIsError(void) const; + /*! * @return True when this message has been replied with an error code and needs to be retried, false otherwise. */ diff --git a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp index b05a20e..de0ff1c 100644 --- a/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp +++ b/src/lib/adapter/Pulse-Eight/USBCECAdapterMessageQueue.cpp @@ -414,6 +414,10 @@ bool CCECAdapterMessageQueue::Write(CCECAdapterMessage *msg) CLockObject lock(m_mutex); m_messages.erase(iEntryId); } + + if (msg->ReplyIsError()) + msg->state = ADAPTER_MESSAGE_STATE_ERROR; + delete entry; }