1 /* 2 * Copyright 2009, Haiku Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 */ 5 #ifndef _BUFFER_GROUP_H 6 #define _BUFFER_GROUP_H 7 8 9 #include <MediaDefs.h> 10 11 12 class BBuffer; 13 namespace BPrivate { 14 struct SharedBufferList; 15 } 16 17 18 class BBufferGroup { 19 public: 20 BBufferGroup(size_t size, int32 count = 3, 21 uint32 placement = B_ANY_ADDRESS, 22 uint32 lock = B_FULL_LOCK); 23 explicit BBufferGroup(); 24 BBufferGroup(int32 count, 25 const media_buffer_id* buffers); 26 ~BBufferGroup(); 27 28 status_t InitCheck(); 29 30 status_t AddBuffer(const buffer_clone_info& info, 31 BBuffer** _buffer = NULL); 32 33 BBuffer* RequestBuffer(size_t size, 34 bigtime_t timeout = B_INFINITE_TIMEOUT); 35 status_t RequestBuffer(BBuffer* buffer, 36 bigtime_t timeout = B_INFINITE_TIMEOUT); 37 38 status_t RequestError(); 39 40 status_t CountBuffers(int32* _count); 41 status_t GetBufferList(int32 bufferCount, 42 BBuffer** _buffers); 43 44 status_t WaitForBuffers(); 45 status_t ReclaimAllBuffers(); 46 47 private: 48 // deprecated BeOS R4 API 49 status_t AddBuffersTo(BMessage* message, const char* name, 50 bool needLock); 51 52 BBufferGroup(const BBufferGroup& other); 53 BBufferGroup& operator=(const BBufferGroup& other); 54 55 status_t _Init(); 56 57 private: 58 friend struct BPrivate::SharedBufferList; 59 60 status_t fInitError; 61 status_t fRequestError; 62 int32 fBufferCount; 63 BPrivate::SharedBufferList* fBufferList; 64 sem_id fReclaimSem; 65 66 uint32 _reserved[9]; 67 }; 68 69 70 #endif // _BUFFER_GROUP_H 71