mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:37:35 +00:00
AudioServer: Fix issue when adding a BufferQueue to Mixer
Previously, the Mixer class would only check for an added BufferQueue if the list of active queues was empty. If more than one client connected to AudioServer, its queue would never be added to the list of active queues. This fix adds a flag that, when set, will cause the sound thread to wait for a new BufferQueue.
This commit is contained in:
parent
745801e109
commit
980acd0db7
2 changed files with 5 additions and 1 deletions
|
@ -64,6 +64,7 @@ NonnullRefPtr<BufferQueue> Mixer::create_queue(ClientConnection& client)
|
|||
auto queue = adopt(*new BufferQueue(client));
|
||||
pthread_mutex_lock(&m_pending_mutex);
|
||||
m_pending_mixing.append(*queue);
|
||||
m_added_queue = true;
|
||||
pthread_cond_signal(&m_pending_cond);
|
||||
pthread_mutex_unlock(&m_pending_mutex);
|
||||
return queue;
|
||||
|
@ -74,11 +75,12 @@ void Mixer::mix()
|
|||
decltype(m_pending_mixing) active_mix_queues;
|
||||
|
||||
for (;;) {
|
||||
if (active_mix_queues.is_empty()) {
|
||||
if (active_mix_queues.is_empty() || m_added_queue) {
|
||||
pthread_mutex_lock(&m_pending_mutex);
|
||||
pthread_cond_wait(&m_pending_cond, &m_pending_mutex);
|
||||
active_mix_queues.append(move(m_pending_mixing));
|
||||
pthread_mutex_unlock(&m_pending_mutex);
|
||||
m_added_queue = false;
|
||||
}
|
||||
|
||||
active_mix_queues.remove_all_matching([&](auto& entry) { return !entry->client(); });
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "ClientConnection.h"
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/Badge.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
|
@ -125,6 +126,7 @@ public:
|
|||
|
||||
private:
|
||||
Vector<NonnullRefPtr<BufferQueue>> m_pending_mixing;
|
||||
Atomic<bool> m_added_queue { false };
|
||||
pthread_mutex_t m_pending_mutex;
|
||||
pthread_cond_t m_pending_cond;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue