xref: /haiku/headers/os/media/BufferGroup.h (revision 3be9edf8da228afd9fec0390f408c964766122aa)
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 struct _shared_buffer_list;
14 
15 
16 class BBufferGroup {
17 public:
18 							BBufferGroup(size_t size, int32 count = 3,
19 								uint32 placement = B_ANY_ADDRESS,
20 								uint32 lock = B_FULL_LOCK);
21 	explicit				BBufferGroup();
22 							BBufferGroup(int32 count,
23 								const media_buffer_id* buffers);
24 							~BBufferGroup();
25 
26 			status_t		InitCheck();
27 
28 			status_t		AddBuffer(const buffer_clone_info& info,
29 								BBuffer** _buffer = NULL);
30 
31 			BBuffer*		RequestBuffer(size_t size,
32 								bigtime_t timeout = B_INFINITE_TIMEOUT);
33 			status_t		RequestBuffer(BBuffer* buffer,
34 								bigtime_t timeout = B_INFINITE_TIMEOUT);
35 
36 			status_t		RequestError();
37 
38 			status_t		CountBuffers(int32* _count);
39 			status_t		GetBufferList(int32 bufferCount,
40 								BBuffer** _buffers);
41 
42 			status_t		WaitForBuffers();
43 			status_t		ReclaimAllBuffers();
44 
45 private:
46 			// deprecated BeOS R4 API
47 			status_t 		AddBuffersTo(BMessage* message, const char* name,
48 								bool needLock);
49 
50 							BBufferGroup(const BBufferGroup& other);
51 			BBufferGroup&	operator=(const BBufferGroup& other);
52 
53 			status_t		_Init();
54 
55 private:
56 	friend struct _shared_buffer_list;
57 
58 			status_t		fInitError;
59 			status_t		fRequestError;
60 			int32			fBufferCount;
61 			_shared_buffer_list* fBufferList;
62 			sem_id			fReclaimSem;
63 
64 			uint32			_reserved[9];
65 };
66 
67 
68 #endif	// _BUFFER_GROUP_H
69