nCine::StreamDecodeRequest struct

Request to decode one buffer of audio stream data, usually on the decoding thread.

Owned jointly by the requesting AudioStream and, while submitted, by the audio device. The shared ownership keeps the reader and the destination buffer alive even if the stream is moved or destroyed while the request is still being executed. One request is reused for the whole lifetime of a stream and holds at most one chunk of decoded data.

Public types

enum class State : std::uint8_t { Idle, Pending, Ready }
State of the request.

Constructors, destructors, conversion operators

StreamDecodeRequest()

Public functions

void Execute()
Decodes one buffer of data and marks the request as ready.

Public variables

std::shared_ptr<IAudioReader> reader
Reader that decodes the data, shared with the owning stream.
std::unique_ptr<char[]> buffer
Destination buffer for the decoded data.
std::int32_t bufferSize
Size of the destination buffer in bytes.
std::int32_t bytesRead
Number of decoded bytes, valid when the state is State::Ready.
bool looping
Whether the reader rewinds and keeps decoding when the end of data is reached.
std::atomic<State> state
Current state of the request.

Enum documentation

enum class nCine::StreamDecodeRequest::State : std::uint8_t

State of the request.

Enumerators
Idle

Not submitted, the buffer contents are not valid

Pending

Submitted, the request is owned by the decoding thread

Ready

Executed, the buffer holds bytesRead decoded bytes