ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

Audio::RawStream< is16Bit, isUnsigned, isLE > Class Template Reference

This is a stream, which allows for playing raw PCM data from a stream. More...

Inheritance diagram for Audio::RawStream< is16Bit, isUnsigned, isLE >:
Collaboration diagram for Audio::RawStream< is16Bit, isUnsigned, isLE >:

List of all members.

Public Member Functions

 RawStream (int rate, bool stereo, DisposeAfterUse::Flag disposeStream, Common::SeekableReadStream *stream)
 ~RawStream ()
int readBuffer (int16 *buffer, const int numSamples)
 Fill the given buffer with up to numSamples samples.
bool isStereo () const
 Is this a stereo stream?
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.
int getRate () const
 Sample rate of the stream.
Timestamp getLength () const
 Returns the length of the stream.
bool seek (const Timestamp &where)
 Seeks to a given offset in the stream.

Private Types

enum  { kSampleBufferLength = 2048 }

Private Member Functions

int fillBuffer (int maxSamples)
 Fill the temporary sample buffer used in readBuffer.

Private Attributes

const int _rate
 Sample rate of stream.
const bool _isStereo
 Whether this is an stereo stream.
Timestamp _playtime
 Calculated total play time.
Common::DisposablePtr
< Common::SeekableReadStream
_stream
 Stream to read data from.
bool _endOfData
 Whether the stream end has been reached.
byte_buffer
 Buffer used in readBuffer.

Detailed Description

template<bool is16Bit, bool isUnsigned, bool isLE>
class Audio::RawStream< is16Bit, isUnsigned, isLE >

This is a stream, which allows for playing raw PCM data from a stream.

Definition at line 50 of file raw.cpp.


Member Enumeration Documentation

template<bool is16Bit, bool isUnsigned, bool isLE>
anonymous enum [private]
Enumerator:
kSampleBufferLength 

How many samples we can buffer at once.

TODO: Check whether this size suffices for systems with slow disk I/O.

Definition at line 83 of file raw.cpp.


Constructor & Destructor Documentation

template<bool is16Bit, bool isUnsigned, bool isLE>
Audio::RawStream< is16Bit, isUnsigned, isLE >::RawStream ( int  rate,
bool  stereo,
DisposeAfterUse::Flag  disposeStream,
Common::SeekableReadStream stream 
) [inline]

Definition at line 52 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
Audio::RawStream< is16Bit, isUnsigned, isLE >::~RawStream (  )  [inline]

Definition at line 62 of file raw.cpp.


Member Function Documentation

template<bool is16Bit, bool isUnsigned, bool isLE>
bool Audio::RawStream< is16Bit, isUnsigned, isLE >::endOfData (  )  const [inline, 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 Audio::AudioStream.

Definition at line 69 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
int Audio::RawStream< is16Bit, isUnsigned, isLE >::fillBuffer ( int  maxSamples  )  [private]

Fill the temporary sample buffer used in readBuffer.

Parameters:
maxSamples Maximum samples to read.
Returns:
actual count of samples read.

Definition at line 130 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
Timestamp Audio::RawStream< is16Bit, isUnsigned, isLE >::getLength (  )  const [inline, virtual]

Returns the length of the stream.

Returns:
length as Timestamp.

Implements Audio::SeekableAudioStream.

Definition at line 72 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
int Audio::RawStream< is16Bit, isUnsigned, isLE >::getRate (  )  const [inline, virtual]

Sample rate of the stream.

Implements Audio::AudioStream.

Definition at line 71 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
bool Audio::RawStream< is16Bit, isUnsigned, isLE >::isStereo (  )  const [inline, virtual]

Is this a stereo stream?

Implements Audio::AudioStream.

Definition at line 68 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
int Audio::RawStream< is16Bit, isUnsigned, isLE >::readBuffer ( int16 buffer,
const int  numSamples 
) [virtual]

Fill the given buffer with up to numSamples samples.

Returns the actual number of samples read, or -1 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 endianess, 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.

Implements Audio::AudioStream.

Definition at line 103 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
bool Audio::RawStream< is16Bit, isUnsigned, isLE >::seek ( const Timestamp where  )  [virtual]

Seeks to a given offset in the stream.

Parameters:
where offset as timestamp
Returns:
true on success, false on failure.

Implements Audio::SeekableAudioStream.

Definition at line 163 of file raw.cpp.


Member Data Documentation

template<bool is16Bit, bool isUnsigned, bool isLE>
byte* Audio::RawStream< is16Bit, isUnsigned, isLE >::_buffer [private]

Buffer used in readBuffer.

Definition at line 82 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
bool Audio::RawStream< is16Bit, isUnsigned, isLE >::_endOfData [private]

Whether the stream end has been reached.

Definition at line 80 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
const bool Audio::RawStream< is16Bit, isUnsigned, isLE >::_isStereo [private]

Whether this is an stereo stream.

Definition at line 77 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
Timestamp Audio::RawStream< is16Bit, isUnsigned, isLE >::_playtime [private]

Calculated total play time.

Definition at line 78 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
const int Audio::RawStream< is16Bit, isUnsigned, isLE >::_rate [private]

Sample rate of stream.

Definition at line 76 of file raw.cpp.

template<bool is16Bit, bool isUnsigned, bool isLE>
Common::DisposablePtr<Common::SeekableReadStream> Audio::RawStream< is16Bit, isUnsigned, isLE >::_stream [private]

Stream to read data from.

Definition at line 79 of file raw.cpp.


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


Generated on Sat Jan 12 2019 05:03:55 for ResidualVM by doxygen 1.7.1
curved edge   curved edge