ScummVM API documentation
Audio::LoopingAudioStream Class Reference

#include <audiostream.h>

Inheritance diagram for Audio::LoopingAudioStream:
Audio::LoopableAudioStream Audio::AudioStream

Public Member Functions

 LoopingAudioStream (RewindableAudioStream *stream, uint loops, DisposeAfterUse::Flag disposeAfterUse=DisposeAfterUse::YES, bool rewind=true)
 
 LoopingAudioStream (Common::DisposablePtr< RewindableAudioStream > &&stream, uint loops, bool rewind=true)
 
int readBuffer (int16 *buffer, const int numSamples) override
 
bool endOfData () const override
 
bool endOfStream () const override
 
bool isStereo () const override
 
int getRate () const override
 
uint getCompleteIterations () const override
 
void setRemainingIterations (uint loops) override
 

Detailed Description

A looping audio stream.

This object does nothing besides using a RewindableAudioStream to play a stream in a loop.

Constructor & Destructor Documentation

◆ LoopingAudioStream() [1/2]

Audio::LoopingAudioStream::LoopingAudioStream ( RewindableAudioStream stream,
uint  loops,
DisposeAfterUse::Flag  disposeAfterUse = DisposeAfterUse::YES,
bool  rewind = true 
)

Create a looping audio stream object.

On creation of the LoopingAudioStream object, the underlying stream will be rewound.

See also
makeLoopingAudioStream
Parameters
streamThe stream to loop.
loopsHow often to loop (0 = infinite).
disposeAfterUseDestroy the stream after the LoopingAudioStream has finished playback.
rewindIf true, rewind the underlying stream.

◆ LoopingAudioStream() [2/2]

Audio::LoopingAudioStream::LoopingAudioStream ( Common::DisposablePtr< RewindableAudioStream > &&  stream,
uint  loops,
bool  rewind = true 
)

Create a looping audio stream object.

On creation of the LoopingAudioStream object, the underlying stream will be rewound.

See also
makeLoopingAudioStream
Parameters
streamThe stream to loop.
loopsHow often to loop (0 = infinite).
disposeAfterUseDestroy the stream after the LoopingAudioStream has finished playback.
rewindIf true, rewind the underlying stream.

Member Function Documentation

◆ readBuffer()

int Audio::LoopingAudioStream::readBuffer ( int16 *  buffer,
const int  numSamples 
)
overridevirtual

Fill the given buffer with up to numSamples samples.

Data must be in native endianness, 16 bits per sample, signed. For stereo stream, the buffer will be filled with interleaved left and right channel samples, starting with the left sample. Furthermore, the samples in the left and right are summed up. So if you request 4 samples from a stereo stream, you will get a total of two left channel and two right channel samples.

Returns
The actual number of samples read, or -1 if a critical error occurred.
Note
You must check whether the returned value is less than what you requested. This indicates that the stream is fully used up.

Implements Audio::AudioStream.

◆ endOfData()

bool Audio::LoopingAudioStream::endOfData ( ) const
overridevirtual

Check whether end of data has been reached.

If this returns true, it indicates that at this time there is no data available in the stream. However, there might be more data in the future.

This is used by e.g. a rate converter to decide whether to keep on converting data or to stop.

Implements Audio::AudioStream.

◆ endOfStream()

bool Audio::LoopingAudioStream::endOfStream ( ) const
overridevirtual

Check whether end of stream has been reached.

If this returns true, it indicates that all data in this stream is used up and no additional data will appear in it in the future.

This is used by the mixer to decide whether a given stream shall be removed from the list of active streams (and thus be destroyed). By default, this maps to endOfData().

Reimplemented from Audio::AudioStream.

◆ isStereo()

bool Audio::LoopingAudioStream::isStereo ( ) const
inlineoverridevirtual

Check whether this is a stereo stream.

Implements Audio::AudioStream.

◆ getRate()

int Audio::LoopingAudioStream::getRate ( ) const
inlineoverridevirtual

Sample rate of the stream.

Implements Audio::AudioStream.

◆ getCompleteIterations()

uint Audio::LoopingAudioStream::getCompleteIterations ( ) const
inlineoverridevirtual

Return the number of loops that the stream has played.

Implements Audio::LoopableAudioStream.

◆ setRemainingIterations()

void Audio::LoopingAudioStream::setRemainingIterations ( uint  loops)
inlineoverridevirtual

Set the number of remaining loops the stream should play before stopping.

Implements Audio::LoopableAudioStream.


The documentation for this class was generated from the following file: