class ReusableBuffer
Defined at line 36 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
This class contains an audio buffer along with a frame number that identifies the
first frame in the buffer:
+-----------------------------------+
| buffer |
+-----------------------------------+
^ ^
start frame end frame
The buffer is initially empty. Audio data can be appended up to a specified capacity.
The buffer can be cleared for reuse. The capacity is preallocated by the constructor,
after which there are no further allocations.
All frames must be aligned on integral positions. Despite this integral requirement,
method calls represent frame positions with Fixed numbers for consistency with other
classes in this directory.
Public Methods
void ReusableBuffer (Format format, int64_t capacity_frames)
Defined at line 14 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.cc
void Reset (Fixed start_frame)
Clears the buffer and resets the starting position.
This must be called at least once after the constructor before appending any data.
REQUIRED: start_frame.Fraction() == 0
Defined at line 20 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.cc
void ReusableBuffer (const ReusableBuffer & )
No copying or moving.
Defined at line 41 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
ReusableBuffer & operator= (const ReusableBuffer & )
Defined at line 42 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
void ReusableBuffer (ReusableBuffer && )
Defined at line 43 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
ReusableBuffer & operator= (ReusableBuffer && )
Defined at line 44 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
Fixed start_frame ()
Reports the starting frame of this buffer.
REQUIRED: the buffer has been reset.
Defined at line 48 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
Fixed end_frame ()
Reports the end of the buffer. Like std::vector::end(), this is one frame past the last frame.
REQUIRED: the buffer has been reset.
Defined at line 55 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
int64_t frame_count ()
Reports the total number of frames appended to the buffer since the last `Reset`.
Defined at line 58 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
bool empty ()
Reports whether the buffer is empty.
Defined at line 63 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
int64_t capacity ()
Reports the maximum capacity of this buffer in frames.
Defined at line 66 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
void * payload ()
Returns a pointer to the raw data.
It is undefined behavior to access the payload beyond `length()` frames.
REQUIRED: the buffer is not empty.
Defined at line 72 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
const Format & format ()
Reports the payload's format.
Defined at line 81 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
void AppendData (Fixed payload_start, int64_t payload_frames, void * payload)
Appends the given payload buffer.
If `payload_start > end()`, silence is automatically inserted in the gap.
REQUIRED: payload_start.Fraction() == 0
&
&
payload_start >= end()
&
&
does not overflow capacity
&
&
the buffer has been reset
Defined at line 96 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h
void AppendSilence (Fixed silence_start, int64_t silence_frames)
Appends silent frames.
REQUIRED: silence_start.Fraction() == 0
&
&
silence_start >= end()
&
&
does not overflow capacity
&
&
the buffer has been reset
Defined at line 107 of file ../../src/media/audio/services/mixer/mix/reusable_buffer.h