xoreos
0.0.5
|
A looping audio stream. More...
#include <audiostream.h>
Public Member Functions | |
LoopingAudioStream (RewindableAudioStream *stream, size_t loops, bool disposeAfterUse=true) | |
Creates a looping audio stream object. More... | |
~LoopingAudioStream () | |
size_t | readBuffer (int16 *buffer, const size_t numSamples) |
Fill the given buffer with up to numSamples samples. More... | |
bool | endOfData () const |
End of data reached? If this returns true, it means that at this time there is no data available in the stream. More... | |
int | getChannels () const |
Return the number channels in this stream. More... | |
int | getRate () const |
Sample rate of the stream. More... | |
size_t | getCompleteIterations () const |
Returns number of loops the stream has played. More... | |
bool | rewind () |
uint64 | getLength () const |
uint64 | getDuration () const |
uint64 | getLengthOnce () const |
Return the length of one loop. More... | |
uint64 | getDurationOnce () const |
Return the duration of one loop. More... | |
Public Member Functions inherited from Sound::AudioStream | |
virtual | ~AudioStream () |
virtual bool | endOfStream () const |
End of stream reached? If this returns true, it means that all data in this stream is used up and no additional data will appear in it in the future. More... | |
Private Attributes | |
Common::DisposablePtr< RewindableAudioStream > | _parent |
size_t | _loops |
size_t | _completeIterations |
Additional Inherited Members | |
Static Public Attributes inherited from Sound::AudioStream | |
static const size_t | kSizeInvalid = SIZE_MAX |
A looping audio stream.
This object does nothing besides using a RewindableAudioStream to play a stream in a loop.
Definition at line 175 of file audiostream.h.
Sound::LoopingAudioStream::LoopingAudioStream | ( | RewindableAudioStream * | stream, |
size_t | loops, | ||
bool | disposeAfterUse = true |
||
) |
Creates a looping audio stream object.
stream | Stream to loop |
loops | How often to loop (0 = infinite) |
disposeAfterUse | Destroy the stream after the LoopingAudioStream has finished playback. |
Definition at line 59 of file audiostream.cpp.
Sound::LoopingAudioStream::~LoopingAudioStream | ( | ) |
Definition at line 63 of file audiostream.cpp.
|
virtual |
End of data reached? If this returns true, it means that at this time there is no data available in the stream.
However there may be more data in the future. This is used by e.g. a rate converter to decide whether to keep on converting data or stop.
Implements Sound::AudioStream.
Definition at line 97 of file audiostream.cpp.
References _completeIterations, and _loops.
|
inlinevirtual |
Return the number channels in this stream.
Implements Sound::AudioStream.
Definition at line 192 of file audiostream.h.
References _parent.
|
inline |
Returns number of loops the stream has played.
Definition at line 196 of file audiostream.h.
References _completeIterations.
uint64 Sound::LoopingAudioStream::getDuration | ( | ) | const |
Definition at line 127 of file audiostream.cpp.
References _loops, _parent, and Sound::RewindableAudioStream::kInvalidLength.
uint64 Sound::LoopingAudioStream::getDurationOnce | ( | ) | const |
Return the duration of one loop.
Definition at line 142 of file audiostream.cpp.
References _parent.
uint64 Sound::LoopingAudioStream::getLength | ( | ) | const |
Definition at line 116 of file audiostream.cpp.
References _loops, _parent, and Sound::RewindableAudioStream::kInvalidLength.
uint64 Sound::LoopingAudioStream::getLengthOnce | ( | ) | const |
|
inlinevirtual |
Sample rate of the stream.
Implements Sound::AudioStream.
Definition at line 193 of file audiostream.h.
References _parent.
|
virtual |
Fill the given buffer with up to numSamples samples.
Returns the actual number of samples read, or kSizeInvalid if a critical error occurred (note: you must check if this value is less than what you requested, this can happen when the stream is fully used up).
Data has to be in native endianness, 16 bit per sample, signed. For stereo stream, buffer will be filled with interleaved left and right channel samples, starting with a 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.
The same holds true for more channels. Channel configurations recognized:
Implements Sound::AudioStream.
Definition at line 66 of file audiostream.cpp.
References _completeIterations, _loops, _parent, and Sound::AudioStream::kSizeInvalid.
bool Sound::LoopingAudioStream::rewind | ( | ) |
Definition at line 108 of file audiostream.cpp.
References _completeIterations, and _parent.
|
private |
Definition at line 212 of file audiostream.h.
Referenced by endOfData(), getCompleteIterations(), readBuffer(), and rewind().
|
private |
Definition at line 211 of file audiostream.h.
Referenced by endOfData(), getDuration(), getLength(), and readBuffer().
|
private |
Definition at line 209 of file audiostream.h.
Referenced by getChannels(), getDuration(), getDurationOnce(), getLength(), getLengthOnce(), getRate(), readBuffer(), and rewind().