diff options
Diffstat (limited to 'webrtc/base/bufferqueue.h')
-rw-r--r-- | webrtc/base/bufferqueue.h | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/webrtc/base/bufferqueue.h b/webrtc/base/bufferqueue.h index 4941fccf2e..458f0189cd 100644 --- a/webrtc/base/bufferqueue.h +++ b/webrtc/base/bufferqueue.h @@ -21,26 +21,33 @@ namespace rtc { class BufferQueue { public: - // Creates a buffer queue queue with a given capacity and default buffer size. + // Creates a buffer queue with a given capacity and default buffer size. BufferQueue(size_t capacity, size_t default_size); - ~BufferQueue(); + virtual ~BufferQueue(); // Return number of queued buffers. size_t size() const; // ReadFront will only read one buffer at a time and will truncate buffers // that don't fit in the passed memory. + // Returns true unless no data could be returned. bool ReadFront(void* data, size_t bytes, size_t* bytes_read); // WriteBack always writes either the complete memory or nothing. + // Returns true unless no data could be written. bool WriteBack(const void* data, size_t bytes, size_t* bytes_written); + protected: + // These methods are called when the state of the queue changes. + virtual void NotifyReadableForTest() {} + virtual void NotifyWritableForTest() {} + private: size_t capacity_; size_t default_size_; - std::deque<Buffer*> queue_; - std::vector<Buffer*> free_list_; - mutable CriticalSection crit_; // object lock + mutable CriticalSection crit_; + std::deque<Buffer*> queue_ GUARDED_BY(crit_); + std::vector<Buffer*> free_list_ GUARDED_BY(crit_); RTC_DISALLOW_COPY_AND_ASSIGN(BufferQueue); }; |