mirror of
https://github.com/scummvm/scummvm.git
synced 2026-06-20 05:45:29 +00:00
AUDIO: Add a packetized version of ADPCM streams
This commit is contained in:
@@ -457,4 +457,34 @@ RewindableAudioStream *makeADPCMStream(Common::SeekableReadStream *stream, Dispo
|
||||
}
|
||||
}
|
||||
|
||||
class PacketizedADPCMStream : public StatelessPacketizedAudioStream {
|
||||
public:
|
||||
PacketizedADPCMStream(ADPCMType type, int rate, int channels, uint32 blockAlign) :
|
||||
StatelessPacketizedAudioStream(rate, channels), _type(type), _blockAlign(blockAlign) {}
|
||||
|
||||
protected:
|
||||
AudioStream *makeStream(Common::SeekableReadStream *data);
|
||||
|
||||
private:
|
||||
ADPCMType _type;
|
||||
uint32 _blockAlign;
|
||||
};
|
||||
|
||||
AudioStream *PacketizedADPCMStream::makeStream(Common::SeekableReadStream *data) {
|
||||
return makeADPCMStream(data, DisposeAfterUse::YES, data->size(), _type, getRate(), getChannels(), _blockAlign);
|
||||
}
|
||||
|
||||
PacketizedAudioStream *makePacketizedADPCMStream(ADPCMType type, int rate, int channels, uint32 blockAlign) {
|
||||
// Filter out types we can't support (they're not fully stateless)
|
||||
switch (type) {
|
||||
case kADPCMOki:
|
||||
case kADPCMDVI:
|
||||
return 0;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return new PacketizedADPCMStream(type, rate, channels, blockAlign);
|
||||
}
|
||||
|
||||
} // End of namespace Audio
|
||||
|
||||
@@ -44,6 +44,7 @@ class SeekableReadStream;
|
||||
|
||||
namespace Audio {
|
||||
|
||||
class PacketizedAudioStream;
|
||||
class RewindableAudioStream;
|
||||
|
||||
// There are several types of ADPCM encoding, only some are supported here
|
||||
@@ -81,6 +82,26 @@ RewindableAudioStream *makeADPCMStream(
|
||||
int channels,
|
||||
uint32 blockAlign = 0);
|
||||
|
||||
/**
|
||||
* Creates a PacketizedAudioStream that will automatically queue
|
||||
* packets as individual AudioStreams like returned by makeADPCMStream.
|
||||
*
|
||||
* Due to the ADPCM types not necessarily supporting stateless
|
||||
* streaming, OKI and DVI are not supported by this function
|
||||
* and will return NULL.
|
||||
*
|
||||
* @param type the compression type used
|
||||
* @param rate the sampling rate
|
||||
* @param channels the number of channels
|
||||
* @param blockAlign block alignment ???
|
||||
* @return The new PacketizedAudioStream or NULL, if the type isn't supported.
|
||||
*/
|
||||
PacketizedAudioStream *makePacketizedADPCMStream(
|
||||
ADPCMType type,
|
||||
int rate,
|
||||
int channels,
|
||||
uint32 blockAlign = 0);
|
||||
|
||||
} // End of namespace Audio
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user