[Scummvm-git-logs] scummvm master -> d42b7b4637463f0d0a411bafd366af0980ac94be
neuromancer
noreply at scummvm.org
Tue Oct 7 22:42:28 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
d42b7b4637 HYPNO: Fix playing music during cutscenes
Commit: d42b7b4637463f0d0a411bafd366af0980ac94be
https://github.com/scummvm/scummvm/commit/d42b7b4637463f0d0a411bafd366af0980ac94be
Author: Cameron Cawley (ccawley2011 at gmail.com)
Date: 2025-10-07T19:42:24-03:00
Commit Message:
HYPNO: Fix playing music during cutscenes
Changed paths:
engines/hypno/actions.cpp
engines/hypno/arcade.cpp
engines/hypno/boyz/arcade.cpp
engines/hypno/hypno.cpp
engines/hypno/hypno.h
engines/hypno/scene.cpp
engines/hypno/spider/spider.cpp
engines/hypno/spider/talk.cpp
engines/hypno/wet/arcade.cpp
engines/hypno/wet/hard.cpp
diff --git a/engines/hypno/actions.cpp b/engines/hypno/actions.cpp
index 71b235f9bc5..afd71b11302 100644
--- a/engines/hypno/actions.cpp
+++ b/engines/hypno/actions.cpp
@@ -136,7 +136,6 @@ void HypnoEngine::runIntro(Intro *a) {
void HypnoEngine::runCutscene(Cutscene *a) {
stopSound();
defaultCursor();
- _music.clear();
MVideo v(a->path, Common::Point(0, 0), false, true, false);
disableCursor();
runIntro(v);
diff --git a/engines/hypno/arcade.cpp b/engines/hypno/arcade.cpp
index 7442ab01329..4197c518711 100644
--- a/engines/hypno/arcade.cpp
+++ b/engines/hypno/arcade.cpp
@@ -550,11 +550,8 @@ void HypnoEngine::runArcade(ArcadeShooting *arc) {
}
}
- if (_music.empty() && !arc->music.empty()) {
- _music = _soundPath + arc->music;
- _musicRate = arc->musicRate;
- _musicStereo = arc->musicStereo;
- playSound(_music, 0, _musicRate, _musicStereo); // music loop forever
+ if (!isMusicActive() && !arc->music.empty()) {
+ playMusic(_soundPath + arc->music, arc->musicRate, arc->musicStereo);
}
if (needsUpdate) {
@@ -609,7 +606,7 @@ void HypnoEngine::runArcade(ArcadeShooting *arc) {
_timerStarted = false;
removeTimers();
stopSound();
- _music.clear();
+ stopMusic();
}
Common::Point HypnoEngine::computeTargetPosition(const Common::Point &mousePos) {
@@ -720,8 +717,6 @@ bool HypnoEngine::shoot(const Common::Point &mousePos, ArcadeShooting *arc, bool
_background->decoder->pauseVideo(false);
updateScreen(*_background);
drawScreen();
- if (!_music.empty())
- playSound(_music, 0, _musicRate, _musicStereo); // restore music
} else if (_objIdx == 1 && !arc->hitBoss2Video.empty()) {
_background->decoder->pauseVideo(true);
MVideo video(arc->hitBoss2Video, Common::Point(0, 0), false, true, false);
@@ -732,8 +727,6 @@ bool HypnoEngine::shoot(const Common::Point &mousePos, ArcadeShooting *arc, bool
updateScreen(*_background);
drawScreen();
drawCursorArcade(mousePos);
- if (!_music.empty())
- playSound(_music, 0, _musicRate, _musicStereo); // restore music
}
byte p[3] = {0x00, 0x00, 0x00}; // Always black?
assert(_shoots[i].paletteSize == 1 || _shoots[i].paletteSize == 0);
diff --git a/engines/hypno/boyz/arcade.cpp b/engines/hypno/boyz/arcade.cpp
index 0d8fac6d7a9..dd21b591685 100644
--- a/engines/hypno/boyz/arcade.cpp
+++ b/engines/hypno/boyz/arcade.cpp
@@ -390,8 +390,6 @@ bool BoyzEngine::checkTransition(ArcadeTransitions &transitions, ArcadeShooting
_background->decoder->pauseVideo(false);
_masks->decoder->pauseVideo(false);
- if (!_music.empty())
- playSound(_music, 0, _musicRate, _musicStereo); // restore music
drawPlayer();
updateScreen(*_background);
drawScreen();
@@ -639,8 +637,6 @@ bool BoyzEngine::shoot(const Common::Point &mousePos, ArcadeShooting *arc, bool
_shootsDestroyed[_shoots[i].name] = true;
updateScreen(*_background);
drawScreen();
- if (!_music.empty())
- playSound(_music, 0, _musicRate, _musicStereo); // restore music
}
} else if (_shoots[i].interactionFrame > 0) {
incFriendliesEncountered();
@@ -685,9 +681,6 @@ bool BoyzEngine::shoot(const Common::Point &mousePos, ArcadeShooting *arc, bool
_background->decoder->pauseVideo(false);
updateScreen(*_background);
drawScreen();
- if (!_music.empty())
- playSound(_music, 0, _musicRate, _musicStereo); // restore music
-
hitPlayer();
}
if (_shoots[i].explosionFrames.size() == 0)
diff --git a/engines/hypno/hypno.cpp b/engines/hypno/hypno.cpp
index 60cc38d008d..0eb33bde496 100644
--- a/engines/hypno/hypno.cpp
+++ b/engines/hypno/hypno.cpp
@@ -58,9 +58,9 @@ HypnoEngine::HypnoEngine(OSystem *syst, const ADGameDescription *gd)
_playerFrameIdx(0), _playerFrameSep(0), _refreshConversation(false),
_countdown(0), _timerStarted(false), _score(0), _bonus(0), _lives(0),
_defaultCursor(""), _defaultCursorIdx(0), _skipDefeatVideo(false),
- _background(nullptr), _masks(nullptr), _musicRate(0), _musicStereo(false),
+ _background(nullptr), _masks(nullptr),
_additionalVideo(nullptr), _ammo(0), _maxAmmo(0), _skipNextVideo(false),
- _doNotStopSounds(false), _screenW(0), _screenH(0), // Every games initializes its own resolution
+ _screenW(0), _screenH(0), // Every games initializes its own resolution
_keepTimerDuringScenes(false), _subtitles(nullptr) {
_rnd = new Common::RandomSource("hypno");
_checkpoint = "";
@@ -192,14 +192,13 @@ void HypnoEngine::runLevel(Common::String &name) {
_prefixDir = _levels[name]->prefix;
stopSound();
- _music.clear();
+ stopMusic();
// Play intros
disableCursor();
if (_levels[name]->playMusicDuringIntro && !_levels[name]->music.empty()) {
- playSound(_levels[name]->music, 0, _levels[name]->musicRate);
- _doNotStopSounds = true;
+ playMusic(_levels[name]->music, _levels[name]->musicRate);
}
debug("Number of videos to play: %d", _levels[name]->intros.size());
@@ -208,8 +207,6 @@ void HypnoEngine::runLevel(Common::String &name) {
runIntro(v);
}
- _doNotStopSounds = false;
-
if (_levels[name]->type == TransitionLevel) {
debugC(1, kHypnoDebugScene, "Executing transition level %s", name.c_str());
runTransition((Transition *)_levels[name]);
@@ -235,8 +232,6 @@ void HypnoEngine::runLevel(Common::String &name) {
void HypnoEngine::runIntros(Videos &videos) {
debugC(1, kHypnoDebugScene, "Starting run intros with %d videos!", videos.size());
Common::Event event;
- if (!_doNotStopSounds)
- stopSound();
bool skip = false;
int clicked[3] = {-1, -1, -1};
int clicks = 0;
@@ -644,12 +639,10 @@ void HypnoEngine::skipVideo(MVideo &video) {
}
// Sound handling
-
-void HypnoEngine::playSound(const Common::String &filename, uint32 loops, uint32 sampleRate, bool stereo) {
- debugC(1, kHypnoDebugMedia, "%s(%s, %d, %d)", __FUNCTION__, filename.c_str(), loops, sampleRate);
+Audio::SeekableAudioStream *HypnoEngine::loadAudioStream(const Common::String &filename, uint32 sampleRate, bool stereo) {
+ debugC(1, kHypnoDebugMedia, "%s(%s, %d)", __FUNCTION__, filename.c_str(), sampleRate);
Common::Path name = convertPath(filename);
- Audio::LoopingAudioStream *stream = nullptr;
Common::File *file = new Common::File();
if (file->open(name)) {
uint32 flags = Audio::FLAG_UNSIGNED;
@@ -662,25 +655,50 @@ void HypnoEngine::playSound(const Common::String &filename, uint32 loops, uint32
sub = new Common::SeekableSubReadStream(file, 0, file->size(), DisposeAfterUse::YES);
}
- stream = new Audio::LoopingAudioStream(Audio::makeRawStream(sub, sampleRate, flags, DisposeAfterUse::YES), loops);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream, -1, Audio::Mixer::kMaxChannelVolume);
+ return Audio::makeRawStream(sub, sampleRate, flags, DisposeAfterUse::YES);
} else {
if (!_prefixDir.empty())
name = _prefixDir.join(name);
if (file->open(name)) {
- stream = new Audio::LoopingAudioStream(Audio::makeRawStream(file, sampleRate, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES), loops);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream, -1, Audio::Mixer::kMaxChannelVolume);
+ return Audio::makeRawStream(file, sampleRate, Audio::FLAG_UNSIGNED, DisposeAfterUse::YES);
} else {
debugC(1, kHypnoDebugMedia, "%s not found!", name.toString().c_str());
delete file;
+ return nullptr;
}
}
}
+void HypnoEngine::playSound(const Common::String &filename, uint32 loops, uint32 sampleRate, bool stereo) {
+ Audio::SeekableAudioStream *stream = loadAudioStream(filename, sampleRate, stereo);
+ if (!stream)
+ return;
+ _mixer->stopHandle(_soundHandle);
+ Audio::LoopingAudioStream *loopstream = new Audio::LoopingAudioStream(stream, loops);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, loopstream, -1, Audio::Mixer::kMaxChannelVolume);
+}
+
+void HypnoEngine::playMusic(const Common::String &filename, uint32 sampleRate, bool stereo) {
+ Audio::SeekableAudioStream *stream = loadAudioStream(filename, sampleRate, stereo);
+ if (!stream)
+ return;
+ _mixer->stopHandle(_musicHandle);
+ Audio::LoopingAudioStream *loopstream = new Audio::LoopingAudioStream(stream, 0);
+ _mixer->playStream(Audio::Mixer::kMusicSoundType, &_musicHandle, loopstream, -1, Audio::Mixer::kMaxChannelVolume);
+}
+
void HypnoEngine::stopSound() {
debugC(1, kHypnoDebugMedia, "%s()", __FUNCTION__);
- _mixer->stopAll();
- //_mixer->stopHandle(_soundHandle);
+ _mixer->stopHandle(_soundHandle);
+}
+
+void HypnoEngine::stopMusic() {
+ debugC(1, kHypnoDebugMedia, "%s()", __FUNCTION__);
+ _mixer->stopHandle(_musicHandle);
+}
+
+bool HypnoEngine::isMusicActive() {
+ return _mixer->isSoundHandleActive(_musicHandle);
}
// Path handling
diff --git a/engines/hypno/hypno.h b/engines/hypno/hypno.h
index 4202cae3db6..995991f2c2b 100644
--- a/engines/hypno/hypno.h
+++ b/engines/hypno/hypno.h
@@ -37,6 +37,10 @@
#include "hypno/grammar.h"
#include "hypno/libfile.h"
+namespace Audio {
+class SeekableAudioStream;
+}
+
namespace Image {
class ImageDecoder;
}
@@ -148,7 +152,7 @@ public:
bool _unlockAllLevels;
bool _restoredContentEnabled;
- Audio::SoundHandle _soundHandle;
+ Audio::SoundHandle _soundHandle, _musicHandle;
Common::InstallShieldV3 _installerArchive;
Common::List<LibFile*> _archive;
@@ -289,12 +293,12 @@ public:
// Sounds
Filename _soundPath;
- Filename _music;
- int _musicRate;
- bool _musicStereo;
- bool _doNotStopSounds;
+ Audio::SeekableAudioStream *loadAudioStream(const Filename &filename, uint32 sampleRate = 22050, bool stereo = false);
void playSound(const Filename &filename, uint32 loops, uint32 sampleRate = 22050, bool stereo = false);
+ void playMusic(const Filename &filename, uint32 sampleRate = 22050, bool stereo = false);
void stopSound();
+ void stopMusic();
+ bool isMusicActive();
// Arcade
Common::String _arcadeMode;
diff --git a/engines/hypno/scene.cpp b/engines/hypno/scene.cpp
index dfcb4b2a5f8..ee6cae0ec16 100644
--- a/engines/hypno/scene.cpp
+++ b/engines/hypno/scene.cpp
@@ -509,11 +509,6 @@ void HypnoEngine::runScene(Scene *scene) {
}
}
- if (_music.empty() && !scene->music.empty() && _videosPlaying.empty() && _nextSequentialVideoToPlay.empty()) {
- _music = scene->music;
- playSound(_music, 0, scene->musicRate);
- }
-
if (!_videosPlaying.empty() || !_videosLooping.empty() || !_nextSequentialVideoToPlay.empty()) {
drawScreen();
continue;
@@ -533,6 +528,10 @@ void HypnoEngine::runScene(Scene *scene) {
drawScreen();
}
+ if (!isMusicActive() && !scene->music.empty()) {
+ playMusic(scene->music, scene->musicRate);
+ }
+
g_system->updateScreen();
g_system->delayMillis(30);
}
diff --git a/engines/hypno/spider/spider.cpp b/engines/hypno/spider/spider.cpp
index c3bcb77a336..bece0c892ec 100644
--- a/engines/hypno/spider/spider.cpp
+++ b/engines/hypno/spider/spider.cpp
@@ -1205,6 +1205,7 @@ void SpiderEngine::loadGame(const Common::String &nextLevel, int score, int puzz
// We don't want to continue with any sound from a previous game
stopSound();
+ stopMusic();
_sceneState["GS_PUZZLELEVEL"] = puzzleDifficulty;
_sceneState["GS_COMBATLEVEL"] = combatDifficulty;
_score = score;
diff --git a/engines/hypno/spider/talk.cpp b/engines/hypno/spider/talk.cpp
index 4fd05b095dc..740040f36d8 100644
--- a/engines/hypno/spider/talk.cpp
+++ b/engines/hypno/spider/talk.cpp
@@ -135,7 +135,6 @@ void SpiderEngine::showConversation() {
}
endConversation();
- _music.clear();
if (shouldEscape) {
runIntros(_escapeSequentialVideoToPlay);
diff --git a/engines/hypno/wet/arcade.cpp b/engines/hypno/wet/arcade.cpp
index f58b8e9ea6c..198f15fb72f 100644
--- a/engines/hypno/wet/arcade.cpp
+++ b/engines/hypno/wet/arcade.cpp
@@ -390,8 +390,6 @@ bool WetEngine::checkTransition(ArcadeTransitions &transitions, ArcadeShooting *
updateScreen(*_background);
drawScreen();
drawCursorArcade(g_system->getEventManager()->getMousePos());
- if (!_music.empty())
- playSound(_music, 0, _musicRate); // restore music
} else
error ("Invalid transition at %d", ttime);
@@ -740,8 +738,6 @@ void WetEngine::pressedKey(const int keycode) {
_background->decoder->pauseVideo(false);
updateScreen(*_background);
drawScreen();
- if (!_music.empty())
- playSound(_music, 0, _musicRate); // restore music
} else if (keycode == kActionSkipLevel) { // Added for testing
_skipLevel = true;
} else if (keycode == kActionKillPlayer) { // Added for testing
@@ -904,8 +900,6 @@ void WetEngine::missNoTarget(ArcadeShooting *arc) {
_background->decoder->pauseVideo(false);
updateScreen(*_background);
drawScreen();
- if (!_music.empty())
- playSound(_music, 0, _musicRate); // restore music
break;
} else if (it->name == "SP_BOSS2" && !arc->missBoss2Video.empty()) {
_background->decoder->pauseVideo(true);
@@ -917,8 +911,6 @@ void WetEngine::missNoTarget(ArcadeShooting *arc) {
_background->decoder->pauseVideo(false);
updateScreen(*_background);
drawScreen();
- if (!_music.empty())
- playSound(_music, 0, _musicRate); // restore music
break;
}
}
diff --git a/engines/hypno/wet/hard.cpp b/engines/hypno/wet/hard.cpp
index 1a5580d3b0f..4f86a54f3ba 100644
--- a/engines/hypno/wet/hard.cpp
+++ b/engines/hypno/wet/hard.cpp
@@ -86,6 +86,7 @@ void WetEngine::runLevelMenu(Code *code) {
loadPalette((byte *) &lime, 192+currentLevel, 1);
drawImage(*menu, 0, 0, false);
bool cont = true;
+ // TODO: Should this be played as music instead?
playSound("sound/bub01.raw", 0, 22050);
Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
More information about the Scummvm-git-logs
mailing list