[Scummvm-cvs-logs] SF.net SVN: scummvm:[47394] scummvm/trunk
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Jan 19 23:19:48 CET 2010
Revision: 47394
http://scummvm.svn.sourceforge.net/scummvm/?rev=47394&view=rev
Author: fingolfin
Date: 2010-01-19 22:19:43 +0000 (Tue, 19 Jan 2010)
Log Message:
-----------
Get rid of Mixer::playRaw for good
Modified Paths:
--------------
scummvm/trunk/engines/agos/res_snd.cpp
scummvm/trunk/engines/agos/sound.cpp
scummvm/trunk/engines/queen/sound.cpp
scummvm/trunk/engines/scumm/he/sound_he.cpp
scummvm/trunk/engines/scumm/sound.cpp
scummvm/trunk/engines/sky/intro.cpp
scummvm/trunk/engines/sky/sound.cpp
scummvm/trunk/sound/mixer.cpp
scummvm/trunk/sound/mixer.h
scummvm/trunk/sound/mixer_intern.h
Modified: scummvm/trunk/engines/agos/res_snd.cpp
===================================================================
--- scummvm/trunk/engines/agos/res_snd.cpp 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/engines/agos/res_snd.cpp 2010-01-19 22:19:43 UTC (rev 47394)
@@ -23,8 +23,6 @@
*
*/
-
-
#include "common/config-manager.h"
#include "common/file.h"
Modified: scummvm/trunk/engines/agos/sound.cpp
===================================================================
--- scummvm/trunk/engines/agos/sound.cpp 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/engines/agos/sound.cpp 2010-01-19 22:19:43 UTC (rev 47394)
@@ -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 @@
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 @@
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
Modified: scummvm/trunk/engines/queen/sound.cpp
===================================================================
--- scummvm/trunk/engines/queen/sound.cpp 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/engines/queen/sound.cpp 2010-01-19 22:19:43 UTC (rev 47394)
@@ -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 @@
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 @@
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);
}
}
}
Modified: scummvm/trunk/engines/scumm/he/sound_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/sound_he.cpp 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/engines/scumm/he/sound_he.cpp 2010-01-19 22:19:43 UTC (rev 47394)
@@ -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 @@
}
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 @@
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 @@
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 @@
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 @@
_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 @@
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 @@
}
_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 @@
_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) {
Modified: scummvm/trunk/engines/scumm/sound.cpp
===================================================================
--- scummvm/trunk/engines/scumm/sound.cpp 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/engines/scumm/sound.cpp 2010-01-19 22:19:43 UTC (rev 47394)
@@ -203,7 +203,9 @@
// 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 @@
// 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 @@
// 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')) {
Modified: scummvm/trunk/engines/sky/intro.cpp
===================================================================
--- scummvm/trunk/engines/sky/intro.cpp 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/engines/sky/intro.cpp 2010-01-19 22:19:43 UTC (rev 47394)
@@ -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::nextPart(uint16 *&data) {
uint8 *vData = NULL;
+ Audio::AudioStream *stream = 0;
+
// return false means cancel intro
uint16 command = *data++;
switch (command) {
@@ -730,11 +735,13 @@
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 @@
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);
Modified: scummvm/trunk/engines/sky/sound.cpp
===================================================================
--- scummvm/trunk/engines/sky/sound.cpp 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/engines/sky/sound.cpp 2010-01-19 22:19:43 UTC (rev 47394)
@@ -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 @@
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 @@
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;
}
Modified: scummvm/trunk/sound/mixer.cpp
===================================================================
--- scummvm/trunk/sound/mixer.cpp 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/sound/mixer.cpp 2010-01-19 22:19:43 UTC (rev 47394)
@@ -217,22 +217,6 @@
*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,
Modified: scummvm/trunk/sound/mixer.h
===================================================================
--- scummvm/trunk/sound/mixer.h 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/sound/mixer.h 2010-01-19 22:19:43 UTC (rev 47394)
@@ -65,8 +65,8 @@
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,25 +121,7 @@
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.
*
* Note that the sound id assigned below is unique. At most one stream
Modified: scummvm/trunk/sound/mixer_intern.h
===================================================================
--- scummvm/trunk/sound/mixer_intern.h 2010-01-19 20:41:51 UTC (rev 47393)
+++ scummvm/trunk/sound/mixer_intern.h 2010-01-19 22:19:43 UTC (rev 47394)
@@ -74,14 +74,6 @@
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,
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list