[Scummvm-cvs-logs] SF.net SVN: scummvm:[47397] scummvm/trunk/engines
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Wed Jan 20 00:50:34 CET 2010
Revision: 47397
http://scummvm.svn.sourceforge.net/scummvm/?rev=47397&view=rev
Author: fingolfin
Date: 2010-01-19 23:50:33 +0000 (Tue, 19 Jan 2010)
Log Message:
-----------
Started to get rid of Audio::FLAG_LOOP
Modified Paths:
--------------
scummvm/trunk/engines/draci/sound.cpp
scummvm/trunk/engines/m4/sound.cpp
scummvm/trunk/engines/made/resource.cpp
scummvm/trunk/engines/mohawk/sound.cpp
scummvm/trunk/engines/saga/sound.cpp
scummvm/trunk/engines/saga/sound.h
scummvm/trunk/engines/scumm/he/sound_he.cpp
scummvm/trunk/engines/sky/intro.cpp
scummvm/trunk/engines/sword1/sound.cpp
Modified: scummvm/trunk/engines/draci/sound.cpp
===================================================================
--- scummvm/trunk/engines/draci/sound.cpp 2010-01-19 23:48:55 UTC (rev 47396)
+++ scummvm/trunk/engines/draci/sound.cpp 2010-01-19 23:50:33 UTC (rev 47397)
@@ -197,14 +197,13 @@
byte flags = Audio::FLAG_UNSIGNED;
- if (loop)
- flags |= Audio::FLAG_LOOP;
-
const Audio::Mixer::SoundType soundType = (handleType == kVoiceHandle) ?
Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType;
// Don't use DisposeAfterUse::YES, because our caching system deletes samples by itself.
- Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer._data, buffer._length, DisposeAfterUse::NO, buffer._frequency, flags, 0, 0);
+ Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
+ Audio::makeRawMemoryStream(buffer._data, buffer._length, DisposeAfterUse::NO, buffer._frequency, flags),
+ loop ? 0 : 1);
_mixer->playInputStream(soundType, handle, stream, -1, volume);
}
Modified: scummvm/trunk/engines/m4/sound.cpp
===================================================================
--- scummvm/trunk/engines/m4/sound.cpp 2010-01-19 23:48:55 UTC (rev 47396)
+++ scummvm/trunk/engines/m4/sound.cpp 2010-01-19 23:50:33 UTC (rev 47397)
@@ -70,7 +70,6 @@
}
void Sound::playSound(const char *soundName, int volume, bool loop, int channel) {
- byte flags;
Common::SeekableReadStream *soundStream = _vm->res()->get(soundName);
SndHandle *handle;
if (channel < 0) {
@@ -90,15 +89,13 @@
_vm->res()->toss(soundName);
handle->type = kEffectHandle;
- flags = Audio::FLAG_UNSIGNED;
- if (loop)
- flags |= Audio::FLAG_LOOP;
-
_vm->res()->toss(soundName);
// Sound format is 8bit mono, unsigned, 11025kHz
- Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, bufferSize, DisposeAfterUse::YES, 11025, flags, 0, 0);
+ Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
+ Audio::makeRawMemoryStream(buffer, bufferSize, DisposeAfterUse::YES, 11025, Audio::FLAG_UNSIGNED),
+ loop ? 0 : 1);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume);
}
@@ -137,7 +134,6 @@
}
void Sound::playVoice(const char *soundName, int volume) {
- byte flags;
Common::SeekableReadStream *soundStream = _vm->res()->get(soundName);
SndHandle *handle = getHandle();
byte *buffer;
@@ -146,12 +142,11 @@
soundStream->read(buffer, soundStream->size());
handle->type = kEffectHandle;
- flags = Audio::FLAG_UNSIGNED;
_vm->res()->toss(soundName);
// Voice format is 8bit mono, unsigned, 11025kHz
- Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, soundStream->size(), DisposeAfterUse::YES, 11025, flags);
+ Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, soundStream->size(), DisposeAfterUse::YES, 11025, Audio::FLAG_UNSIGNED);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume);
}
@@ -246,15 +241,10 @@
return;
}
- byte flags;
SndHandle *handle = getHandle();
handle->type = kEffectHandle;
- flags = Audio::FLAG_UNSIGNED;
- if (loop)
- flags |= Audio::FLAG_LOOP;
-
// Get sound data
FabDecompressor fab;
byte *compData = new byte[_dsrFile.dsrEntries[soundIndex]->compSize];
@@ -268,9 +258,11 @@
buffer, _dsrFile.dsrEntries[soundIndex]->uncompSize);
// Play sound
- Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer,
+ Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
+ Audio::makeRawMemoryStream(buffer,
_dsrFile.dsrEntries[soundIndex]->uncompSize, DisposeAfterUse::YES,
- _dsrFile.dsrEntries[soundIndex]->frequency, flags, 0, 0);
+ _dsrFile.dsrEntries[soundIndex]->frequency, Audio::FLAG_UNSIGNED),
+ loop ? 0 : 1);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume);
/*
Modified: scummvm/trunk/engines/made/resource.cpp
===================================================================
--- scummvm/trunk/engines/made/resource.cpp 2010-01-19 23:48:55 UTC (rev 47396)
+++ scummvm/trunk/engines/made/resource.cpp 2010-01-19 23:50:33 UTC (rev 47397)
@@ -261,11 +261,13 @@
}
Audio::AudioStream *SoundResource::getAudioStream(int soundRate, bool loop) {
- byte flags = Audio::FLAG_UNSIGNED;
+ Audio::RewindableAudioStream *stream =
+ Audio::makeRawMemoryStream(_soundData, _soundSize, DisposeAfterUse::NO, soundRate, Audio::FLAG_UNSIGNED);
+
if (loop)
- flags |= Audio::FLAG_LOOP;
-
- return Audio::makeRawMemoryStream(_soundData, _soundSize, DisposeAfterUse::NO, soundRate, flags, 0, 0);
+ return Audio::makeLoopingAudioStream(stream, 0);
+ else
+ return stream;
}
void SoundResourceV1::load(byte *source, int size) {
Modified: scummvm/trunk/engines/mohawk/sound.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/sound.cpp 2010-01-19 23:48:55 UTC (rev 47396)
+++ scummvm/trunk/engines/mohawk/sound.cpp 2010-01-19 23:50:33 UTC (rev 47397)
@@ -481,12 +481,9 @@
stream->read(data, size);
delete stream;
- byte flags = Audio::FLAG_UNSIGNED;
-
- if (loop)
- flags |= Audio::FLAG_LOOP;
-
- return Audio::makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, flags, 0, 0);
+ return Audio::makeLoopingAudioStream(
+ Audio::makeRawMemoryStream(data, size, DisposeAfterUse::YES, rate, Audio::FLAG_UNSIGNED),
+ loop ? 0 : 1);
}
SndHandle *Sound::getHandle() {
Modified: scummvm/trunk/engines/saga/sound.cpp
===================================================================
--- scummvm/trunk/engines/saga/sound.cpp 2010-01-19 23:48:55 UTC (rev 47396)
+++ scummvm/trunk/engines/saga/sound.cpp 2010-01-19 23:50:33 UTC (rev 47397)
@@ -64,19 +64,18 @@
return NULL; // for compilers that don't support NORETURN
}
-void Sound::playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume,
+void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundBuffer &buffer, int volume,
sndHandleType handleType, bool loop) {
Audio::AudioStream *stream = 0;
- if (loop)
- buffer.flags |= Audio::FLAG_LOOP;
-
Audio::Mixer::SoundType soundType = (handleType == kVoiceHandle) ?
Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType;
if (!buffer.isCompressed) {
- stream = Audio::makeRawMemoryStream(buffer.buffer, buffer.size, DisposeAfterUse::YES, buffer.frequency, buffer.flags, 0, 0);
+ stream = Audio::makeLoopingAudioStream(
+ Audio::makeRawMemoryStream(buffer.buffer, buffer.size, DisposeAfterUse::YES, buffer.frequency, buffer.flags),
+ loop ? 0 : 1);
} else {
// TODO / FIXME: It seems we don't loop compressed audio at all, but do loop uncompressed data.
Modified: scummvm/trunk/engines/saga/sound.h
===================================================================
--- scummvm/trunk/engines/saga/sound.h 2010-01-19 23:48:55 UTC (rev 47396)
+++ scummvm/trunk/engines/saga/sound.h 2010-01-19 23:50:33 UTC (rev 47397)
@@ -87,7 +87,7 @@
private:
- void playSoundBuffer(Audio::SoundHandle *handle, SoundBuffer &buffer, int volume,
+ void playSoundBuffer(Audio::SoundHandle *handle, const SoundBuffer &buffer, int volume,
sndHandleType handleType, bool loop);
SndHandle *getHandle();
Modified: scummvm/trunk/engines/scumm/he/sound_he.cpp
===================================================================
--- scummvm/trunk/engines/scumm/he/sound_he.cpp 2010-01-19 23:48:55 UTC (rev 47396)
+++ scummvm/trunk/engines/scumm/he/sound_he.cpp 2010-01-19 23:50:33 UTC (rev 47397)
@@ -528,7 +528,7 @@
}
void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
- Audio::AudioStream *stream = 0;
+ Audio::RewindableAudioStream *stream = 0;
byte *ptr, *spoolPtr;
int size = -1;
int priority, rate;
@@ -636,7 +636,6 @@
// TODO: Extra sound flags
if (heFlags & 1) {
- flags |= Audio::FLAG_LOOP;
_heChannel[heChannel].timer = 0;
} else {
_heChannel[heChannel].timer = size * 1000 / rate;
@@ -668,11 +667,12 @@
#ifdef SCUMM_LITTLE_ENDIAN
flags |= Audio::FLAG_LITTLE_ENDIAN;
#endif
- stream = Audio::makeRawMemoryStream(sound + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags, 0, 0);
+ stream = Audio::makeRawMemoryStream(sound + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags);
} else {
- stream = Audio::makeRawMemoryStream(ptr + memStream.pos() + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags, 0, 0);
+ stream = Audio::makeRawMemoryStream(ptr + memStream.pos() + heOffset, size - heOffset, DisposeAfterUse::YES, rate, flags);
}
- _mixer->playInputStream(type, &_heSoundChannels[heChannel], stream, soundID);
+ _mixer->playInputStream(type, &_heSoundChannels[heChannel],
+ Audio::makeLoopingAudioStream(stream, (heFlags & 1) ? 0 : 1), soundID);
}
// Support for sound in Humongous Entertainment games
else if (READ_BE_UINT32(ptr) == MKID_BE('DIGI') || READ_BE_UINT32(ptr) == MKID_BE('TALK')) {
@@ -722,7 +722,6 @@
// TODO: Extra sound flags
if (heFlags & 1) {
- flags |= Audio::FLAG_LOOP;
_heChannel[heChannel].timer = 0;
} else {
_heChannel[heChannel].timer = size * 1000 / rate;
@@ -730,8 +729,9 @@
_mixer->stopHandle(_heSoundChannels[heChannel]);
- stream = Audio::makeRawMemoryStream(ptr + heOffset + 8, size, DisposeAfterUse::NO, rate, flags, 0, 0);
- _mixer->playInputStream(type, &_heSoundChannels[heChannel], stream, soundID);
+ stream = Audio::makeRawMemoryStream(ptr + heOffset + 8, size, DisposeAfterUse::NO, rate, flags);
+ _mixer->playInputStream(type, &_heSoundChannels[heChannel],
+ Audio::makeLoopingAudioStream(stream, (heFlags & 1) ? 0 : 1), soundID);
}
// Support for PCM music in 3DO versions of Humongous Entertainment games
else if (READ_BE_UINT32(ptr) == MKID_BE('MRAW')) {
Modified: scummvm/trunk/engines/sky/intro.cpp
===================================================================
--- scummvm/trunk/engines/sky/intro.cpp 2010-01-19 23:48:55 UTC (rev 47396)
+++ scummvm/trunk/engines/sky/intro.cpp 2010-01-19 23:50:33 UTC (rev 47397)
@@ -680,7 +680,7 @@
bool Intro::nextPart(uint16 *&data) {
uint8 *vData = NULL;
- Audio::AudioStream *stream = 0;
+ Audio::RewindableAudioStream *stream = 0;
// return false means cancel intro
uint16 command = *data++;
@@ -757,8 +757,8 @@
case LOOPBG:
_mixer->stopID(SOUND_BG);
stream = Audio::makeRawMemoryStream(_bgBuf + 256, _bgSize - 768, DisposeAfterUse::YES,
- 11025, Audio::FLAG_UNSIGNED | Audio::FLAG_LOOP, 0, 0);
- _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSfx, stream, SOUND_BG);
+ 11025, Audio::FLAG_UNSIGNED);
+ _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_bgSfx, Audio::makeLoopingAudioStream(stream, 0), SOUND_BG);
return true;
case PLAYBG:
_mixer->stopID(SOUND_BG);
Modified: scummvm/trunk/engines/sword1/sound.cpp
===================================================================
--- scummvm/trunk/engines/sword1/sound.cpp 2010-01-19 23:48:55 UTC (rev 47396)
+++ scummvm/trunk/engines/sword1/sound.cpp 2010-01-19 23:50:33 UTC (rev 47397)
@@ -270,9 +270,9 @@
flags = Audio::FLAG_UNSIGNED;
if (READ_LE_UINT16(sampleData + 0x16) == 2)
flags |= Audio::FLAG_STEREO;
- if (_fxList[elem->id].type == FX_LOOP)
- flags |= Audio::FLAG_LOOP;
- Audio::AudioStream *stream = Audio::makeRawMemoryStream(sampleData + 0x2C, size, DisposeAfterUse::NO, 11025, flags, 0, 0);
+ Audio::AudioStream *stream = Audio::makeLoopingAudioStream(
+ Audio::makeRawMemoryStream(sampleData + 0x2C, size, DisposeAfterUse::NO, 11025, flags),
+ (_fxList[elem->id].type == FX_LOOP) ? 0 : 1);
_mixer->playInputStream(Audio::Mixer::kSFXSoundType, &elem->handle, stream, elem->id, volume, pan);
}
}
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