Don't call both
BroadcastBuffer()
and Recycle()
on the same buffer.
| Class Overview |
The BBuffer
constructor and destructor
are private; use the appropriate functions in the
BBufferGroup
class to create and destroy BBuffers
.
media_audio_header* AudioHeader();
Returns a pointer to an audio buffer's header; this is just an alias for:
&BBuffer
::Header
()->u
.raw_audio
;
buffer_clone_info CloneInfo() const;
Returns a buffer_clone_info structure describing a buffer. This information is primarily for debugging purposes; don't use this buffer_clone_info structure to add a buffer to a buffer group, because it'll just alias an existing buffer.
void Data();
The Data()
function returns a
pointer to the first byte of the buffer, or
NULL
if the buffer somehow couldn't be properly initialized (in which
case the buffer can't be used).
int32 Flags();
Returns the buffer's flags. The flags let you specify options for the
buffer. For example, you might create a
BBufferGroup
in which some buffers are intended for odd video fields
(B_F1_BUFFER
), and other buffers are intended for
even video fields (B_F2_BUFFER
), thereby letting
you handle interlaced video much more easily by having each buffer know
where the video should be displayed.
media_header* Header();
Returns a pointer to the buffer's header. This header describes the media
data contained therein. The result is only valid for a buffer received
from either
BBufferGroup::RequestBuffer()
or
BBufferConsumer::BufferReceived()
.
If you put data into a buffer, you should call
Header()
to obtain a
pointer to the buffer's header, then fill out the
media_header
structure with information describing the buffer's contents.
media_buffer_id ID();
If the buffer has been successfully registered with the Media Server, and
is available for use by other clients, ID()
returns a positive buffer ID.
Otherwise, a negative number is returned.
void Recycle();
Sends the buffer back to the BBufferGroup that owns it so the buffer can
be reused. You can only call Recycle() on a buffer that you received from
either the
BBufferGroup::RequestBuffer()
call or the
BBufferConsumer::BufferReceived()
call.
Don't call both
BroadcastBuffer()
and Recycle()
on the same buffer.
size_t SizeAvailable();
Returns the size, in bytes, of the buffer. The actual number of bytes
used might be less than this value, and is stored in the buffer's header,
which can be obtained by calling the
Header()
function.
size_t SizeUsed();
void SetSizeUsed(ssize_t sizeUsed);
SizeUsed()
returns the number of
bytes in the buffer that are currently in use.
SetSizeUsed()
sets this value. This should be called after writing data
into the buffer in order to indicate the size of the written data.
media_type Type();
Returns the media type of the data contained within the buffer, as
specified by the
BBufferProducer
from which the buffer originated. This
value is only valid if you received the buffer from either the
BBufferGroup::RequestBuffer()
call or the
BBufferConsumer::BufferReceived()
call.
Declared in: media/Buffer.h
Constant | Description |
---|---|
| Buffer is for odd fields. |
| Buffer is for even fields. |
| The buffer is a small buffer. |
These flags can be assigned to a buffer; the current possible values let
you specify whether the buffer should be used for even video fields or
odd video fields; if B_SMALL_BUFFER
is set, the buffer is a
BSmallBuffer
.
Declared in: media/Buffer.h
struct buffer_clone_info {buffer_clone_info
();~buffer_clone_info
(); media_buffer_idbuffer
; area_idarea
; size_toffset
; size_tsize
; int32flags
; private:_reserved_
[4]; };
Describes where in memory a BBuffer
resides (in terms of the memory area
and offset into the area at which the buffer is located, and the size of
the buffer), as well as the buffer's flags.