From 7c930dd5a6dae3bc3b2861ca95d8eea5942168cb Mon Sep 17 00:00:00 2001 From: Dillon Skaggs Date: Sat, 7 Dec 2024 11:44:16 -0600 Subject: [PATCH] fix(mumble): fix reinitializing clients when audio device is set `HandleClientConnect` expects the `MumbleUser` to hae a valid username and session, but this was only sending the session id, so the audio sink was getting set to an empty user name, resulting in the client never being able to hear anyone until they turned off their voice chat and turned it back on (or got lucky enough that their internet was slow, or initialization was slow and that this wouldn't get hit). --- .../voip-mumble/src/MumbleAudioOutput.cpp | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/code/components/voip-mumble/src/MumbleAudioOutput.cpp b/code/components/voip-mumble/src/MumbleAudioOutput.cpp index e8d235065f..090ec5a2d7 100644 --- a/code/components/voip-mumble/src/MumbleAudioOutput.cpp +++ b/code/components/voip-mumble/src/MumbleAudioOutput.cpp @@ -1499,15 +1499,6 @@ void MumbleAudioOutput::SetAudioDevice(const std::string& deviceId) { std::unique_lock _(m_clientsMutex); - - for (auto& client : m_clients) - { - if (client.second) - { - m_ids.push_back(client.first); - } - } - // delete all clients m_clients.clear(); } @@ -1515,12 +1506,10 @@ void MumbleAudioOutput::SetAudioDevice(const std::string& deviceId) // reinitialize audio device InitializeAudioDevice(); - // recreate clients - for (auto& client : m_ids) + m_client->GetState().ForAllUsers([this](const std::shared_ptr& user) { - MumbleUser fakeUser(client); - HandleClientConnect(fakeUser); - } + HandleClientConnect(*user); + }); } void MumbleAudioOutput::SetDistance(float distance)