aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/scumm/player_mod.cpp5
-rw-r--r--engines/scumm/sound.cpp19
-rw-r--r--sound/decoders/raw.cpp31
-rw-r--r--sound/decoders/raw.h18
-rw-r--r--sound/decoders/voc.cpp24
5 files changed, 39 insertions, 58 deletions
diff --git a/engines/scumm/player_mod.cpp b/engines/scumm/player_mod.cpp
index aeb882296d..c98120a2c0 100644
--- a/engines/scumm/player_mod.cpp
+++ b/engines/scumm/player_mod.cpp
@@ -95,7 +95,10 @@ void Player_MOD::startChannel(int id, void *data, int size, int rate, uint8 vol,
_channels[i].pan = pan;
_channels[i].freq = rate;
_channels[i].ctr = 0;
- _channels[i].input = Audio::makeRawMemoryStream_OLD((const byte*)data, size, rate, 0, loopStart, loopEnd);
+
+ Audio::SeekableAudioStream *stream = Audio::makeRawStream((const byte *)data, size, rate, 0);
+ _channels[i].input = Audio::makeLoopingAudioStream(stream, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate), loopStart == loopEnd ? 1 : 0);
+
// read the first sample
_channels[i].input->readBuffer(&_channels[i].pos, 1);
}
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index 2efab8acdd..eb0ae856c7 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -349,7 +349,8 @@ void Sound::playSound(int soundID) {
}
size -= waveSize;
- stream = Audio::makeRawMemoryStream_OLD(sound, waveSize, rate, Audio::FLAG_UNSIGNED, loopStart, loopEnd);
+ Audio::SeekableAudioStream *s = Audio::makeRawStream(sound, waveSize, rate, Audio::FLAG_UNSIGNED);
+ stream = Audio::makeLoopingAudioStream(s, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate), 0);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, 255, 0);
}
break;
@@ -430,17 +431,21 @@ void Sound::playSound(int soundID) {
int vol = ptr[24] * 4;
int loopStart = 0, loopEnd = 0;
int loopcount = ptr[27];
+
+ memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
+ Audio::SeekableAudioStream *plainStream = Audio::makeRawStream(sound, size, rate, 0);
+
if (loopcount > 1) {
- // TODO: We can only loop once, or infinitely many times, but
- // have no support for a finite number of repetitions.
- // So far, I have seen only 1 and 255 (for infinite repetitions),
- // so maybe this is not really a problem.
loopStart = READ_BE_UINT16(ptr + 10) - READ_BE_UINT16(ptr + 8);
loopEnd = READ_BE_UINT16(ptr + 14);
+
+ // TODO: Currently we will only ever play till "loopEnd", even when we only have
+ // a finite repition count.
+ stream = Audio::makeLoopingAudioStream(plainStream, Audio::Timestamp(0, loopStart, rate), Audio::Timestamp(0, loopEnd, rate), loopcount == 255 ? 0 : loopcount);
+ } else {
+ stream = plainStream;
}
- memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size);
- stream = Audio::makeRawMemoryStream_OLD(sound, size, rate, 0, loopStart, loopEnd);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, vol, 0);
}
else {
diff --git a/sound/decoders/raw.cpp b/sound/decoders/raw.cpp
index 18abfdcb35..df3d178c7e 100644
--- a/sound/decoders/raw.cpp
+++ b/sound/decoders/raw.cpp
@@ -339,37 +339,6 @@ SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
}
}
-
-AudioStream *makeRawMemoryStream_OLD(const byte *ptr, uint32 len,
- int rate, byte flags,
- uint loopStart, uint loopEnd,
- DisposeAfterUse::Flag autoFree
- ) {
- SeekableAudioStream *s = makeRawMemoryStream(ptr, len, rate, flags, autoFree);
-
- if (loopStart != loopEnd) {
- const bool isStereo = (flags & Audio::FLAG_STEREO) != 0;
- const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0;
-
- if (loopEnd == 0)
- loopEnd = len;
- assert(loopStart <= loopEnd);
- assert(loopEnd <= len);
-
- // Verify the buffer sizes are sane
- if (is16Bit && isStereo)
- assert((loopStart & 3) == 0 && (loopEnd & 3) == 0);
- else if (is16Bit || isStereo)
- assert((loopStart & 1) == 0 && (loopEnd & 1) == 0);
-
- const uint32 extRate = s->getRate() * (is16Bit ? 2 : 1) * (isStereo ? 2 : 1);
-
- return new SubLoopingAudioStream(s, 0, Timestamp(0, loopStart, extRate), Timestamp(0, loopEnd, extRate));
- } else {
- return s;
- }
-}
-
#define MAKE_LINEAR_DISK(STEREO, UNSIGNED) \
if (is16Bit) { \
if (isLE) \
diff --git a/sound/decoders/raw.h b/sound/decoders/raw.h
index e6fe0d6abf..92add95131 100644
--- a/sound/decoders/raw.h
+++ b/sound/decoders/raw.h
@@ -86,24 +86,6 @@ SeekableAudioStream *makeRawMemoryStream(const byte *ptr, uint32 len,
);
/**
- * NOTE:
- * This API is considered deprecated.
- *
- * Factory function for a raw PCM AudioStream, which will simply treat all
- * data in the buffer described by ptr and len as raw sample data in the
- * specified format. It will then simply pass this data directly to the mixer,
- * after converting it to the sample format used by the mixer (i.e. 16 bit
- * signed native endian). Optionally supports (infinite) looping of a portion
- * of the data.
- */
-AudioStream *makeRawMemoryStream_OLD(const byte *ptr, uint32 len,
- int rate, byte flags,
- uint loopStart, uint loopEnd,
- DisposeAfterUse::Flag autofreeBuffer = DisposeAfterUse::YES
- );
-
-
-/**
* Struct used to define the audio data to be played by a RawDiskStream.
*/
struct RawDiskStreamAudioBlock {
diff --git a/sound/decoders/voc.cpp b/sound/decoders/voc.cpp
index 23accb010c..9cb59db85f 100644
--- a/sound/decoders/voc.cpp
+++ b/sound/decoders/voc.cpp
@@ -353,7 +353,29 @@ AudioStream *makeVOCStream(Common::SeekableReadStream &stream, byte flags, uint
if (!data)
return 0;
- return makeRawMemoryStream_OLD(data, size, rate, flags, loopStart, loopEnd);
+ SeekableAudioStream *s = Audio::makeRawStream(data, size, rate, flags);
+
+ if (loopStart != loopEnd) {
+ const bool isStereo = (flags & Audio::FLAG_STEREO) != 0;
+ const bool is16Bit = (flags & Audio::FLAG_16BITS) != 0;
+
+ if (loopEnd == 0)
+ loopEnd = size;
+ assert(loopStart <= loopEnd);
+ assert(loopEnd <= (uint)size);
+
+ // Verify the buffer sizes are sane
+ if (is16Bit && isStereo)
+ assert((loopStart & 3) == 0 && (loopEnd & 3) == 0);
+ else if (is16Bit || isStereo)
+ assert((loopStart & 1) == 0 && (loopEnd & 1) == 0);
+
+ const uint32 extRate = s->getRate() * (is16Bit ? 2 : 1) * (isStereo ? 2 : 1);
+
+ return new SubLoopingAudioStream(s, 0, Timestamp(0, loopStart, extRate), Timestamp(0, loopEnd, extRate));
+ } else {
+ return s;
+ }
#endif
}