xoreos
0.0.5
|
Public Member Functions | |
MP3Stream (Common::SeekableReadStream *inStream, bool dispose) | |
~MP3Stream () | |
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... | |
uint64 | getLength () const |
Estimate the total number of samples per channel in this stream. More... | |
bool | rewind () |
Rewinds the stream to its start. More... | |
Public Member Functions inherited from Sound::RewindableAudioStream | |
virtual uint64 | getDuration () const |
Estimate the total duration of the stream in milliseconds. 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... | |
Protected Types | |
enum | State { MP3_STATE_INIT, MP3_STATE_READY, MP3_STATE_EOS } |
enum | { BUFFER_SIZE = 5 * 8192 } |
Protected Member Functions | |
void | decodeMP3Data () |
void | readMP3Data () |
void | initStream () |
void | readHeader () |
void | deinitStream () |
Protected Attributes | |
Common::DisposablePtr< Common::SeekableReadStream > | _inStream |
size_t | _posInFrame |
State | _state |
mad_timer_t | _totalTime |
mad_stream | _stream |
mad_frame | _frame |
mad_synth | _synth |
uint64 | _length |
uint64 | _samples |
int | _sampleRate |
int | _channels |
byte | _buf [BUFFER_SIZE+MAD_BUFFER_GUARD] |
Additional Inherited Members | |
Static Public Attributes inherited from Sound::RewindableAudioStream | |
static const uint64 | kInvalidLength = UINT64_C(0xFFFFFFFFFFFFFFFF) |
Static Public Attributes inherited from Sound::AudioStream | |
static const size_t | kSizeInvalid = SIZE_MAX |
|
protected |
Sound::MP3Stream::MP3Stream | ( | Common::SeekableReadStream * | inStream, |
bool | dispose | ||
) |
Definition at line 123 of file mp3.cpp.
References _buf, _channels, _frame, _length, _sampleRate, _samples, _state, BUFFER_SIZE, decodeMP3Data(), deinitStream(), initStream(), MP3_STATE_EOS, MP3_STATE_INIT, and readHeader().
Sound::MP3Stream::~MP3Stream | ( | ) |
Definition at line 157 of file mp3.cpp.
References deinitStream().
|
protected |
Definition at line 161 of file mp3.cpp.
References _frame, _posInFrame, _state, _stream, _synth, initStream(), MP3_STATE_EOS, MP3_STATE_INIT, MP3_STATE_READY, readMP3Data(), and warning().
Referenced by MP3Stream(), and readBuffer().
|
protected |
Definition at line 305 of file mp3.cpp.
References _frame, _state, _stream, _synth, MP3_STATE_EOS, and MP3_STATE_INIT.
Referenced by initStream(), MP3Stream(), and ~MP3Stream().
|
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 107 of file mp3.cpp.
References _state, and MP3_STATE_EOS.
|
inlinevirtual |
Return the number channels in this stream.
Implements Sound::AudioStream.
Definition at line 108 of file mp3.cpp.
References _channels.
|
inlinevirtual |
Estimate the total number of samples per channel in this stream.
If this value is not calculatable, return kInvalidLength.
Reimplemented from Sound::RewindableAudioStream.
Definition at line 110 of file mp3.cpp.
References _length.
|
inlinevirtual |
Sample rate of the stream.
Implements Sound::AudioStream.
Definition at line 109 of file mp3.cpp.
References _sampleRate.
|
protected |
Definition at line 246 of file mp3.cpp.
References _frame, _inStream, _posInFrame, _samples, _state, _stream, _synth, _totalTime, deinitStream(), MP3_STATE_INIT, MP3_STATE_READY, readMP3Data(), and Sound::timer_zero.
Referenced by decodeMP3Data(), MP3Stream(), and rewind().
|
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 331 of file mp3.cpp.
References _frame, _posInFrame, _state, _synth, decodeMP3Data(), MP3_STATE_EOS, and Sound::scale_sample().
|
protected |
Definition at line 268 of file mp3.cpp.
References _frame, _samples, _state, _stream, _totalTime, MP3_STATE_EOS, MP3_STATE_READY, readMP3Data(), and warning().
Referenced by MP3Stream(), and rewind().
|
protected |
Definition at line 203 of file mp3.cpp.
References _buf, _inStream, _state, _stream, BUFFER_SIZE, and MP3_STATE_EOS.
Referenced by decodeMP3Data(), initStream(), and readHeader().
|
virtual |
Rewinds the stream to its start.
Implements Sound::RewindableAudioStream.
Definition at line 233 of file mp3.cpp.
References _state, _totalTime, initStream(), MP3_STATE_EOS, MP3_STATE_READY, and readHeader().
|
protected |
Definition at line 98 of file mp3.cpp.
Referenced by MP3Stream(), and readMP3Data().
|
protected |
Definition at line 91 of file mp3.cpp.
Referenced by getChannels(), and MP3Stream().
|
protected |
Definition at line 84 of file mp3.cpp.
Referenced by decodeMP3Data(), deinitStream(), initStream(), MP3Stream(), readBuffer(), and readHeader().
|
protected |
Definition at line 76 of file mp3.cpp.
Referenced by initStream(), and readMP3Data().
|
protected |
Definition at line 87 of file mp3.cpp.
Referenced by getLength(), and MP3Stream().
|
protected |
Definition at line 78 of file mp3.cpp.
Referenced by decodeMP3Data(), initStream(), and readBuffer().
|
protected |
Definition at line 90 of file mp3.cpp.
Referenced by getRate(), and MP3Stream().
|
protected |
Definition at line 88 of file mp3.cpp.
Referenced by initStream(), MP3Stream(), and readHeader().
|
protected |
Definition at line 79 of file mp3.cpp.
Referenced by decodeMP3Data(), deinitStream(), endOfData(), initStream(), MP3Stream(), readBuffer(), readHeader(), readMP3Data(), and rewind().
|
protected |
Definition at line 83 of file mp3.cpp.
Referenced by decodeMP3Data(), deinitStream(), initStream(), readHeader(), and readMP3Data().
|
protected |
Definition at line 85 of file mp3.cpp.
Referenced by decodeMP3Data(), deinitStream(), initStream(), and readBuffer().
|
protected |
Definition at line 81 of file mp3.cpp.
Referenced by initStream(), readHeader(), and rewind().