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.
This commit is contained in:
Torbjörn Andersson 2021-06-21 08:42:27 +02:00 committed by Torbjörn Andersson
parent 745f912ca1
commit 1bd7028c31
2 changed files with 7 additions and 0 deletions

View file

@ -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.

View file

@ -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,