[Scummvm-git-logs] scummvm master -> 0a9282695757324431ea07bceb5176b0adadc123

djsrv dservilla at gmail.com
Thu Aug 12 17:18:55 UTC 2021


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

Summary:
b40233ffe7 COMMON: Create DisposablePtr::disownPtr()
9c6fa32c82 COMMON: Create DisposablePtr::getDispose()
22775dff7e AUDIO: Create Mixer::loopChannel()
50c7cefc2c DIRECTOR: Keep playing sounds when movie switches
0a92826957 DIRECTOR: Fix whitespace


Commit: b40233ffe7b2583634edb7ff5d4b653283cba7c1
    https://github.com/scummvm/scummvm/commit/b40233ffe7b2583634edb7ff5d4b653283cba7c1
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-12T13:18:27-04:00

Commit Message:
COMMON: Create DisposablePtr::disownPtr()

Changed paths:
    common/ptr.h


diff --git a/common/ptr.h b/common/ptr.h
index 84552f7f67..1ce966c7f8 100644
--- a/common/ptr.h
+++ b/common/ptr.h
@@ -475,6 +475,14 @@ public:
 		reset(nullptr, DisposeAfterUse::NO);
 	}
 
+	/**
+	 * Clears the pointer without destroying the old object.
+	 */
+	void disownPtr() {
+		_pointer = nullptr;
+		_dispose = DisposeAfterUse::NO;
+	}
+
 	/**
 	 * Returns the plain pointer value.
 	 *


Commit: 9c6fa32c8245faa58ab32d0090ca0c424816d81f
    https://github.com/scummvm/scummvm/commit/9c6fa32c8245faa58ab32d0090ca0c424816d81f
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-12T13:18:27-04:00

Commit Message:
COMMON: Create DisposablePtr::getDispose()

Changed paths:
    common/ptr.h


diff --git a/common/ptr.h b/common/ptr.h
index 1ce966c7f8..4196bb7659 100644
--- a/common/ptr.h
+++ b/common/ptr.h
@@ -490,6 +490,11 @@ public:
 	 */
 	PointerType get() const { return _pointer; }
 
+	/**
+	 * Returns the pointer's dispose flag.
+	 */
+	DisposeAfterUse::Flag getDispose() const { return _dispose; }
+
 private:
 	PointerType           _pointer;
 	DisposeAfterUse::Flag _dispose;


Commit: 22775dff7e372e465be8d7e2d0ab4c6f5ab90cc9
    https://github.com/scummvm/scummvm/commit/22775dff7e372e465be8d7e2d0ab4c6f5ab90cc9
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-12T13:18:27-04:00

Commit Message:
AUDIO: Create Mixer::loopChannel()

Changed paths:
    audio/mixer.cpp
    audio/mixer.h
    audio/mixer_intern.h


diff --git a/audio/mixer.cpp b/audio/mixer.cpp
index 28b569eb6b..93aabfc370 100644
--- a/audio/mixer.cpp
+++ b/audio/mixer.cpp
@@ -126,6 +126,11 @@ public:
 	 */
 	Timestamp getElapsedTime();
 
+	/**
+	 * Replaces the channel's stream with a version that loops indefinitely.
+	 */
+	void loop();
+
 	/**
 	 * Queries the channel's sound type.
 	 */
@@ -397,6 +402,16 @@ Timestamp MixerImpl::getElapsedTime(SoundHandle handle) {
 	return _channels[index]->getElapsedTime();
 }
 
