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

eriktorbjorn eriktorbjorn at telia.com
Thu Jun 24 18:38:41 UTC 2021


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

Summary:
1bd7028c31 AUDIO: Added mutex() method to return the mixer's internal mutex.
0c3872d515 SCUMM: Use the mixer's mutex in Player_AD


Commit: 1bd7028c3113bffd9ea8df1ce647328c95cded14
    https://github.com/scummvm/scummvm/commit/1bd7028c3113bffd9ea8df1ce647328c95cded14
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-06-24T20:38:38+02:00

Commit Message:
AUDIO: Added mutex() method to return the mixer's internal mutex.

This is so that individual audio players can share the same mutex as the
mixer. When they have their own, it's apparently quite easy to
accidentally introduce deadlocks. Particularly when the audio player is
shut down.

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


diff --git a/audio/mixer.h b/audio/mixer.h
index 5db2c6c3de..5af650ac67 100644
--- a/audio/mixer.h
+++ b/audio/mixer.h
@@ -23,6 +23,7 @@
 #ifndef AUDIO_MIXER_H
 #define AUDIO_MIXER_H
 
+#include "common/mutex.h"
 #include "common/types.h"
 #include "common/noncopyable.h"
 
@@ -94,6 +95,10 @@ public:
 	 */
 	virtual bool isReady() const = 0;
 
+	/**
+	 * Return the mixer's internal mutex so that audio players can use it.
+	 */
+	virtual Common::Mutex &mutex() = 0;
 
 	/**
 	 * Start playing the given audio stream.
diff --git a/audio/mixer_intern.h b/audio/mixer_intern.h
index 44c187e406..92f74eeeec 100644
--- a/audio/mixer_intern.h
+++ b/audio/mixer_intern.h
@@ -86,6 +86,8 @@ public:
 
 	virtual bool isReady() const { Common::StackLock lock(_mutex); return _mixerReady; }
 
+	virtual Common::Mutex &mutex() { return _mutex; }
+
 	virtual void playStream(
 		SoundType type,
 		SoundHandle *handle,


Commit: 0c3872d51519638ca7fb18449800c39b46aec0e2
    https://github.com/scummvm/scummvm/commit/0c3872d51519638ca7fb18449800c39b46aec0e2
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2021-06-24T20:38:38+02:00

Commit Message:
SCUMM: Use the mixer's mutex in Player_AD

This is one of the players that has had problems with deadlocks
recently. I'm not very well versed in threaded programming, but arthxx
has promised to fix up some more players later. This one was used as
proof of concept because it deadlocks a lot.

Changed paths:
    engines/scumm/players/player_ad.cpp
    engines/scumm/players/player_ad.h
    engines/scumm/scumm.cpp


diff --git a/engines/scumm/players/player_ad.cpp b/engines/scumm/players/player_ad.cpp
index 40f4ec93c9..f0ee921fd8 100644
--- a/engines/scumm/players/player_ad.cpp
+++ b/engines/scumm/players/player_ad.cpp
@@ -35,8 +35,8 @@ namespace Scumm {
 
 #define AD_CALLBACK_FREQUENCY 472
 
-Player_AD::Player_AD(ScummEngine *scumm)
-	: _vm(scumm) {
+Player_AD::Player_AD(ScummEngine *scumm, Common::Mutex &mutex)
+	: _vm(scumm), _mutex(mutex) {
 	_opl2 = OPL::Config::create();
 	if (!_opl2->init()) {
 		error("Could not initialize OPL2 emulator");
diff --git a/engines/scumm/players/player_ad.h b/engines/scumm/players/player_ad.h
index 7e8b542c9f..5c877f3b12 100644
--- a/engines/scumm/players/player_ad.h
+++ b/engines/scumm/players/player_ad.h
@@ -41,7 +41,7 @@ class ScummEngine;
  */
 class Player_AD : public MusicEngine {
 public:
-	Player_AD(ScummEngine *scumm);
+	Player_AD(ScummEngine *scumm, Common::Mutex &mutex);
 	~Player_AD() override;
 
 	// MusicEngine API
@@ -59,7 +59,7 @@ public:
 
 private:
 	ScummEngine *const _vm;
-	Common::Mutex _mutex;
+	Common::Mutex &_mutex;
 
 	void setupVolume();
 	int _musicVolume;
diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp
index 830fe1c776..7ffa28c08b 100644
--- a/engines/scumm/scumm.cpp
+++ b/engines/scumm/scumm.cpp
@@ -2095,7 +2095,7 @@ void ScummEngine::setupMusic(int midi, const Common::String &macInstrumentFile)
 		// EGA/VGA. However, we support multi MIDI for that game and we cannot
 		// support this with the Player_AD code at the moment. The reason here
 		// is that multi MIDI is supported internally by our iMuse output.
-		_musicEngine = new Player_AD(this);
+		_musicEngine = new Player_AD(this, _mixer->mutex());
 #ifdef ENABLE_HE
 	} else if (_game.platform == Common::kPlatformDOS && _sound->_musicType == MDT_ADLIB && _game.heversion >= 60) {
 		_musicEngine = new Player_HE(this);




More information about the Scummvm-git-logs mailing list