aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/agos/res_snd.cpp2
-rw-r--r--engines/agos/sound.cpp11
-rw-r--r--engines/queen/sound.cpp9
-rw-r--r--engines/scumm/he/sound_he.cpp34
-rw-r--r--engines/scumm/sound.cpp10
-rw-r--r--engines/sky/intro.cpp23
-rw-r--r--engines/sky/sound.cpp9
-rw-r--r--sound/mixer.cpp16
-rw-r--r--sound/mixer.h22
-rw-r--r--sound/mixer_intern.h8
10 files changed, 68 insertions, 76 deletions
diff --git a/engines/agos/res_snd.cpp b/engines/agos/res_snd.cpp
index 4f3582b55d..00d677727d 100644
--- a/engines/agos/res_snd.cpp
+++ b/engines/agos/res_snd.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "common/config-manager.h"
#include "common/file.h"
diff --git a/engines/agos/sound.cpp b/engines/agos/sound.cpp
index 5b9257b068..4309b57089 100644
--- a/engines/agos/sound.cpp
+++ b/engines/agos/sound.cpp
@@ -23,8 +23,6 @@
*
*/
-
-
#include "common/file.h"
#include "common/util.h"
@@ -35,6 +33,7 @@
#include "sound/flac.h"
#include "sound/mixer.h"
#include "sound/mp3.h"
+#include "sound/raw.h"
#include "sound/voc.h"
#include "sound/vorbis.h"
#include "sound/wave.h"
@@ -277,7 +276,9 @@ void RawSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType typ
byte *buffer = (byte *)malloc(size);
assert(buffer);
_file->read(buffer, size);
- _mixer->playRaw(type, handle, buffer, size, DisposeAfterUse::YES, 22050, flags);
+
+ Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, size, DisposeAfterUse::YES, 22050, flags);
+ _mixer->playInputStream(type, handle, stream);
}
#ifdef USE_MAD
@@ -743,7 +744,9 @@ void Sound::playRawData(byte *soundData, uint sound, uint size, uint freq) {
byte flags = 0;
if (_vm->getPlatform() == Common::kPlatformPC)
flags = Audio::Mixer::FLAG_UNSIGNED;
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_effectsHandle, buffer, size, DisposeAfterUse::YES, freq, flags);
+
+ Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, size, DisposeAfterUse::YES, freq, flags);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_effectsHandle, stream);
}
// Feeble Files specific
diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp
index b03084f7bc..71467b9f99 100644
--- a/engines/queen/sound.cpp
+++ b/engines/queen/sound.cpp
@@ -39,6 +39,7 @@
#include "sound/flac.h"
#include "sound/mididrv.h"
#include "sound/mp3.h"
+#include "sound/raw.h"
#include "sound/vorbis.h"
#define SB_HEADER_SIZE_V104 110
@@ -328,7 +329,9 @@ void SBSound::playSoundData(Common::File *f, uint32 size, Audio::SoundHandle *so
if (sound) {
f->read(sound, size);
Audio::Mixer::SoundType type = (soundHandle == &_speechHandle) ? Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType;
- _mixer->playRaw(type, soundHandle, sound, size, DisposeAfterUse::YES, 11840, Audio::Mixer::FLAG_UNSIGNED);
+
+ Audio::AudioStream *stream = Audio::makeRawMemoryStream(sound, size, DisposeAfterUse::YES, 11840, Audio::Mixer::FLAG_UNSIGNED);
+ _mixer->playInputStream(type, soundHandle, stream);
}
}
@@ -610,7 +613,9 @@ void AmigaSound::playSound(const char *base) {
uint8 *soundData = (uint8 *)malloc(soundSize);
if (soundData) {
f->read(soundData, soundSize);
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_sfxHandle, soundData, soundSize, DisposeAfterUse::YES, 11025, 0);
+
+ Audio::AudioStream *stream = Audio::makeRawMemoryStream(soundData, soundSize, DisposeAfterUse::YES, 11025, 0);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_sfxHandle, stream);
}
}
}
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index d4e1e407a8..64487568c3 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -41,6 +41,7 @@
#include "sound/mididrv.h"
#include "sound/mixer.h"
#include "sound/mp3.h"
+#include "sound/raw.h"
#include "sound/voc.h"
#include "sound/vorbis.h"
#include "sound/wave.h"
@@ -527,6 +528,7 @@ byte *findSoundTag(uint32 tag, byte *ptr) {
}
void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
+ Audio::AudioStream *stream = 0;
byte *ptr, *spoolPtr;
int size = -1;
int priority, rate;
@@ -572,7 +574,8 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
musicFile.close();
if (_vm->_game.heversion == 70) {
- _mixer->playRaw(type, &_heSoundChannels[heChannel], spoolPtr, size, DisposeAfterUse::NO, 11025, flags, soundID);
+ stream = Audio::makeRawMemoryStream(spoolPtr, size, DisposeAfterUse::NO, 11025, flags);
+ _mixer->playInputStream(type, &_heSoundChannels[heChannel], stream, soundID);
return;
}
}
@@ -591,7 +594,6 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
if (READ_BE_UINT32(ptr) == MKID_BE('RIFF') || READ_BE_UINT32(ptr) == MKID_BE('WSOU')) {
uint16 compType;
int blockAlign;
- char *sound;
int codeOffs = -1;
priority = (soundID > _vm->_numSounds) ? 255 : *(ptr + 18);
@@ -613,9 +615,9 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
ptr += 8;
size = READ_LE_UINT32(ptr + 4);
- Common::MemoryReadStream stream(ptr, size);
+ Common::MemoryReadStream memStream(ptr, size);
- if (!Audio::loadWAVFromStream(stream, size, rate, flags, &compType, &blockAlign)) {
+ if (!Audio::loadWAVFromStream(memStream, size, rate, flags, &compType, &blockAlign)) {
error("playHESound: Not a valid WAV file (%d)", soundID);
}
@@ -642,9 +644,13 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
_mixer->stopHandle(_heSoundChannels[heChannel]);
if (compType == 17) {
- Audio::AudioStream *voxStream = Audio::makeADPCMStream(&stream, false, size, Audio::kADPCMMSIma, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
+ Audio::AudioStream *voxStream = Audio::makeADPCMStream(&memStream, false, size, Audio::kADPCMMSIma, rate, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1, blockAlign);
- sound = (char *)malloc(size * 4);
+ // FIXME: Get rid of this crude hack to turn a ADPCM stream into a raw stream.
+ // It seems it is only there to allow looping -- if that is true, we certainly
+ // can do without it, using a LoopingAudioStream.
+
+ byte *sound = (byte *)malloc(size * 4);
/* On systems where it matters, malloc will return
* even addresses, so the use of (void *) in the
* following cast shuts the compiler from warning
@@ -657,16 +663,16 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
if (_heChannel[heChannel].timer)
_heChannel[heChannel].timer = size * 1000 / rate;
- // makeADPCMStream returns a stream in native endianness, but RawMemoryStream (and playRaw)
+ // makeADPCMStream returns a stream in native endianness, but RawMemoryStream
// defaults to big endian. If we're on a little endian system, set the LE flag.
#ifdef SCUMM_LITTLE_ENDIAN
flags |= Audio::Mixer::FLAG_LITTLE_ENDIAN;
#endif
-
- _mixer->playRaw(type, &_heSoundChannels[heChannel], sound + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags, soundID);
+ stream = Audio::makeRawMemoryStream(sound + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags, 0, 0);
} else {
- _mixer->playRaw(type, &_heSoundChannels[heChannel], ptr + stream.pos() + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags, soundID);
+ stream = Audio::makeRawMemoryStream(ptr + memStream.pos() + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags, 0, 0);
}
+ _mixer->playInputStream(type, &_heSoundChannels[heChannel], stream, soundID);
}
// Support for sound in Humongous Entertainment games
else if (READ_BE_UINT32(ptr) == MKID_BE('DIGI') || READ_BE_UINT32(ptr) == MKID_BE('TALK')) {
@@ -723,7 +729,9 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
}
_mixer->stopHandle(_heSoundChannels[heChannel]);
- _mixer->playRaw(type, &_heSoundChannels[heChannel], ptr + heOffset + 8, size, DisposeAfterUse::NO, rate, flags, soundID);
+
+ stream = Audio::makeRawMemoryStream(ptr + heOffset + 8, size, DisposeAfterUse::NO, rate, flags, 0, 0);
+ _mixer->playInputStream(type, &_heSoundChannels[heChannel], stream, soundID);
}
// Support for PCM music in 3DO versions of Humongous Entertainment games
else if (READ_BE_UINT32(ptr) == MKID_BE('MRAW')) {
@@ -741,7 +749,9 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags)
_mixer->stopID(_currentMusic);
_currentMusic = soundID;
- _mixer->playRaw(Audio::Mixer::kMusicSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, 0, soundID);
+
+ stream = Audio::makeRawMemoryStream(sound, size, DisposeAfterUse::YES, rate, 0);
+ _mixer->playInputStream(Audio::Mixer::kMusicSoundType, NULL, stream, soundID);
}
else if (READ_BE_UINT32(ptr) == MKID_BE('MIDI')) {
if (_vm->_imuse) {
diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp
index 4206ff80d9..788be2d0d6 100644
--- a/engines/scumm/sound.cpp
+++ b/engines/scumm/sound.cpp
@@ -203,7 +203,9 @@ void Sound::playSound(int soundID) {
// Allocate a sound buffer, copy the data into it, and play
sound = (byte *)malloc(size);
memcpy(sound, ptr, size);
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID);
+
+ stream = Audio::makeRawMemoryStream(sound, size, DisposeAfterUse::YES, rate, flags);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID);
}
// WORKAROUND bug # 1311447
else if (READ_BE_UINT32(ptr) == 0x460e200d) {
@@ -225,7 +227,8 @@ void Sound::playSound(int soundID) {
// Allocate a sound buffer, copy the data into it, and play
sound = (byte *)malloc(size);
memcpy(sound, ptr, size);
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID);
+ stream = Audio::makeRawMemoryStream(sound, size, DisposeAfterUse::YES, rate, flags);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID);
}
// Support for sampled sound effects in Monkey Island 1 and 2
else if (READ_BE_UINT32(ptr) == MKID_BE('SBL ')) {
@@ -296,7 +299,8 @@ void Sound::playSound(int soundID) {
// Allocate a sound buffer, copy the data into it, and play
sound = (byte *)malloc(size);
memcpy(sound, ptr + 6, size);
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID);
+ stream = Audio::makeRawMemoryStream(sound, size, DisposeAfterUse::YES, rate, flags);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID);
}
else if ((_vm->_game.platform == Common::kPlatformFMTowns && _vm->_game.version == 3) || READ_BE_UINT32(ptr) == MKID_BE('SOUN') || READ_BE_UINT32(ptr) == MKID_BE('TOWS')) {
diff --git a/engines/sky/intro.cpp b/engines/sky/intro.cpp
index 5e1b432418..a81058692d 100644
--- a/engines/sky/intro.cpp
+++ b/engines/sky/intro.cpp
@@ -38,6 +38,9 @@
#include "sky/struc.h"
#include "sky/text.h"
+#include "sound/audiostream.h"
+#include "sound/raw.h"
+
namespace Sky {
#define SHOWSCREEN 0
@@ -677,6 +680,8 @@ bool Intro::doIntro(bool floppyIntro) {
bool Intro::nextPart(uint16 *&data) {
uint8 *vData = NULL;
+ Audio::AudioStream *stream = 0;
+
// return false means cancel intro
uint16 command = *data++;
switch (command) {
@@ -730,11 +735,13 @@ bool Intro::nextPart(uint16 *&data) {
return false;
vData = _skyDisk->loadFile(*data++);
// HACK: Fill the header with silence. We should
- // probably use _skySound instead of calling playRaw()
+ // probably use _skySound instead of calling playInputStream()
// directly, but this will have to do for now.
memset(vData, 127, sizeof(DataFileHeader));
- _mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_voice, vData, _skyDisk->_lastLoadedFileSize, DisposeAfterUse::YES,
- 11025, Audio::Mixer::FLAG_UNSIGNED, SOUND_VOICE);
+
+ stream = Audio::makeRawMemoryStream(vData, _skyDisk->_lastLoadedFileSize, DisposeAfterUse::YES,
+ 11025, Audio::Mixer::FLAG_UNSIGNED);
+ _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_voice, stream, SOUND_VOICE);
return true;
case WAITVOICE:
while (_mixer->isSoundHandleActive(_voice))
@@ -749,13 +756,15 @@ bool Intro::nextPart(uint16 *&data) {
return true;
case LOOPBG:
_mixer->stopID(SOUND_BG);
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_bgSfx, _bgBuf + 256, _bgSize - 768, DisposeAfterUse::YES,
- 11025, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LOOP, SOUND_BG);
+ stream = Audio::makeRawMemoryStream(_bgBuf + 256, _bgSize - 768, DisposeAfterUse::YES,
+ 11025, Audio::Mixer::FLAG_UNSIGNED | Audio::Mixer::FLAG_LOOP, 0, 0);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSfx, stream, SOUND_BG);
return true;
case PLAYBG:
_mixer->stopID(SOUND_BG);
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_bgSfx, _bgBuf + 256, _bgSize - 768, DisposeAfterUse::YES,
- 11025, Audio::Mixer::FLAG_UNSIGNED, SOUND_BG);
+ stream = Audio::makeRawMemoryStream(_bgBuf + 256, _bgSize - 768, DisposeAfterUse::YES,
+ 11025, Audio::Mixer::FLAG_UNSIGNED);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSfx, stream, SOUND_BG);
return true;
case STOPBG:
_mixer->stopID(SOUND_BG);
diff --git a/engines/sky/sound.cpp b/engines/sky/sound.cpp
index cf5dc78c21..83ddc11a6b 100644
--- a/engines/sky/sound.cpp
+++ b/engines/sky/sound.cpp
@@ -33,6 +33,7 @@
#include "sky/sound.h"
#include "sky/struc.h"
+#include "sound/audiostream.h"
#include "sound/raw.h"
namespace Sky {
@@ -1043,7 +1044,9 @@ void Sound::playSound(uint32 id, byte *sound, uint32 size, Audio::SoundHandle *h
memcpy(buffer, sound+sizeof(DataFileHeader), size);
_mixer->stopID(id);
- _mixer->playRaw(Audio::Mixer::kSFXSoundType, handle, buffer, size, DisposeAfterUse::YES, 11025, flags, id);
+
+ Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, size, DisposeAfterUse::YES, 11025, flags);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, handle, stream, id);
}
void Sound::loadSection(uint8 pSection) {
@@ -1245,7 +1248,9 @@ bool Sound::startSpeech(uint16 textNum) {
rate = 11025;
_mixer->stopID(SOUND_SPEECH);
- _mixer->playRaw(Audio::Mixer::kSpeechSoundType, &_ingameSpeech, playBuffer, speechSize, DisposeAfterUse::YES, rate, Audio::Mixer::FLAG_UNSIGNED, SOUND_SPEECH);
+
+ Audio::AudioStream *stream = Audio::makeRawMemoryStream(playBuffer, speechSize, DisposeAfterUse::YES, rate, Audio::Mixer::FLAG_UNSIGNED);
+ _mixer->playInputStream(Audio::Mixer::kSpeechSoundType, &_ingameSpeech, stream, SOUND_SPEECH);
return true;
}
diff --git a/sound/mixer.cpp b/sound/mixer.cpp
index 05af10c8b9..45b65f1f36 100644
--- a/sound/mixer.cpp
+++ b/sound/mixer.cpp
@@ -217,22 +217,6 @@ void MixerImpl::insertChannel(SoundHandle *handle, Channel *chan) {
*handle = chanHandle;
}
-void MixerImpl::playRaw(
- SoundType type,
- SoundHandle *handle,
- void *sound,
- uint32 size,
- DisposeAfterUse::Flag autofreeBuffer,
- uint rate, byte flags,
- int id, byte volume, int8 balance) {
-
- // Create the audio stream
- AudioStream *stream = makeRawMemoryStream((byte *)sound, size, autofreeBuffer, rate, flags, 0, 0);
-
- // Play it
- playInputStream(type, handle, stream, id, volume, balance, DisposeAfterUse::YES, false, false);
-}
-
void MixerImpl::playInputStream(
SoundType type,
SoundHandle *handle,
diff --git a/sound/mixer.h b/sound/mixer.h
index 381bef214d..9b75928f64 100644
--- a/sound/mixer.h
+++ b/sound/mixer.h
@@ -65,8 +65,8 @@ class Mixer {
public:
/**
* Various flags which can be bit-ORed and then passed to
- * Mixer::playRaw resp. makeRawMemoryStream to control their
- * behavior.
+ * makeRawMemoryStream and some other AudioStream factories
+ * to control their behavior.
*
* Engine authors are advised not to rely on a certain value or
* order of these flags (in particular, do not store them verbatim
@@ -121,24 +121,6 @@ public:
virtual bool isReady() const = 0;
-
- /**
- * Start playing the given raw sound data.
- * Internally, this simply creates an audio input stream wrapping the data
- * (using the makeRawMemoryStream factory function), which is then
- * passed on to playInputStream.
- */
- virtual void playRaw(
- SoundType type,
- SoundHandle *handle,
- void *sound, uint32 size,
- DisposeAfterUse::Flag autofreeBuffer,
- uint rate,
- byte flags,
- int id = -1,
- byte volume = kMaxChannelVolume,
- int8 balance = 0) = 0;
-
/**
* Start playing the given audio input stream.
*
diff --git a/sound/mixer_intern.h b/sound/mixer_intern.h
index 476d9bc28d..a1037f1107 100644
--- a/sound/mixer_intern.h
+++ b/sound/mixer_intern.h
@@ -74,14 +74,6 @@ public:
virtual bool isReady() const { return _mixerReady; }
- virtual void playRaw(
- SoundType type,
- SoundHandle *handle,
- void *sound, uint32 size,
- DisposeAfterUse::Flag autofreeBuffer,
- uint rate, byte flags,
- int id, byte volume, int8 balance);
-
virtual void playInputStream(
SoundType type,
SoundHandle *handle,