2009-08-05 16:08:47 +00:00
|
|
|
/*
|
|
|
|
* Copyright 2009, Haiku Inc. All Rights Reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
|
|
|
*/
|
|
|
|
#ifndef _BUFFER_GROUP_H
|
2002-07-09 12:24:59 +00:00
|
|
|
#define _BUFFER_GROUP_H
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
|
2002-07-09 12:24:59 +00:00
|
|
|
#include <MediaDefs.h>
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
|
2007-10-15 20:13:55 +00:00
|
|
|
class BBuffer;
|
2002-07-09 12:24:59 +00:00
|
|
|
struct _shared_buffer_list;
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
|
|
|
|
class BBufferGroup {
|
2002-07-09 12:24:59 +00:00
|
|
|
public:
|
2009-08-05 16:08:47 +00:00
|
|
|
BBufferGroup(size_t size, int32 count = 3,
|
|
|
|
uint32 placement = B_ANY_ADDRESS,
|
|
|
|
uint32 lock = B_FULL_LOCK);
|
|
|
|
explicit BBufferGroup();
|
|
|
|
BBufferGroup(int32 count,
|
|
|
|
const media_buffer_id* buffers);
|
|
|
|
~BBufferGroup();
|
|
|
|
|
|
|
|
status_t InitCheck();
|
|
|
|
|
|
|
|
status_t AddBuffer(const buffer_clone_info& info,
|
|
|
|
BBuffer** _buffer = NULL);
|
|
|
|
|
|
|
|
BBuffer* RequestBuffer(size_t size,
|
|
|
|
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
|
|
|
status_t RequestBuffer(BBuffer* buffer,
|
|
|
|
bigtime_t timeout = B_INFINITE_TIMEOUT);
|
|
|
|
|
|
|
|
status_t RequestError();
|
2002-07-09 12:24:59 +00:00
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
status_t CountBuffers(int32* _count);
|
|
|
|
status_t GetBufferList(int32 bufferCount,
|
|
|
|
BBuffer** _buffers);
|
|
|
|
|
|
|
|
status_t WaitForBuffers();
|
|
|
|
status_t ReclaimAllBuffers();
|
2002-07-09 12:24:59 +00:00
|
|
|
|
|
|
|
private:
|
2009-08-05 16:08:47 +00:00
|
|
|
// deprecated BeOS R4 API
|
|
|
|
status_t AddBuffersTo(BMessage* message, const char* name,
|
|
|
|
bool needLock);
|
|
|
|
|
|
|
|
BBufferGroup(const BBufferGroup& other);
|
|
|
|
BBufferGroup& operator=(const BBufferGroup& other);
|
|
|
|
|
|
|
|
status_t _Init();
|
|
|
|
|
|
|
|
private:
|
|
|
|
friend struct _shared_buffer_list;
|
|
|
|
|
|
|
|
status_t fInitError;
|
|
|
|
status_t fRequestError;
|
|
|
|
int32 fBufferCount;
|
|
|
|
_shared_buffer_list* fBufferList;
|
|
|
|
sem_id fReclaimSem;
|
|
|
|
|
|
|
|
uint32 _reserved[9];
|
2002-07-09 12:24:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-08-05 16:08:47 +00:00
|
|
|
#endif // _BUFFER_GROUP_H
|