[Scummvm-git-logs] scummvm master -> 7f886d51e1d2e877bfe482cd0265981be525f7ac

criezy criezy at scummvm.org
Sat Aug 21 18:17:48 UTC 2021


This automated email contains information about 4 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
4e70c7e687 AGS: Fix playing the same sound again and again in ags_wave
d9cf6e626a AGS: Fix music and sfx being stopped when changing room in Strangeland
0b307e46a4 AGS: Fix music not looping in Strangeland
7f886d51e1 AGS: Add warning about playing overlapping sounds in ags_wave


Commit: 4e70c7e6875d3b092e540319db530ed2226f479c
    https://github.com/scummvm/scummvm/commit/4e70c7e6875d3b092e540319db530ed2226f479c
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-21T19:17:44+01:00

Commit Message:
AGS: Fix playing the same sound again and again in ags_wave

In Strangeland, it seems to start the same sound again and again
(multiple times per second, the sound itself is 45s long). In
ScummVM we were stopping and restarting the sound each time. It
seams the original was only starting the sound if it was not
already playing.

This fixes noise (as we played again and again the first few ms
of the same sound) when starting Strangeland. And this means we
can now hear the music!

Changed paths:
    engines/ags/plugins/ags_waves/sound.cpp


diff --git a/engines/ags/plugins/ags_waves/sound.cpp b/engines/ags/plugins/ags_waves/sound.cpp
index 6e413dac5e..58f4054f13 100644
--- a/engines/ags/plugins/ags_waves/sound.cpp
+++ b/engines/ags/plugins/ags_waves/sound.cpp
@@ -37,6 +37,8 @@ void AGSWaves::SFX_Play(ScriptMethodParams &params) {
 	PARAMS2(int, sfxNum, int, repeat);
 
 	SoundEffect &effect = SFX[sfxNum];
+	if (_mixer->isSoundHandleActive(effect._soundHandle))
+		return;
 	_mixer->stopHandle(effect._soundHandle);
 
 	Common::FSNode fsNode = ::AGS::g_vm->getGameFolder().getChild(


Commit: d9cf6e626a93f9d308ce1fd6f5358580076dbeb2
    https://github.com/scummvm/scummvm/commit/d9cf6e626a93f9d308ce1fd6f5358580076dbeb2
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-21T19:17:44+01:00

Commit Message:
AGS: Fix music and sfx being stopped when changing room in Strangeland

The original is unloading sounds that had already stopped, but is not
stopping the ones still playing.

Changed paths:
    engines/ags/plugins/ags_waves/ags_waves.cpp


diff --git a/engines/ags/plugins/ags_waves/ags_waves.cpp b/engines/ags/plugins/ags_waves/ags_waves.cpp
index e567c57a75..da068c8cef 100644
--- a/engines/ags/plugins/ags_waves/ags_waves.cpp
+++ b/engines/ags/plugins/ags_waves/ags_waves.cpp
@@ -152,7 +152,8 @@ int64 AGSWaves::AGS_EngineOnEvent(int event, NumberPtr data) {
 		break;
 
 	case AGSE_ENTERROOM:
-		stopAllSounds();
+		// The original unloads sfx that are not playing and are not on repeat
+		// I don't think we need to do anything here.
 		break;
 
 	default:


Commit: 0b307e46a4d8cd0076807d0c5b83fadd16994a58
    https://github.com/scummvm/scummvm/commit/0b307e46a4d8cd0076807d0c5b83fadd16994a58
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-21T19:17:44+01:00

Commit Message:
AGS: Fix music not looping in Strangeland

Changed paths:
    engines/ags/plugins/ags_waves/ags_waves.h
    engines/ags/plugins/ags_waves/sound.cpp


diff --git a/engines/ags/plugins/ags_waves/ags_waves.h b/engines/ags/plugins/ags_waves/ags_waves.h
index b5c8269f1d..de7abbf352 100644
--- a/engines/ags/plugins/ags_waves/ags_waves.h
+++ b/engines/ags/plugins/ags_waves/ags_waves.h
@@ -166,6 +166,8 @@ private:
 	 */
 	Audio::AudioStream *loadOGG(const Common::FSNode &fsNode);
 
+	void playStream(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, Audio::AudioStream *stream, int repeat);
+
 	void stopAllSounds();
 	void GlitchFix();
 	void ApplyFilter(int SetFrequency);
diff --git a/engines/ags/plugins/ags_waves/sound.cpp b/engines/ags/plugins/ags_waves/sound.cpp
index 58f4054f13..31824fd0d2 100644
--- a/engines/ags/plugins/ags_waves/sound.cpp
+++ b/engines/ags/plugins/ags_waves/sound.cpp
@@ -49,18 +49,7 @@ void AGSWaves::SFX_Play(ScriptMethodParams &params) {
 	if (sound != nullptr) {
 		effect._volume = 255;
 
-		if (repeat != 0) {
-			Audio::SeekableAudioStream *sas =
-				dynamic_cast<Audio::SeekableAudioStream *>(sound);
-			assert(sas);
-
-			// -1 for infinite, >0 number of successive repeats
-			Audio::LoopingAudioStream *las =
-				new Audio::LoopingAudioStream(sas, repeat + 1);
-			_mixer->playStream(Audio::Mixer::kSFXSoundType, &effect._soundHandle, las);
-		} else {
-			_mixer->playStream(Audio::Mixer::kSFXSoundType, &effect._soundHandle, sound);
-		}
+		playStream(Audio::Mixer::kSFXSoundType, &effect._soundHandle, sound, repeat);
 
 		if (OGG_Filter && effect._filter && effect._volume > 1) {
 			warning("TODO: Mix_RegisterEffect(grabChan, LPEffect, NULL, NULL);");
@@ -194,6 +183,24 @@ Audio::AudioStream *AGSWaves::loadOGG(const Common::FSNode &fsNode) {
 	return nullptr;
 }
 
+void AGSWaves::playStream(Audio::Mixer::SoundType type, Audio::SoundHandle *handle, Audio::AudioStream *stream, int repeat) {
+	if (!handle || !stream)
+		return;
+
+	if (repeat != 0) {
+		Audio::SeekableAudioStream *sas =
+			dynamic_cast<Audio::SeekableAudioStream *>(stream);
+		assert(sas);
+
+		// -1 for infinite, >0 number of successive repeats
+		Audio::LoopingAudioStream *las =
+			new Audio::LoopingAudioStream(sas, repeat + 1);
+		_mixer->playStream(type, handle, las);
+	} else {
+		_mixer->playStream(type, handle, stream);
+	}
+}
+
 void AGSWaves::StopSFX(int sfxNum) {
 	SoundEffect &effect = SFX[sfxNum];
 	_mixer->stopHandle(effect._soundHandle);
@@ -251,8 +258,8 @@ void AGSWaves::MusicPlay(int MusicToPlay, int repeat, int fadeinMS, int fadeoutM
 		if (!MFXStream.Switch) {
 			MFXStream.Channel = 0;
 
-			_mixer->playStream(Audio::Mixer::kMusicSoundType,
-				&MFXStream._soundHandle, musicStream);
+			playStream(Audio::Mixer::kMusicSoundType,
+				&MFXStream._soundHandle, musicStream, repeat);
 
 			MFXStream.ID = MusicToPlay;
 			MFXStream.FadeTime = (fadeinMS / 1000) * 40;
@@ -265,8 +272,8 @@ void AGSWaves::MusicPlay(int MusicToPlay, int repeat, int fadeinMS, int fadeoutM
 			MFXStream.HaltedOne = false;
 			MFXStream.Channel = 1;
 
-			_mixer->playStream(Audio::Mixer::kMusicSoundType,
-				&MFXStream._soundHandle, musicStream);
+			playStream(Audio::Mixer::kMusicSoundType,
+				&MFXStream._soundHandle, musicStream, repeat);
 
 			MFXStream.ID = MusicToPlay;
 			MFXStream.FadeTime = (fadeoutMS / 1000) * 40;


Commit: 7f886d51e1d2e877bfe482cd0265981be525f7ac
    https://github.com/scummvm/scummvm/commit/7f886d51e1d2e877bfe482cd0265981be525f7ac
Author: Thierry Crozat (criezy at scummvm.org)
Date: 2021-08-21T19:17:44+01:00

Commit Message:
AGS: Add warning about playing overlapping sounds in ags_wave

This is currently not implemented, and is not trivial to implement
with the current way we implemented the plugin.

Playing overlapping sound is for example used when moving the cursor
over the buttons in the options or quit dialogs in Strangeland.

Changed paths:
    engines/ags/plugins/ags_waves/sound.cpp


diff --git a/engines/ags/plugins/ags_waves/sound.cpp b/engines/ags/plugins/ags_waves/sound.cpp
index 31824fd0d2..cdb9e8fdbb 100644
--- a/engines/ags/plugins/ags_waves/sound.cpp
+++ b/engines/ags/plugins/ags_waves/sound.cpp
@@ -37,8 +37,14 @@ void AGSWaves::SFX_Play(ScriptMethodParams &params) {
 	PARAMS2(int, sfxNum, int, repeat);
 
 	SoundEffect &effect = SFX[sfxNum];
-	if (_mixer->isSoundHandleActive(effect._soundHandle))
+	if (_mixer->isSoundHandleActive(effect._soundHandle)) {
+		if (effect._allow == 1) {
+			// In this case we should start the sound on a new channel, not stopping
+			// the one currently playing.
+			warning("TODO: play overlapping sound with SFX_Play");
+		}
 		return;
+	}
 	_mixer->stopHandle(effect._soundHandle);
 
 	Common::FSNode fsNode = ::AGS::g_vm->getGameFolder().getChild(
@@ -156,7 +162,8 @@ void AGSWaves::Audio_Remove_Filter(ScriptMethodParams &params) {
 }
 
 void AGSWaves::SFX_AllowOverlap(ScriptMethodParams &params) {
-	//PARAMS2(int, SFX, int, allow);
+	PARAMS2(int, sfxNum, int, allow);
+	SFX[sfxNum]._allow = allow;
 }
 
 void AGSWaves::SFX_Filter(ScriptMethodParams &params) {




More information about the Scummvm-git-logs mailing list