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

Classes

struct  Packet
 

Public Member Functions

 ASFStream (Common::SeekableReadStream *stream, bool dispose)
 
 ~ASFStream ()
 
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...
 
uint64 getDuration () const
 Estimate the total duration of the stream in milliseconds. More...
 
bool rewind ()
 Rewinds the stream to its start. 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...
 

Private Member Functions

void load ()
 
void parseStreamHeader ()
 
void parseFileHeader ()
 
PacketreadPacket ()
 
PacketizedAudioStreamcreateAudioStream ()
 
void feedAudioData ()
 
bool allDataLoaded () const
 

Private Attributes

Common::DisposablePtr< Common::SeekableReadStream_stream
 
size_t _rewindPos
 
uint64 _curPacket
 
Common::ScopedPtr< PacketizedAudioStream_curAudioStream
 
byte _curSequenceNumber
 
uint64 _packetCount
 
uint64 _duration
 
uint32 _minPacketSize
 
uint32 _maxPacketSize
 
uint16 _streamID
 
uint16 _compression
 
uint16 _channels
 
int _sampleRate
 
uint32 _bitRate
 
uint16 _blockAlign
 
uint16 _bitsPerCodedSample
 
Common::ScopedPtr< Common::SeekableReadStream_extraData
 

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 106 of file asf.cpp.

Constructor & Destructor Documentation

◆ ASFStream()

Sound::ASFStream::ASFStream ( Common::SeekableReadStream stream,
bool  dispose 
)

Definition at line 184 of file asf.cpp.

References _curPacket, _curSequenceNumber, and load().

Here is the call graph for this function:

◆ ~ASFStream()

Sound::ASFStream::~ASFStream ( )

Definition at line 191 of file asf.cpp.

Member Function Documentation

◆ allDataLoaded()

bool Sound::ASFStream::allDataLoaded ( ) const
private

Definition at line 473 of file asf.cpp.

References _curPacket, and _packetCount.

Referenced by endOfData(), and readBuffer().

Here is the caller graph for this function:

◆ createAudioStream()

PacketizedAudioStream * Sound::ASFStream::createAudioStream ( )
private

Definition at line 409 of file asf.cpp.

References _bitRate, _blockAlign, _channels, _compression, _extraData, _sampleRate, Sound::kWaveWMAv2, and Sound::makeWMAStream().

Referenced by parseStreamHeader(), and rewind().

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

◆ endOfData()

bool Sound::ASFStream::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 477 of file asf.cpp.

References _curAudioStream, and allDataLoaded().

Here is the call graph for this function:

◆ feedAudioData()

void Sound::ASFStream::feedAudioData ( )
private

Definition at line 420 of file asf.cpp.

References _curAudioStream, _curSequenceNumber, _streamID, Sound::ASFStream::Packet::Segment::data, readPacket(), Sound::ASFStream::Packet::Segment::sequenceNumber, and Sound::ASFStream::Packet::Segment::streamID.

Referenced by readBuffer().

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

◆ getChannels()

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

Return the number channels in this stream.

Implements Sound::AudioStream.

Definition at line 114 of file asf.cpp.

References _channels.

◆ getDuration()

uint64 Sound::ASFStream::getDuration ( ) const
virtual

Estimate the total duration of the stream in milliseconds.

If this value is not calculable, return kInvalidLength.

Reimplemented from Sound::RewindableAudioStream.

Definition at line 301 of file asf.cpp.

References _duration.

◆ getLength()

uint64 Sound::ASFStream::getLength ( ) const
virtual

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 297 of file asf.cpp.

References _duration, and getRate().

Here is the call graph for this function:

◆ getRate()

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

Sample rate of the stream.

Implements Sound::AudioStream.

Definition at line 115 of file asf.cpp.

References _sampleRate.

Referenced by getLength().

Here is the caller graph for this function:

◆ load()

void Sound::ASFStream::load ( )
private

◆ parseFileHeader()

void Sound::ASFStream::parseFileHeader ( )
private

Definition at line 241 of file asf.cpp.

References _duration, _maxPacketSize, _minPacketSize, _packetCount, and _stream.

Referenced by load().

Here is the caller graph for this function:

◆ parseStreamHeader()

void Sound::ASFStream::parseStreamHeader ( )
private

Definition at line 264 of file asf.cpp.

