class ReusableBuffer
Defined at line 36 of file ../../src/media/audio/audio_core/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 (const Format & format, int64_t capacity_frames)
Defined at line 9 of file ../../src/media/audio/audio_core/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.
REQUIRES: start_frame.Fraction() == 0
Defined at line 17 of file ../../src/media/audio/audio_core/reusable_buffer.cc
void ReusableBuffer (const ReusableBuffer & )
No copying or moving.
Defined at line 41 of file ../../src/media/audio/audio_core/reusable_buffer.h
ReusableBuffer & operator= (const ReusableBuffer & )
Defined at line 42 of file ../../src/media/audio/audio_core/reusable_buffer.h
void ReusableBuffer (ReusableBuffer && )
Defined at line 43 of file ../../src/media/audio/audio_core/reusable_buffer.h
ReusableBuffer & operator= (ReusableBuffer && )
Defined at line 44 of file ../../src/media/audio/audio_core/reusable_buffer.h
Fixed start ()
Reports the starting frame of this buffer.
REQUIRES: the buffer has been reset.
Defined at line 48 of file ../../src/media/audio/audio_core/reusable_buffer.h
Fixed end ()
Reports the end of this buffer. Like std::vector::end(), this is one frame past the last frame.
REQUIRES: the buffer has been reset.
Defined at line 55 of file ../../src/media/audio/audio_core/reusable_buffer.h
int64_t length ()
Reports the total number of frames appended to the buffer since the last `Reset()`.
Defined at line 58 of file ../../src/media/audio/audio_core/reusable_buffer.h
bool empty ()
Reports whether the buffer is empty.
Defined at line 61 of file ../../src/media/audio/audio_core/reusable_buffer.h
int64_t capacity ()
Reports the maximum capacity of this buffer, in frames.
Defined at line 64 of file ../../src/media/audio/audio_core/reusable_buffer.h
void * payload ()
Returns a pointer to the raw data.
It is undefined behavior to access the payload beyond `length()` frames.
REQUIRES: the buffer is not empty.
Defined at line 70 of file ../../src/media/audio/audio_core/reusable_buffer.h
const Format & format ()
Reports the payload's format.
Defined at line 79 of file ../../src/media/audio/audio_core/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.
REQUIRES: payload_start.Fraction() == 0
&
&
payload_start >= end()
&
&
does not overflow capacity
&
&
the buffer has been reset
Defined at line 94 of file ../../src/media/audio/audio_core/reusable_buffer.h
void AppendSilence (Fixed silence_start, int64_t silence_frames)
Appends silent frames.
REQUIRES: silence_start.Fraction() == 0
&
&
silence_start >= end()
&
&
does not overflow capacity
&
&
the buffer has been reset
Defined at line 105 of file ../../src/media/audio/audio_core/reusable_buffer.h