xoreos
0.0.5
|
Classes | |
struct | StreamHolder |
We queue a number of (pointers to) audio stream objects. More... | |
Public Member Functions | |
QueuingAudioStreamImpl (int rate, int channels) | |
~QueuingAudioStreamImpl () | |
virtual size_t | readBuffer (int16 *buffer, const size_t numSamples) |
Fill the given buffer with up to numSamples samples. More... | |
virtual int | getChannels () const |
Return the number channels in this stream. More... | |
virtual int | getRate () const |
Sample rate of the stream. More... | |
virtual 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... | |
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... | |
virtual void | queueAudioStream (AudioStream *stream, bool disposeAfterUse) |
Queue an audio stream for playback. More... | |
virtual void | finish () |
Mark this stream as finished. More... | |
virtual bool | isFinished () const |
Is the stream marked as finished? More... | |
size_t | numQueuedStreams () const |
Return the number of streams still queued for playback (including the currently playing stream). More... | |
Public Member Functions inherited from Sound::AudioStream | |
virtual | ~AudioStream () |
Private Attributes | |
const int | _rate |
The sampling rate of this audio stream. More... | |
const int | _channels |
The number of channels in this audio stream. More... | |
bool | _finished |
This flag is set by the finish() method only. More... | |
Common::Mutex | _mutex |
A mutex to avoid access problems (causing e.g. More... | |
std::queue< StreamHolder > | _queue |
The queue of audio streams. More... | |
Additional Inherited Members | |
Static Public Attributes inherited from Sound::AudioStream | |
static const size_t | kSizeInvalid = SIZE_MAX |
Definition at line 146 of file audiostream.cpp.
|
inline |
Definition at line 190 of file audiostream.cpp.
Sound::QueuingAudioStreamImpl::~QueuingAudioStreamImpl | ( | ) |
Definition at line 226 of file audiostream.cpp.
References Sound::QueuingAudioStreamImpl::StreamHolder::_disposeAfterUse, _queue, and Sound::QueuingAudioStreamImpl::StreamHolder::_stream.
|
inlinevirtual |
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 198 of file audiostream.cpp.
|
inlinevirtual |
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.
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 Sound::AudioStream.
Definition at line 202 of file audiostream.cpp.
|
inlinevirtual |
Mark this stream as finished.
That is, signal that no further data will be queued to it. Only after this has been done can this stream ever 'end'.
Implements Sound::QueuingAudioStream.
Definition at line 210 of file audiostream.cpp.
|
inlinevirtual |
Return the number channels in this stream.
Implements Sound::AudioStream.
Definition at line 196 of file audiostream.cpp.
References _channels.
Referenced by queueAudioStream().
|
inlinevirtual |
Sample rate of the stream.
Implements Sound::AudioStream.
Definition at line 197 of file audiostream.cpp.
References _rate.
Referenced by queueAudioStream().
|
inlinevirtual |
Is the stream marked as finished?
Implements Sound::QueuingAudioStream.
Definition at line 215 of file audiostream.cpp.
|
inlinevirtual |
Return the number of streams still queued for playback (including the currently playing stream).
Implements Sound::QueuingAudioStream.
Definition at line 220 of file audiostream.cpp.
|
virtual |
Queue an audio stream for playback.
This stream plays all queued streams, in the order they were queued. If disposeAfterUse is set to DisposeAfterUse::YES, then the queued stream is deleted after all data contained in it has been played.
Implements Sound::QueuingAudioStream.
Definition at line 235 of file audiostream.cpp.
References _finished, _mutex, _queue, Sound::AudioStream::getChannels(), getChannels(), Sound::AudioStream::getRate(), and getRate().
|
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 246 of file audiostream.cpp.
References Sound::QueuingAudioStreamImpl::StreamHolder::_disposeAfterUse, _mutex, _queue, Sound::AudioStream::endOfData(), Sound::AudioStream::kSizeInvalid, and Sound::AudioStream::readBuffer().
|
private |
The number of channels in this audio stream.
Definition at line 171 of file audiostream.cpp.
Referenced by getChannels().
|
private |
This flag is set by the finish() method only.
See there for more details.
Definition at line 176 of file audiostream.cpp.
Referenced by endOfStream(), finish(), isFinished(), and queueAudioStream().
|
mutableprivate |
A mutex to avoid access problems (causing e.g.
corruption of the linked list) in thread aware environments.
Definition at line 182 of file audiostream.cpp.
Referenced by endOfData(), endOfStream(), finish(), isFinished(), numQueuedStreams(), queueAudioStream(), and readBuffer().
|
private |
The queue of audio streams.
Definition at line 187 of file audiostream.cpp.
Referenced by endOfData(), endOfStream(), numQueuedStreams(), queueAudioStream(), readBuffer(), and ~QueuingAudioStreamImpl().
|
private |
The sampling rate of this audio stream.
Definition at line 166 of file audiostream.cpp.
Referenced by getRate().