1 /******************************************************************************* 2 / 3 / File: BufferGroup.h 4 / 5 / Description: A BBufferGroup organizes sets of BBuffers so that you can request 6 / and reclaim them. 7 / 8 / Copyright 1997-98, Be Incorporated, All Rights Reserved 9 / 10 *******************************************************************************/ 11 12 #if !defined(_BUFFER_GROUP_H) 13 #define _BUFFER_GROUP_H 14 15 #include <MediaDefs.h> 16 17 struct _shared_buffer_list; 18 19 class BBufferGroup 20 { 21 public: 22 23 BBufferGroup( 24 size_t size, 25 int32 count = 3, 26 uint32 placement = B_ANY_ADDRESS, 27 uint32 lock = B_FULL_LOCK); 28 explicit BBufferGroup(); 29 BBufferGroup( 30 int32 count, 31 const media_buffer_id * buffers); 32 ~BBufferGroup(); /* BBufferGroup is NOT a virtual class!!! */ 33 34 status_t InitCheck(); 35 36 /* use this function to add buffers you created on your own */ 37 status_t AddBuffer( 38 const buffer_clone_info & info, 39 BBuffer ** out_buffer = NULL); 40 41 BBuffer * RequestBuffer( 42 size_t size, 43 bigtime_t timeout = B_INFINITE_TIMEOUT); 44 status_t RequestBuffer( 45 BBuffer * buffer, 46 bigtime_t timeout = B_INFINITE_TIMEOUT); 47 status_t RequestError(); /* return last RequestBuffer error, useful if NULL is returned */ 48 49 status_t CountBuffers( 50 int32 * out_count); 51 status_t GetBufferList( 52 int32 buf_count, 53 BBuffer ** out_buffers); 54 55 status_t WaitForBuffers(); 56 status_t ReclaimAllBuffers(); 57 58 private: 59 /* in BeOS R5 this is a deprecated api, from BeOS R4 times */ 60 status_t AddBuffersTo(BMessage * message, const char * name, bool needLock=true); 61 62 status_t InitBufferGroup(); /* used internally */ 63 BBufferGroup(const BBufferGroup &); /* not implemented */ 64 BBufferGroup& operator=(const BBufferGroup&); /* not implemented */ 65 66 friend struct _shared_buffer_list; 67 68 status_t fInitError; 69 status_t fRequestError; 70 int32 fBufferCount; 71 _shared_buffer_list * fBufferList; 72 73 // this is a BBufferGroup specific semaphore used for reclaiming BBuffers of this group 74 // is also is a system wide unique identifier of this group 75 sem_id fReclaimSem; 76 77 uint32 _reserved_buffer_group_[9]; 78 }; 79 80 #endif /* _BUFFER_GROUP_H */ 81 82