X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FUSBCECAdapterMessageQueue.h;h=9c5be4969b0abb084b65eaa09197d89fea880012;hb=4c2e665c0dcf87d0b45c07eb592a1aebf4ccf1f7;hp=5163090b6e33676aa231c8222ba5e0f7fd747569;hpb=a75e3a5a63546d6f7e670bc2a7a1931887a5d2a0;p=deb_libcec.git diff --git a/src/lib/adapter/USBCECAdapterMessageQueue.h b/src/lib/adapter/USBCECAdapterMessageQueue.h index 5163090..9c5be49 100644 --- a/src/lib/adapter/USBCECAdapterMessageQueue.h +++ b/src/lib/adapter/USBCECAdapterMessageQueue.h @@ -32,6 +32,7 @@ */ #include "USBCECAdapterMessage.h" +#include namespace CEC { @@ -88,24 +89,29 @@ namespace CEC /*! * @brief Called when a 'command accepted' message was received. * @param message The message that was received. - * @return True when the waiting thread need to be signaled, false otherwise. + * @return True when the message was handled, false otherwise. */ bool MessageReceivedCommandAccepted(const CCECAdapterMessage &message); /*! * @brief Called when a 'transmit succeeded' message was received. * @param message The message that was received. - * @return True when the waiting thread need to be signaled, false otherwise. + * @return True when the message was handled, false otherwise. */ bool MessageReceivedTransmitSucceeded(const CCECAdapterMessage &message); /*! * @brief Called when a message that's not a 'command accepted' or 'transmit succeeded' message was received. * @param message The message that was received. - * @return True when the waiting thread need to be signaled, false otherwise. + * @return True when the message was handled, false otherwise. */ bool MessageReceivedResponse(const CCECAdapterMessage &message); + /*! + * @brief Signals the waiting thread. + */ + void Signal(void); + CCECAdapterMessage * m_message; /**< the message that was sent */ uint8_t m_iPacketsLeft; /**< the amount of acks that we're waiting on */ bool m_bSucceeded; /**< true when the command received a response, false otherwise */ @@ -124,9 +130,9 @@ namespace CEC * @param com The communication handler callback to use. * @param iQueueSize The outgoing message queue size. */ - CCECAdapterMessageQueue(CUSBCECAdapterCommunication *com, size_t iQueueSize = 64) : + CCECAdapterMessageQueue(CUSBCECAdapterCommunication *com) : m_com(com), - m_messages(iQueueSize) {} + m_iNextMessage(0) {} virtual ~CCECAdapterMessageQueue(void); /*! @@ -155,14 +161,10 @@ namespace CEC bool Write(CCECAdapterMessage *msg); private: - /*! - * @return The next message in the queue, or NULL if there is none. - */ - CCECAdapterMessageQueueEntry *GetNextQueuedEntry(void); - CUSBCECAdapterCommunication * m_com; /**< the communication handler */ PLATFORM::CMutex m_mutex; /**< mutex for changes to this class */ - PLATFORM::SyncedBuffer m_messages; /**< the outgoing message queue */ + std::map m_messages; /**< the outgoing message queue */ + uint64_t m_iNextMessage; /**< the index of the next message */ CCECAdapterMessage m_incomingAdapterMessage; /**< the current incoming message that's being assembled */ cec_command m_currentCECFrame; /**< the current incoming CEC command that's being assembled */ };