xoreos  0.0.5
Public Member Functions | Protected Member Functions | Private Attributes | List of all members
Sound::StatelessPacketizedAudioStream Class Referenceabstract

A PacketizedAudioStream that works closer to a QueuingAudioStream. More...

#include <audiostream.h>

Inheritance diagram for Sound::StatelessPacketizedAudioStream:
Inheritance graph
[legend]
Collaboration diagram for Sound::StatelessPacketizedAudioStream:
Collaboration graph
[legend]

Public Member Functions

 StatelessPacketizedAudioStream (int rate, int channels)
 
virtual ~StatelessPacketizedAudioStream ()
 
int getChannels () const
 Return the number channels in this stream. More...
 
int getRate () const
 Sample rate of the stream. More...
 
size_t readBuffer (int16 *data, 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 *data)
 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 ()
 

Protected Member Functions

virtual AudioStreammakeStream (Common::SeekableReadStream *data)=0
 Make the AudioStream for a given packet. More...
 

Private Attributes

int _rate
 
int _channels
 
Common::ScopedPtr< QueuingAudioStream_stream
 

Additional Inherited Members

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

Detailed Description

A PacketizedAudioStream that works closer to a QueuingAudioStream.

It queues individual packets as whole AudioStream to an internal QueuingAudioStream. This is used for writing quick wrappers against e.g. PCMStream, which can be made into PacketizedAudioStreams with little effort.

Definition at line 300 of file audiostream.h.

Constructor & Destructor Documentation

◆ StatelessPacketizedAudioStream()

Sound::StatelessPacketizedAudioStream::StatelessPacketizedAudioStream ( int  rate,
int  channels 
)
inline

Definition at line 302 of file audiostream.h.

◆ ~StatelessPacketizedAudioStream()

virtual Sound::StatelessPacketizedAudioStream::~StatelessPacketizedAudioStream ( )
inlinevirtual

Definition at line 304 of file audiostream.h.

Member Function Documentation

◆ endOfData()

bool Sound::StatelessPacketizedAudioStream::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 310 of file audiostream.h.

References _stream.

◆ endOfStream()

bool Sound::StatelessPacketizedAudioStream::endOfStream ( ) const
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 311 of file audiostream.h.

References _stream.

◆ finish()

void Sound::StatelessPacketizedAudioStream::finish ( )
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::PacketizedAudioStream.

Definition at line 315 of file audiostream.h.

References _stream.

◆ getChannels()

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

Return the number channels in this stream.

Implements Sound::AudioStream.

Definition at line 307 of file audiostream.h.

References _channels.

Referenced by Sound::PacketizedPCMStream::makeStream(), and Sound::PacketizedADPCMStream::makeStream().

Here is the caller graph for this function:

◆ getRate()

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

Sample rate of the stream.

Implements Sound::AudioStream.

Definition at line 308 of file audiostream.h.

References _rate.

Referenced by Sound::PacketizedPCMStream::makeStream(), and Sound::PacketizedADPCMStream::makeStream().

Here is the caller graph for this function:

◆ isFinished()

bool Sound::StatelessPacketizedAudioStream::isFinished ( ) const
inlinevirtual

Is the stream marked as finished?

Implements Sound::PacketizedAudioStream.

Definition at line 316 of file audiostream.h.

References _stream.

◆ makeStream()

virtual AudioStream* Sound::StatelessPacketizedAudioStream::makeStream ( Common::SeekableReadStream data)
protectedpure virtual

Make the AudioStream for a given packet.

Implemented in Sound::PacketizedADPCMStream, and Sound::PacketizedPCMStream.

Referenced by queuePacket().

Here is the caller graph for this function:

◆ queuePacket()

void Sound::StatelessPacketizedAudioStream::queuePacket ( Common::SeekableReadStream data)
inlinevirtual

Queue the next packet to be decoded.

Implements Sound::PacketizedAudioStream.

Definition at line 314 of file audiostream.h.

References _stream, and makeStream().

Here is the call graph for this function:

◆ readBuffer()

size_t Sound::StatelessPacketizedAudioStream::readBuffer ( int16 buffer,
const size_t  numSamples 
)
inlinevirtual

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 309 of file audiostream.h.

References _stream.

Member Data Documentation

◆ _channels

int Sound::StatelessPacketizedAudioStream::_channels
private

Definition at line 326 of file audiostream.h.

Referenced by getChannels().

◆ _rate

int Sound::StatelessPacketizedAudioStream::_rate
private

Definition at line 325 of file audiostream.h.

Referenced by getRate().

◆ _stream

Common::ScopedPtr<QueuingAudioStream> Sound::StatelessPacketizedAudioStream::_stream
private

Definition at line 327 of file audiostream.h.

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


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