xoreos  0.0.5
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Sound::VorbisStream Class Reference
Inheritance diagram for Sound::VorbisStream:
Inheritance graph
[legend]
Collaboration diagram for Sound::VorbisStream:
Collaboration graph
[legend]

Public Member Functions

 VorbisStream (Common::SeekableReadStream *inStream, bool dispose)
 
 ~VorbisStream ()
 
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 Member Functions

bool refill ()
 

Protected Attributes

Common::DisposablePtr< Common::SeekableReadStream_inStream
 
bool _isStereo
 
int _rate
 
OggVorbis_File _ovFile
 
int16 _buffer [4096]
 
const int16_bufferEnd
 
const int16_pos
 
uint64 _length
 

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
 

Detailed Description

Definition at line 115 of file vorbis.cpp.

Constructor & Destructor Documentation

◆ VorbisStream()

Sound::VorbisStream::VorbisStream ( Common::SeekableReadStream inStream,
bool  dispose 
)

Definition at line 148 of file vorbis.cpp.

References _bufferEnd, _isStereo, _length, _ovFile, _pos, _rate, Sound::g_stream_wrap, refill(), and warning().

Here is the call graph for this function:

◆ ~VorbisStream()

Sound::VorbisStream::~VorbisStream ( )

Definition at line 173 of file vorbis.cpp.

References _ovFile.

Member Function Documentation

◆ endOfData()

bool Sound::VorbisStream::endOfData ( ) const
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 137 of file vorbis.cpp.

References _bufferEnd, and _pos.

◆ getChannels()

int Sound::VorbisStream::getChannels ( ) const
inlinevirtual

Return the number channels in this stream.

Implements Sound::AudioStream.

Definition at line 138 of file vorbis.cpp.

References _isStereo.

◆ getLength()

uint64 Sound::VorbisStream::getLength ( ) const
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 140 of file vorbis.cpp.

References _length.

◆ getRate()

int Sound::VorbisStream::getRate ( ) const
inlinevirtual

Sample rate of the stream.

Implements Sound::AudioStream.

Definition at line 139 of file vorbis.cpp.

References _rate.

◆ readBuffer()

size_t Sound::VorbisStream::readBuffer ( int16 buffer,
const size_t  numSamples 
)
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:

  • 5.1: front left, front right, front center, low frequency rear left, rear right

Implements Sound::AudioStream.

Definition at line 177 of file vorbis.cpp.

References _bufferEnd, _pos, and refill().

Here is the call graph for this function:

◆ refill()

bool Sound::VorbisStream::refill ( )
protected

Definition at line 202 of file vorbis.cpp.

References _buffer, _bufferEnd, _ovFile, _pos, and warning().

Referenced by readBuffer(), rewind(), and VorbisStream().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rewind()

bool Sound::VorbisStream::rewind ( )
virtual

Rewinds the stream to its start.

Returns
true on success, false otherwise.

Implements Sound::RewindableAudioStream.

Definition at line 195 of file vorbis.cpp.

References _ovFile, and refill().

Here is the call graph for this function:

Member Data Documentation

◆ _buffer

int16 Sound::VorbisStream::_buffer[4096]
protected

Definition at line 124 of file vorbis.cpp.

Referenced by refill().

◆ _bufferEnd

const int16* Sound::VorbisStream::_bufferEnd
protected

Definition at line 125 of file vorbis.cpp.

Referenced by endOfData(), readBuffer(), refill(), and VorbisStream().

◆ _inStream

Common::DisposablePtr<Common::SeekableReadStream> Sound::VorbisStream::_inStream
protected

Definition at line 117 of file vorbis.cpp.

◆ _isStereo

bool Sound::VorbisStream::_isStereo
protected

Definition at line 119 of file vorbis.cpp.

Referenced by getChannels(), and VorbisStream().

◆ _length

uint64 Sound::VorbisStream::_length
protected

Definition at line 128 of file vorbis.cpp.

Referenced by getLength(), and VorbisStream().

◆ _ovFile

OggVorbis_File Sound::VorbisStream::_ovFile
protected

Definition at line 122 of file vorbis.cpp.

Referenced by refill(), rewind(), VorbisStream(), and ~VorbisStream().

◆ _pos

const int16* Sound::VorbisStream::_pos
protected

Definition at line 126 of file vorbis.cpp.

Referenced by endOfData(), readBuffer(), refill(), and VorbisStream().

◆ _rate

int Sound::VorbisStream::_rate
protected

Definition at line 120 of file vorbis.cpp.

Referenced by getRate(), and VorbisStream().


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