Skip to content

Commit

Permalink
SOUND: Add a packetized PCM stream
Browse files Browse the repository at this point in the history
  • Loading branch information
clone2727 authored and DrMcCoy committed Aug 18, 2018
1 parent 66d7841 commit a281441
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/sound/decoders/pcm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,24 @@ RewindableAudioStream *makePCMStream(Common::SeekableReadStream *stream,
}
}

class PacketizedPCMStream : public StatelessPacketizedAudioStream {
public:
PacketizedPCMStream(int rate, byte flags, int channels) :
StatelessPacketizedAudioStream(rate, channels), _flags(flags) {}

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

private:
byte _flags;
};

AudioStream *PacketizedPCMStream::makeStream(Common::SeekableReadStream *data) {
return makePCMStream(data, getRate(), _flags, getChannels());
}

PacketizedAudioStream *makePacketizedPCMStream(int rate, byte flags, int channels) {
return new PacketizedPCMStream(rate, flags, channels);
}

} // End of namespace Sound
14 changes: 14 additions & 0 deletions src/sound/decoders/pcm.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@

namespace Sound {

class PacketizedAudioStream;
class RewindableAudioStream;

/**
* Various flags which can be bit-ORed and then passed to
* makeRawMemoryStream and some other AudioStream factories
Expand Down Expand Up @@ -88,6 +91,17 @@ RewindableAudioStream *makePCMStream(Common::SeekableReadStream *stream,
int rate, byte flags, int channels,
bool disposeAfterUse = true);

/**
* Creates a PacketizedAudioStream that will automatically queue
* packets as individual AudioStreams like returned by makePCMStream.
*
* @param rate Rate of the sound data.
* @param flags Audio flags combination.
* @see PCMFlags
* @return The new PacketizedAudioStream.
*/
PacketizedAudioStream *makePacketizedPCMStream(int rate, byte flags, int channels);

} // End of namespace Sound

#endif // SOUND_DECODERS_RAW_H

0 comments on commit a281441

Please sign in to comment.