[Scummvm-git-logs] scummvm master -> b31bd5f231383eb4334a4cfaf539e78090dad48a

ysj1173886760 42030331+ysj1173886760 at users.noreply.github.com
Tue Jul 20 11:34:34 UTC 2021


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

Summary:
b31bd5f231 DIRECTOR: add movingChanging flag to deal with the sound which will playing across the movie.


Commit: b31bd5f231383eb4334a4cfaf539e78090dad48a
    https://github.com/scummvm/scummvm/commit/b31bd5f231383eb4334a4cfaf539e78090dad48a
Author: ysj1173886760 (1173886760 at qq.com)
Date: 2021-07-20T19:34:07+08:00

Commit Message:
DIRECTOR: add movingChanging flag to deal with the sound which will playing across the movie.

Changed paths:
    engines/director/sound.cpp
    engines/director/sound.h
    engines/director/window.cpp


diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index 99e5a0fbea..609328c87f 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -111,7 +111,7 @@ void DirectorSound::playCastMember(CastMemberID memberID, uint8 soundChannel, bo
 			if (soundCast->_type != kCastSound) {
 				warning("DirectorSound::playCastMember: attempted to play a non-SoundCastMember %s", memberID.asString().c_str());
 			} else {
-				if (!allowRepeat && lastPlayingCast(soundChannel) == memberID)
+				if (!allowRepeat && lastPlayingCast(soundChannel) == memberID && !_channels[soundChannel - 1]._movieChanged)
 					return;
 				bool looping = ((SoundCastMember *)soundCast)->_looping;
 				AudioDecoder *ad = ((SoundCastMember *)soundCast)->_audio;
@@ -129,6 +129,7 @@ void DirectorSound::playCastMember(CastMemberID memberID, uint8 soundChannel, bo
 				}
 				playStream(*as, soundChannel);
 				_channels[soundChannel - 1].lastPlayingCast = memberID;
+				_channels[soundChannel - 1]._movieChanged = false;
 			}
 		} else {
 			warning("DirectorSound::playCastMember: couldn't find %s", memberID.asString().c_str());
@@ -252,11 +253,17 @@ void DirectorSound::playExternalSound(AudioDecoder *ad, uint8 soundChannel, uint
 
 	// use castMemberID info to check, castLib -1 represent for externalSound
 	// this should be amended by some kind of union which contains CastMemberID and externalSound info
-	if (isChannelActive(soundChannel) && lastPlayingCast(soundChannel) == CastMemberID(externalSoundID, -1))
+	if (isChannelActive(soundChannel) && (lastPlayingCast(soundChannel) == CastMemberID(externalSoundID, -1)) && !_channels[soundChannel - 1]._movieChanged)
 		return;
 
 	playStream(*(ad->getAudioStream()), soundChannel);
 	_channels[soundChannel - 1].lastPlayingCast = CastMemberID(externalSoundID, -1);
+	_channels[soundChannel - 1]._movieChanged = false;
+}
+
+void DirectorSound::changingMovie() {
+	for (uint i = 0; i < _channels.size(); i++)
+		_channels[i]._movieChanged = true;
 }
 
 CastMemberID DirectorSound::lastPlayingCast(uint8 soundChannel) {
@@ -273,6 +280,7 @@ void DirectorSound::stopSound(uint8 soundChannel) {
 	cancelFade(soundChannel);
 	_mixer->stopHandle(_channels[soundChannel - 1].handle);
 	_channels[soundChannel - 1].lastPlayingCast = CastMemberID(0, 0);
+	_channels[soundChannel - 1]._movieChanged = false;
 	return;
 }
 
@@ -282,6 +290,7 @@ void DirectorSound::stopSound() {
 
 		_mixer->stopHandle(_channels[i].handle);
 		_channels[i].lastPlayingCast = CastMemberID(0, 0);
+		_channels[i]._movieChanged = false;
 	}
 
 	_mixer->stopHandle(_scriptSound);
diff --git a/engines/director/sound.h b/engines/director/sound.h
index 201f321a6d..1c30be2de0 100644
--- a/engines/director/sound.h
+++ b/engines/director/sound.h
@@ -54,7 +54,11 @@ struct SoundChannel {
 	byte volume;
 	FadeParams *fade;
 
-	SoundChannel(): handle(), volume(255), fade(nullptr) {}
+	// this indicate whether the sound is playing across the movie. Because the cast name may be the same while the actual sounds are changing.
+	// And we will override the sound when ever the sound is changing. thus we use a flag to indicate whether the movie is changed.
+	bool _movieChanged;
+
+	SoundChannel(): handle(), volume(255), fade(nullptr), _movieChanged(false) {}
 };
 
 class DirectorSound {
@@ -89,6 +93,7 @@ public:
 	uint8 getSoundLevel(uint8 soundChannel);
 	void setSoundEnabled(bool enabled);
 	void systemBeep();
+	void changingMovie();
 
 	bool getSoundEnabled() { return _enable; }
 
diff --git a/engines/director/window.cpp b/engines/director/window.cpp
index 6ed60a1d52..929765d599 100644
--- a/engines/director/window.cpp
+++ b/engines/director/window.cpp
@@ -38,6 +38,7 @@
 #include "director/channel.h"
 #include "director/sprite.h"
 #include "director/util.h"
+#include "director/sound.h"
 
 namespace Director {
 
@@ -494,6 +495,7 @@ bool Window::step() {
 		} else {
 			delete sharedCast;
 		}
+		g_director->getSoundManager()->changingMovie();
 
 		_nextMovie.movie.clear();
 	}




More information about the Scummvm-git-logs mailing list