[Scummvm-git-logs] scummvm master -> 93f78c4e5735ca819323bc334362fe102a5982da
sev-
sev at scummvm.org
Tue Oct 27 17:16:16 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
dbb668dc3b SCUMM: Add music override
8fda85894b SCUMM: Add support for more formats on sound override
93f78c4e57 SCUMM: Add compile-time check for array size
Commit: dbb668dc3b234c77ba915c4ad18809bbb31f51bc
https://github.com/scummvm/scummvm/commit/dbb668dc3b234c77ba915c4ad18809bbb31f51bc
Author: YYxsCnnPP (YYxsCnnPP at users.noreply.github.com)
Date: 2020-10-27T18:15:54+01:00
Commit Message:
SCUMM: Add music override
Changed paths:
engines/scumm/he/sound_he.cpp
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index 07a81f5310..910aee3e62 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -716,6 +716,18 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags,
_overrideFreq = 0;
}
+ Common::File musicFileOverride;
+ Common::String mfoBuf(Common::String::format("music%d.wav", soundID));
+
+ if (musicFileOverride.exists(mfoBuf) && musicFileOverride.open(mfoBuf)) {
+ musicFileOverride.seek(0, SEEK_SET);
+ Common::SeekableReadStream *oStr =
+ musicFileOverride.readStream(musicFileOverride.size());
+ musicFileOverride.close();
+
+ stream = Audio::makeWAVStream(oStr, DisposeAfterUse::YES);
+ }
+
_vm->setHETimer(heChannel + 4);
_heChannel[heChannel].sound = soundID;
_heChannel[heChannel].priority = priority;
@@ -733,7 +745,9 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags,
_mixer->stopHandle(_heSoundChannels[heChannel]);
- stream = Audio::makeRawStream(ptr + heOffset + 8, size, rate, flags, DisposeAfterUse::NO);
+ if (!stream) {
+ stream = Audio::makeRawStream(ptr + heOffset + 8, size, rate, flags, DisposeAfterUse::NO);
+ }
_mixer->playStream(type, &_heSoundChannels[heChannel],
Audio::makeLoopingAudioStream(stream, (heFlags & 1) ? 0 : 1), soundID);
}
Commit: 8fda85894b3250f057d08d310b092fda3ad23483
https://github.com/scummvm/scummvm/commit/8fda85894b3250f057d08d310b092fda3ad23483
Author: YYxsCnnPP (YYxsCnnPP at users.noreply.github.com)
Date: 2020-10-27T18:15:54+01:00
Commit Message:
SCUMM: Add support for more formats on sound override
Changed paths:
engines/scumm/he/sound_he.cpp
engines/scumm/he/sound_he.h
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index 910aee3e62..ac5dfc1419 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -39,6 +39,9 @@
#include "audio/mixer.h"
#include "audio/decoders/raw.h"
#include "audio/decoders/wave.h"
+#include "audio/decoders/mp3.h"
+#include "audio/decoders/vorbis.h"
+#include "audio/decoders/flac.h"
namespace Scumm {
@@ -716,17 +719,7 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags,
_overrideFreq = 0;
}
- Common::File musicFileOverride;
- Common::String mfoBuf(Common::String::format("music%d.wav", soundID));
-
- if (musicFileOverride.exists(mfoBuf) && musicFileOverride.open(mfoBuf)) {
- musicFileOverride.seek(0, SEEK_SET);
- Common::SeekableReadStream *oStr =
- musicFileOverride.readStream(musicFileOverride.size());
- musicFileOverride.close();
-
- stream = Audio::makeWAVStream(oStr, DisposeAfterUse::YES);
- }
+ tryLoadSoundOverride(soundID, &stream);
_vm->setHETimer(heChannel + 4);
_heChannel[heChannel].sound = soundID;
@@ -787,6 +780,55 @@ void SoundHE::playHESound(int soundID, int heOffset, int heChannel, int heFlags,
}
}
+void SoundHE::tryLoadSoundOverride(int soundID, Audio::RewindableAudioStream **stream) {
+ const char *formats[] = {
+#ifdef USE_FLAC
+ "flac",
+#endif
+ "wav",
+#ifdef USE_VORBIS
+ "ogg",
+#endif
+#ifdef USE_MAD
+ "mp3",
+#endif
+ };
+
+ Audio::SeekableAudioStream *(*formatDecoders[])(Common::SeekableReadStream *, DisposeAfterUse::Flag) = {
+#ifdef USE_FLAC
+ Audio::makeFLACStream,
+#endif
+ Audio::makeWAVStream,
+#ifdef USE_VORBIS
+ Audio::makeVorbisStream,
+#endif
+#ifdef USE_MAD
+ Audio::makeMP3Stream,
+#endif
+ };
+
+ for (size_t i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) {
+ debug(5, "tryLoadSoundOverride: %d %s", soundID, formats[i]);
+
+ Common::File soundFileOverride;
+ Common::String buf(Common::String::format("sound%d.%s", soundID, formats[i]));
+
+ // First check if the file exists before opening it to
+ // reduce the amount of "opening %s failed" in the console.
+ if (soundFileOverride.exists(buf) && soundFileOverride.open(buf)) {
+ soundFileOverride.seek(0, SEEK_SET);
+ Common::SeekableReadStream *oStr = soundFileOverride.readStream(soundFileOverride.size());
+ soundFileOverride.close();
+
+ *stream = formatDecoders[i](oStr, DisposeAfterUse::YES);
+ debug(5, "tryLoadSoundOverride: %s loaded", formats[i]);
+ return;
+ }
+ }
+
+ debug(5, "tryLoadSoundOverride: file not found");
+}
+
void SoundHE::startHETalkSound(uint32 offset) {
byte *ptr;
int32 size;
diff --git a/engines/scumm/he/sound_he.h b/engines/scumm/he/sound_he.h
index 5dda92059b..dcfe62fe85 100644
--- a/engines/scumm/he/sound_he.h
+++ b/engines/scumm/he/sound_he.h
@@ -25,6 +25,7 @@
#include "common/scummsys.h"
#include "scumm/sound.h"
+#include "audio/audiostream.h"
namespace Scumm {
@@ -85,6 +86,9 @@ public:
protected:
void processSoundQueues() override;
+
+private:
+ void tryLoadSoundOverride(int soundID, Audio::RewindableAudioStream **stream);
};
Commit: 93f78c4e5735ca819323bc334362fe102a5982da
https://github.com/scummvm/scummvm/commit/93f78c4e5735ca819323bc334362fe102a5982da
Author: YYxsCnnPP (YYxsCnnPP at users.noreply.github.com)
Date: 2020-10-27T18:15:54+01:00
Commit Message:
SCUMM: Add compile-time check for array size
Changed paths:
engines/scumm/he/sound_he.cpp
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index ac5dfc1419..c75b59129a 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -807,7 +807,12 @@ void SoundHE::tryLoadSoundOverride(int soundID, Audio::RewindableAudioStream **s
#endif
};
- for (size_t i = 0; i < sizeof(formats) / sizeof(formats[0]); i++) {
+ STATIC_ASSERT(
+ ARRAYSIZE(formats) == ARRAYSIZE(formatDecoders),
+ formats_formatDecoders_must_have_same_size
+ );
+
+ for (int i = 0; i < ARRAYSIZE(formats); i++) {
debug(5, "tryLoadSoundOverride: %d %s", soundID, formats[i]);
Common::File soundFileOverride;
More information about the Scummvm-git-logs
mailing list