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

Public Member Functions

 PacketizedVorbisStream ()
 
 ~PacketizedVorbisStream ()
 
bool parseExtraData (Common::SeekableReadStream &stream)
 
bool parseExtraData (Common::SeekableReadStream &packet1, Common::SeekableReadStream &packet2, Common::SeekableReadStream &packet3)
 
int getChannels () const
 Return the number channels in this stream. More...
 
int getRate () const
 Sample rate of the stream. More...
 
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...
 
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...
 
void queuePacket (Common::SeekableReadStream *packet)
 Queue the next packet to be decoded. More...
 
void finish ()
 Mark this stream as finished. More...
 
bool isFinished () const
 Is the stream marked as finished? More...
 
- Public Member Functions inherited from Sound::PacketizedAudioStream
virtual ~PacketizedAudioStream ()
 
- Public Member Functions inherited from Sound::AudioStream
virtual ~AudioStream ()
 

Private Attributes

vorbis_info _vorbisInfo
 
vorbis_dsp_state _dspState
 
vorbis_block _block
 
vorbis_comment _comment
 
ogg_packet _packet
 
bool _init
 
Common::Mutex _mutex
 
std::queue< Common::SeekableReadStream * > _queue
 
bool _finished
 
bool _hasData
 

Additional Inherited Members

- Static Public Attributes inherited from Sound::AudioStream
static const size_t kSizeInvalid = SIZE_MAX
 

Detailed Description

Definition at line 257 of file vorbis.cpp.

Constructor & Destructor Documentation

◆ PacketizedVorbisStream()

Sound::PacketizedVorbisStream::PacketizedVorbisStream ( )

Definition at line 292 of file vorbis.cpp.

References _comment, _finished, _hasData, _init, _packet, and _vorbisInfo.

◆ ~PacketizedVorbisStream()

Sound::PacketizedVorbisStream::~PacketizedVorbisStream ( )

Definition at line 301 of file vorbis.cpp.

References _block, _comment, _dspState, _init, _queue, and _vorbisInfo.

Member Function Documentation

◆ endOfData()

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

References _hasData, _mutex, and _queue.

Referenced by endOfStream().

Here is the caller graph for this function:

◆ endOfStream()

bool Sound::PacketizedVorbisStream::endOfStream ( ) const
virtual

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 495 of file vorbis.cpp.

References _finished, _mutex, and endOfData().

Here is the call graph for this function:

◆ finish()

void Sound::PacketizedVorbisStream::finish ( )
virtual

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::PacketizedAudioStream.

Definition at line 506 of file vorbis.cpp.

References _finished, and _mutex.

◆ getChannels()

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

Return the number channels in this stream.

Implements Sound::AudioStream.

Definition at line 266 of file vorbis.cpp.

References _vorbisInfo.

Referenced by readBuffer().

Here is the caller graph for this function:

◆ getRate()

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

Sample rate of the stream.

Implements Sound::AudioStream.

Definition at line 267 of file vorbis.cpp.

References _vorbisInfo.

◆ isFinished()

bool Sound::PacketizedVorbisStream::isFinished ( ) const
virtual

Is the stream marked as finished?

Implements Sound::PacketizedAudioStream.

Definition at line 511 of file vorbis.cpp.

References _finished, and _mutex.

◆ parseExtraData() [1/2]

bool Sound::PacketizedVorbisStream::parseExtraData ( Common::SeekableReadStream stream)

◆ parseExtraData() [2/2]

bool Sound::PacketizedVorbisStream::parseExtraData ( Common::SeekableReadStream packet1,
Common::SeekableReadStream packet2,
Common::SeekableReadStream packet3 
)

Definition at line 394 of file vorbis.cpp.

References _block, _comment, _dspState, _init, _packet, _vorbisInfo, Common::ScopedPtrBase< T, Deallocator >::get(), READ_WHOLE_STREAM, and warning().

Here is the call graph for this function:

◆ queuePacket()

void Sound::PacketizedVorbisStream::queuePacket ( Common::SeekableReadStream data)
virtual

Queue the next packet to be decoded.

Implements Sound::PacketizedAudioStream.

Definition at line 500 of file vorbis.cpp.

References _finished, _mutex, and _queue.

◆ readBuffer()

size_t Sound::PacketizedVorbisStream::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 431 of file vorbis.cpp.

References _block, _dspState, _hasData, _init, _mutex, _packet, _queue, getChannels(), and warning().

Here is the call graph for this function:

Member Data Documentation

◆ _block

vorbis_block Sound::PacketizedVorbisStream::_block
private

Definition at line 281 of file vorbis.cpp.

Referenced by parseExtraData(), readBuffer(), and ~PacketizedVorbisStream().

◆ _comment

vorbis_comment Sound::PacketizedVorbisStream::_comment
private

Definition at line 282 of file vorbis.cpp.

Referenced by PacketizedVorbisStream(), parseExtraData(), and ~PacketizedVorbisStream().

◆ _dspState

vorbis_dsp_state Sound::PacketizedVorbisStream::_dspState
private

Definition at line 280 of file vorbis.cpp.

Referenced by parseExtraData(), readBuffer(), and ~PacketizedVorbisStream().

◆ _finished

bool Sound::PacketizedVorbisStream::_finished
private

Definition at line 288 of file vorbis.cpp.

Referenced by endOfStream(), finish(), isFinished(), PacketizedVorbisStream(), and queuePacket().

◆ _hasData

bool Sound::PacketizedVorbisStream::_hasData
private

Definition at line 289 of file vorbis.cpp.

Referenced by endOfData(), PacketizedVorbisStream(), and readBuffer().

◆ _init

bool Sound::PacketizedVorbisStream::_init
private

◆ _mutex

Common::Mutex Sound::PacketizedVorbisStream::_mutex
mutableprivate

Definition at line 286 of file vorbis.cpp.

Referenced by endOfData(), endOfStream(), finish(), isFinished(), queuePacket(), and readBuffer().

◆ _packet

ogg_packet Sound::PacketizedVorbisStream::_packet
private

Definition at line 283 of file vorbis.cpp.

Referenced by PacketizedVorbisStream(), parseExtraData(), and readBuffer().

◆ _queue

std::queue<Common::SeekableReadStream *> Sound::PacketizedVorbisStream::_queue
private

Definition at line 287 of file vorbis.cpp.

Referenced by endOfData(), queuePacket(), readBuffer(), and ~PacketizedVorbisStream().

◆ _vorbisInfo

vorbis_info Sound::PacketizedVorbisStream::_vorbisInfo
private

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