aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/saga/sndres.cpp2
-rw-r--r--engines/scumm/he/sound_he.cpp2
-rw-r--r--sound/adpcm.cpp41
-rw-r--r--sound/adpcm.h34
-rw-r--r--sound/wave.cpp2
5 files changed, 44 insertions, 37 deletions
diff --git a/engines/saga/sndres.cpp b/engines/saga/sndres.cpp
index d3679599fd..40c6bd86a6 100644
--- a/engines/saga/sndres.cpp
+++ b/engines/saga/sndres.cpp
@@ -217,7 +217,7 @@ bool SndRes::load(ResourceContext *context, uint32 resourceId, SoundBuffer &buff
buffer.buffer = NULL;
free(soundResource);
} else {
- voxStream = new ADPCMInputStream(&readS, soundResourceLength, kADPCMOki);
+ voxStream = makeADPCMStream(&readS, soundResourceLength, kADPCMOki);
buffer.buffer = (byte *)malloc(buffer.size);
voxSize = voxStream->readBuffer((int16*)buffer.buffer, soundResourceLength * 2);
if (voxSize != soundResourceLength * 2) {
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index bb01ede275..06736ab29a 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -419,7 +419,7 @@ void Sound::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
}
if (compType == 17) {
- AudioStream *voxStream = new ADPCMInputStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
+ AudioStream *voxStream = makeADPCMStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
sound = (char *)malloc(size * 4);
size = voxStream->readBuffer((int16*)sound, size * 2);
diff --git a/sound/adpcm.cpp b/sound/adpcm.cpp
index 32ea6dc6eb..b1270d9220 100644
--- a/sound/adpcm.cpp
+++ b/sound/adpcm.cpp
@@ -23,7 +23,42 @@
#include "common/stdafx.h"
#include "sound/adpcm.h"
-
+#include "sound/audiostream.h"
+
+
+// TODO: Switch from a SeekableReadStream to a plain ReadStream. This requires
+// some internal refactoring but is definitely possible and will increase the
+// flexibility of this code.
+class ADPCMInputStream : public AudioStream {
+private:
+ Common::SeekableReadStream *_stream;
+ uint32 _endpos;
+ int _channels;
+ typesADPCM _type;
+ uint32 _blockAlign;
+
+ struct adpcmStatus {
+ int32 last;
+ int32 stepIndex;
+ } _status;
+
+ int16 stepAdjust(byte);
+ int16 decodeOKI(byte);
+ int16 decodeMSIMA(byte);
+
+public:
+ ADPCMInputStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels = 2, uint32 blockAlign = 0);
+ ~ADPCMInputStream() {};
+
+ int readBuffer(int16 *buffer, const int numSamples);
+ int readBufferOKI(int16 *buffer, const int numSamples);
+ int readBufferMSIMA1(int16 *buffer, const int numSamples);
+ int readBufferMSIMA2(int16 *buffer, const int numSamples);
+
+ bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); }
+ bool isStereo() const { return false; }
+ int getRate() const { return 22050; }
+};
// Routines to convert 12 bit linear samples to the
// Dialogic or Oki ADPCM coding format aka VOX.
@@ -205,3 +240,7 @@ int16 ADPCMInputStream::decodeMSIMA(byte code) {
return samp;
}
+
+AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels, uint32 blockAlign) {
+ return new ADPCMInputStream(stream, size, type, channels, blockAlign);
+}
diff --git a/sound/adpcm.h b/sound/adpcm.h
index ac24805eff..aea1beaf60 100644
--- a/sound/adpcm.h
+++ b/sound/adpcm.h
@@ -26,7 +26,6 @@
#include "common/stdafx.h"
#include "common/scummsys.h"
#include "common/stream.h"
-#include "sound/audiostream.h"
class AudioStream;
@@ -35,38 +34,7 @@ enum typesADPCM {
kADPCMIma
};
-// TODO: Switch from a SeekableReadStream to a plain ReadStream. This requires
-// some internal refactoring but is definitely possible and will increase the
-// flexibility of this code.
-class ADPCMInputStream : public AudioStream {
-private:
- Common::SeekableReadStream *_stream;
- uint32 _endpos;
- int _channels;
- typesADPCM _type;
- uint32 _blockAlign;
+AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels = 2, uint32 blockAlign = 0);
- struct adpcmStatus {
- int32 last;
- int32 stepIndex;
- } _status;
-
- int16 stepAdjust(byte);
- int16 decodeOKI(byte);
- int16 decodeMSIMA(byte);
-
-public:
- ADPCMInputStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels = 2, uint32 blockAlign = 0);
- ~ADPCMInputStream() {};
-
- int readBuffer(int16 *buffer, const int numSamples);
- int readBufferOKI(int16 *buffer, const int numSamples);
- int readBufferMSIMA1(int16 *buffer, const int numSamples);
- int readBufferMSIMA2(int16 *buffer, const int numSamples);
-
- bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); }
- bool isStereo() const { return false; }
- int getRate() const { return 22050; }
-};
#endif
diff --git a/sound/wave.cpp b/sound/wave.cpp
index 0923c60c47..f6ba3fed27 100644
--- a/sound/wave.cpp
+++ b/sound/wave.cpp
@@ -165,7 +165,7 @@ AudioStream *makeWAVStream(Common::SeekableReadStream &stream) {
return 0;
if (type == 17) // IMA ADPCM
- return new ADPCMInputStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1);
+ return makeADPCMStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1);
byte *data = (byte *)malloc(size);
assert(data);