References _bitRate, _bitsPerCodedSample, _blockAlign, _channels, _compression, _curAudioStream, _extraData, _sampleRate, _stream, _streamID, createAudioStream(), Common::ScopedPtrBase< T, Deallocator >::reset(), and Sound::s_asfAudioStream.

Referenced by load().

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

◆ readBuffer()

size_t Sound::ASFStream::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 450 of file asf.cpp.

References _curAudioStream, allDataLoaded(), feedAudioData(), and Sound::AudioStream::kSizeInvalid.

Here is the call graph for this function:

◆ readPacket()

ASFStream::Packet * Sound::ASFStream::readPacket ( )
private

◆ rewind()

bool Sound::ASFStream::rewind ( )
virtual

Rewinds the stream to its start.

Returns
true on success, false otherwise.

Implements Sound::RewindableAudioStream.

Definition at line 305 of file asf.cpp.

References _curAudioStream, _curPacket, _curSequenceNumber, _rewindPos, _stream, and createAudioStream().

Here is the call graph for this function:

Member Data Documentation

◆ _bitRate

uint32 Sound::ASFStream::_bitRate
private

Definition at line 169 of file asf.cpp.

Referenced by createAudioStream(), and parseStreamHeader().

◆ _bitsPerCodedSample

uint16 Sound::ASFStream::_bitsPerCodedSample
private

Definition at line 171 of file asf.cpp.

Referenced by parseStreamHeader().

◆ _blockAlign

uint16 Sound::ASFStream::_blockAlign
private

Definition at line 170 of file asf.cpp.

Referenced by createAudioStream(), and parseStreamHeader().

◆ _channels

uint16 Sound::ASFStream::_channels
private

Definition at line 167 of file asf.cpp.

Referenced by createAudioStream(), getChannels(), and parseStreamHeader().

◆ _compression

uint16 Sound::ASFStream::_compression
private

Definition at line 166 of file asf.cpp.

Referenced by createAudioStream(), and parseStreamHeader().

◆ _curAudioStream

Common::ScopedPtr<PacketizedAudioStream> Sound::ASFStream::_curAudioStream
private

Definition at line 156 of file asf.cpp.

Referenced by endOfData(), feedAudioData(), parseStreamHeader(), readBuffer(), and rewind().

◆ _curPacket

uint64 Sound::ASFStream::_curPacket
private

Definition at line 155 of file asf.cpp.

Referenced by allDataLoaded(), ASFStream(), readPacket(), and rewind().

◆ _curSequenceNumber

byte Sound::ASFStream::_curSequenceNumber
private

Definition at line 157 of file asf.cpp.

Referenced by ASFStream(), feedAudioData(), and rewind().

◆ _duration

uint64 Sound::ASFStream::_duration
private

Definition at line 161 of file asf.cpp.

Referenced by getDuration(), getLength(), and parseFileHeader().

◆ _extraData

Common::ScopedPtr<Common::SeekableReadStream> Sound::ASFStream::_extraData
private

Definition at line 172 of file asf.cpp.

Referenced by createAudioStream(), and parseStreamHeader().

◆ _maxPacketSize

uint32 Sound::ASFStream::_maxPacketSize
private

Definition at line 162 of file asf.cpp.

Referenced by parseFileHeader(), and readPacket().

◆ _minPacketSize

uint32 Sound::ASFStream::_minPacketSize
private

Definition at line 162 of file asf.cpp.

Referenced by parseFileHeader().

◆ _packetCount

uint64 Sound::ASFStream::_packetCount
private

Definition at line 160 of file asf.cpp.

Referenced by allDataLoaded(), parseFileHeader(), and readPacket().

◆ _rewindPos

size_t Sound::ASFStream::_rewindPos
private

Definition at line 154 of file asf.cpp.

Referenced by load(), and rewind().

◆ _sampleRate

int Sound::ASFStream::_sampleRate
private

Definition at line 168 of file asf.cpp.

Referenced by createAudioStream(), getRate(), and parseStreamHeader().

◆ _stream

Common::DisposablePtr<Common::SeekableReadStream> Sound::ASFStream::_stream
private

Definition at line 143 of file asf.cpp.

Referenced by load(), parseFileHeader(), parseStreamHeader(), readPacket(), and rewind().

◆ _streamID

uint16 Sound::ASFStream::_streamID
private

Definition at line 165 of file asf.cpp.

Referenced by feedAudioData(), and parseStreamHeader().


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