+void MixerImpl::loopChannel(SoundHandle handle) {
+	Common::StackLock lock(_mutex);
+
+	const int index = handle._val % NUM_CHANNELS;
+	if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
+		return;
+
+	_channels[index]->loop();
+}
+
 void MixerImpl::pauseAll(bool paused) {
 	Common::StackLock lock(_mutex);
 	for (int i = 0; i != NUM_CHANNELS; i++) {
@@ -604,6 +619,18 @@ Timestamp Channel::getElapsedTime() {
 	return ts;
 }
 
+void Channel::loop() {
+	assert(_stream);
+
+	Audio::RewindableAudioStream *rewindableStream = dynamic_cast<RewindableAudioStream *>(_stream.get());
+	if (rewindableStream) {
+		DisposeAfterUse::Flag dispose = _stream.getDispose();
+		_stream.disownPtr();
+		Audio::LoopingAudioStream *loopingStream = new Audio::LoopingAudioStream(rewindableStream, 0, dispose, false);
+		_stream.reset(loopingStream, DisposeAfterUse::YES);
+	}
+}
+
 int Channel::mix(int16 *data, uint len) {
 	assert(_stream);
 
diff --git a/audio/mixer.h b/audio/mixer.h
index 5af650ac67..10ccd6181b 100644
--- a/audio/mixer.h
+++ b/audio/mixer.h
@@ -265,6 +265,11 @@ public:
 	 */
 	virtual Timestamp getElapsedTime(SoundHandle handle) = 0;
 
+	/**
+	 * Replace the channel's stream with a version that loops indefinitely.
+	 */
+	virtual void loopChannel(SoundHandle handle) = 0;
+
 	/**
 	 * Check whether any channel of the given sound type is active.
 	 *
diff --git a/audio/mixer_intern.h b/audio/mixer_intern.h
index 92f74eeeec..9856d93ee7 100644
--- a/audio/mixer_intern.h
+++ b/audio/mixer_intern.h
@@ -121,6 +121,8 @@ public:
 	virtual uint32 getSoundElapsedTime(SoundHandle handle);
 	virtual Timestamp getElapsedTime(SoundHandle handle);
 
+	virtual void loopChannel(SoundHandle handle);
+
 	virtual bool hasActiveChannelOfType(SoundType type);
 
 	virtual void setVolumeForSoundType(SoundType type, int volume);


Commit: 50c7cefc2cf94965cfe415fb7510656eeb674e86
    https://github.com/scummvm/scummvm/commit/50c7cefc2cf94965cfe415fb7510656eeb674e86
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-12T13:18:27-04:00

Commit Message:
DIRECTOR: Keep playing sounds when movie switches

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


diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index d8dbdede4f..68a6dea5e0 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -383,9 +383,24 @@ void DirectorSound::playExternalSound(uint16 menu, uint16 submenu, uint8 soundCh
 }
 
 void DirectorSound::changingMovie() {
-	for (uint i = 0; i < _channels.size(); i++) {
-		setPuppetSound(SoundID(), i + 1); // disable puppet sound
-		_channels[i].movieChanged = true;
+	for (uint i = 1; i < _channels.size(); i++) {
+		_channels[i - 1].movieChanged = true;
+		if (isChannelPuppet(i)) {
+			setPuppetSound(SoundID(), i); // disable puppet sound
+		} else if (isChannelActive(i)) {
+			// Don't stop this sound until there's a new, non-zero sound in this channel.
+			_channels[i - 1].stopOnZero = false;
+
+			// If this is a looping sound, make it loop automatically until that happens.
+			const SoundID &lastPlayedSound = _channels[i - 1].lastPlayedSound;
+			if (lastPlayedSound.type == kSoundCast) {
+				CastMemberID memberID(lastPlayedSound.u.cast.member, lastPlayedSound.u.cast.castLib);
+				CastMember *soundCast = _window->getCurrentMovie()->getCastMember(memberID);
+				if (soundCast && soundCast->_type == kCastSound && static_cast<SoundCastMember *>(soundCast)->_looping) {
+					_mixer->loopChannel(_channels[i - 1].handle);
+				}
+			}
+		}
 	}
 	unloadSampleSounds(); // TODO: we can possibly keep this between movies
 }
diff --git a/engines/director/window.cpp b/engines/director/window.cpp
index cf62d7073f..3ae4585730 100644
--- a/engines/director/window.cpp
+++ b/engines/director/window.cpp
@@ -457,6 +457,8 @@ bool Window::step() {
 
 	// prepare next movie
 	if (!_nextMovie.movie.empty()) {
+		_soundManager->changingMovie();
+
 		_newMovieStarted = true;
 
 		_currentPath = getPath(_nextMovie.movie, _currentPath);
@@ -504,7 +506,6 @@ bool Window::step() {
 		} else {
 			delete sharedCast;
 		}
-		_soundManager->changingMovie();
 
 		_nextMovie.movie.clear();
 	}


Commit: 0a9282695757324431ea07bceb5176b0adadc123
    https://github.com/scummvm/scummvm/commit/0a9282695757324431ea07bceb5176b0adadc123
Author: djsrv (dservilla at gmail.com)
Date: 2021-08-12T13:18:27-04:00

Commit Message:
DIRECTOR: Fix whitespace

Changed paths:
    engines/director/sound.cpp


diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index 68a6dea5e0..6da9b1ec3c 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -796,7 +796,7 @@ Audio::AudioStream *AudioFileDecoder::getAudioStream(bool looping, bool forPuppe
 		if (looping && forPuppet) {
 			// If this is for a puppet, return an automatically looping stream.
 			// Otherwise, the sound will be looped by the score
-				return new Audio::LoopingAudioStream(stream, 0);
+			return new Audio::LoopingAudioStream(stream, 0);
 		}
 		return stream;
 	}




More information about the Scummvm-git-logs mailing list