X-Git-Url: https://git.piment-noir.org/?a=blobdiff_plain;f=src%2Flib%2Fadapter%2FUSBCECAdapterMessageQueue.h;h=44c930be3cd7efcc84001506ac8c9943655222dd;hb=38f1fbcc12f5774288b55e3a75df10338f1ed70f;hp=9c5be4969b0abb084b65eaa09197d89fea880012;hpb=64d46f80cc6f34f531ae26e8677f2f0b0c1f74bb;p=deb_libcec.git diff --git a/src/lib/adapter/USBCECAdapterMessageQueue.h b/src/lib/adapter/USBCECAdapterMessageQueue.h index 9c5be49..44c930b 100644 --- a/src/lib/adapter/USBCECAdapterMessageQueue.h +++ b/src/lib/adapter/USBCECAdapterMessageQueue.h @@ -32,16 +32,18 @@ */ #include "USBCECAdapterMessage.h" +#include "../platform/threads/threads.h" #include namespace CEC { class CUSBCECAdapterCommunication; + class CCECAdapterMessageQueue; class CCECAdapterMessageQueueEntry { public: - CCECAdapterMessageQueueEntry(CCECAdapterMessage *message); + CCECAdapterMessageQueueEntry(CCECAdapterMessageQueue *queue, CCECAdapterMessage *message); virtual ~CCECAdapterMessageQueueEntry(void); /*! @@ -85,7 +87,6 @@ namespace CEC */ const char *ToString(void) const; - private: /*! * @brief Called when a 'command accepted' message was received. * @param message The message that was received. @@ -112,6 +113,7 @@ namespace CEC */ void Signal(void); + CCECAdapterMessageQueue * m_queue; 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 */ @@ -120,9 +122,10 @@ namespace CEC PLATFORM::CMutex m_mutex; /**< mutex for changes to this class */ }; - class CCECAdapterMessageQueue + class CCECAdapterMessageQueue : public PLATFORM::CThread { friend class CUSBCECAdapterCommunication; + friend class CCECAdapterMessageQueueEntry; public: /*! @@ -131,8 +134,13 @@ namespace CEC * @param iQueueSize The outgoing message queue size. */ CCECAdapterMessageQueue(CUSBCECAdapterCommunication *com) : + PLATFORM::CThread(), m_com(com), - m_iNextMessage(0) {} + m_iNextMessage(0) + { + m_currentCECFrame.Clear(); + } + virtual ~CCECAdapterMessageQueue(void); /*! @@ -160,10 +168,13 @@ namespace CEC */ bool Write(CCECAdapterMessage *msg); + virtual void *Process(void); + private: CUSBCECAdapterCommunication * m_com; /**< the communication handler */ PLATFORM::CMutex m_mutex; /**< mutex for changes to this class */ std::map m_messages; /**< the outgoing message queue */ + PLATFORM::SyncedBuffer m_writeQueue; /**< the queue for messages that are to be written */ 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 */