Skip to content

Commit

Permalink
SOUND: Add makePacketizedADPCMStream
Browse files Browse the repository at this point in the history
  • Loading branch information
clone2727 authored and DrMcCoy committed Aug 18, 2018
1 parent 7bcfd19 commit 60af482
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/sound/decoders/adpcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,4 +653,25 @@ RewindableAudioStream *makeADPCMStream(Common::SeekableReadStream *stream, bool
}
}

class PacketizedADPCMStream : public StatelessPacketizedAudioStream {
public:
PacketizedADPCMStream(ADPCMTypes type, int rate, int channels, uint32 blockAlign) :
StatelessPacketizedAudioStream(rate, channels), _type(type), _blockAlign(blockAlign) {}

protected:
AudioStream *makeStream(Common::SeekableReadStream *data);

private:
ADPCMTypes _type;
uint32 _blockAlign;
};

AudioStream *PacketizedADPCMStream::makeStream(Common::SeekableReadStream *data) {
return makeADPCMStream(data, true, data->size(), _type, getRate(), getChannels(), _blockAlign);
}

PacketizedAudioStream *makePacketizedADPCMStream(ADPCMTypes type, int rate, int channels, uint32 blockAlign) {
return new PacketizedADPCMStream(type, rate, channels, blockAlign);
}

} // End of namespace Sound
21 changes: 21 additions & 0 deletions src/sound/decoders/adpcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

namespace Sound {

class PacketizedAudioStream;
class RewindableAudioStream;

// There are several types of ADPCM encoding, only some are supported here
Expand Down Expand Up @@ -90,6 +91,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(
ADPCMTypes type,
int rate,
int channels,
uint32 blockAlign = 0);

} // End of namespace Sound

#endif // SOUND_DECODERS_ADPCM_H

0 comments on commit 60af482

Please sign in to comment.