mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:57:44 +00:00
AudioServer: Fix deadlock when playing two audio streams
Previously, AudioServer would deadlock when trying to play another audio stream, i.e. creating a queue. The m_pending_cond condition was used improperly, and the condition wait now happens independently of querying the pending queue for new clients if the mixer is running. To make the mixer's concurrency-safety code more readable, the use of raw POSIX mutex and condition syscalls is replaced with Threading::Mutex and Threading::ConditionVariable.
This commit is contained in:
parent
c7104e7512
commit
3f067f8457
2 changed files with 18 additions and 15 deletions
|
@ -19,8 +19,10 @@
|
|||
#include <LibAudio/Buffer.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/Timer.h>
|
||||
#include <LibThreading/ConditionVariable.h>
|
||||
#include <LibThreading/Mutex.h>
|
||||
#include <LibThreading/Thread.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
namespace AudioServer {
|
||||
|
||||
|
@ -125,9 +127,8 @@ private:
|
|||
void request_setting_sync();
|
||||
|
||||
Vector<NonnullRefPtr<ClientAudioStream>> m_pending_mixing;
|
||||
Atomic<bool> m_added_queue { false };
|
||||
pthread_mutex_t m_pending_mutex;
|
||||
pthread_cond_t m_pending_cond;
|
||||
Threading::Mutex m_pending_mutex;
|
||||
Threading::ConditionVariable m_mixing_necessary { m_pending_mutex };
|
||||
|
||||
RefPtr<Core::File> m_device;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue