Streaming opened sound data. More...
#include <sound_data.h>
Classes | |
struct | ContiguousBuffers |
A sorted non-empty vector of contiguous buffers. More... | |
struct | SoundBufferUntil |
An OpenAL buffer that goes until m_end (exclusive). More... | |
Public Member Functions | |
SoundDataOpenStream (std::unique_ptr< RAIIOggFile > oggfile, const OggFileDecodeInfo &decode_info) | |
bool | isStreaming () const noexcept override |
Iff the data is streaming, there is more than one buffer. | |
std::tuple< ALuint, ALuint, ALuint > | getOrLoadBufferAt (ALuint offset) override |
Load a buffer containing data starting at the given offset. | |
Public Member Functions inherited from sound::ISoundDataOpen | |
ISoundDataOpen (const OggFileDecodeInfo &decode_info) | |
virtual | ~ISoundDataOpen ()=default |
Public Attributes | |
std::unique_ptr< RAIIOggFile > | m_oggfile |
std::vector< ContiguousBuffers > | m_bufferss |
Public Attributes inherited from sound::ISoundDataOpen | |
OggFileDecodeInfo | m_decode_info |
Private Member Functions | |
std::tuple< ALuint, ALuint, ALuint > | loadBufferAt (ALuint offset, std::vector< ContiguousBuffers >::iterator after_it) |
Additional Inherited Members | |
Static Public Member Functions inherited from sound::ISoundDataOpen | |
static std::shared_ptr< ISoundDataOpen > | fromOggFile (std::unique_ptr< RAIIOggFile > oggfile, const std::string &filename_for_logging) |
Streaming opened sound data.
Uses a sorted list of contiguous sound data regions (ContiguousBuffers
s) for efficient seeking.
sound::SoundDataOpenStream::SoundDataOpenStream | ( | std::unique_ptr< RAIIOggFile > | oggfile, |
const OggFileDecodeInfo & | decode_info ) |
|
overridevirtual |
Load a buffer containing data starting at the given offset.
Or just get it if it was already loaded.
This function returns multiple values:
buffer
: The OpenAL buffer.buffer_end
: The offset (in the file) where buffer
ends (exclusive).offset_in_buffer
: Offset relative to buffer
's start where the requested offset
is. offset_in_buffer == 0
is guaranteed if some loaded buffer ends at offset
.offset | The start of the buffer. |
{buffer, buffer_end, offset_in_buffer}
or {0, sound_data_end, 0}
if offset
is invalid. Implements sound::ISoundDataOpen.
References sound::OggFileDecodeInfo::length_samples, loadBufferAt(), sound::SoundDataOpenStream::ContiguousBuffers::m_buffers, m_bufferss, and sound::ISoundDataOpen::m_decode_info.
|
inlineoverridevirtualnoexcept |
Iff the data is streaming, there is more than one buffer.
Implements sound::ISoundDataOpen.
|
private |
References sound::OggFileDecodeInfo::freq, sound::OggFileDecodeInfo::length_samples, m_bufferss, sound::ISoundDataOpen::m_decode_info, m_oggfile, and sound::MIN_STREAM_BUFFER_LENGTH.
Referenced by getOrLoadBufferAt().
std::vector<ContiguousBuffers> sound::SoundDataOpenStream::m_bufferss |
Referenced by getOrLoadBufferAt(), and loadBufferAt().
std::unique_ptr<RAIIOggFile> sound::SoundDataOpenStream::m_oggfile |
Referenced by loadBufferAt().