1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-12-13 08:13:06 +00:00

Fix default audio device switch for PulseAudio backend (#7731)

This commit is contained in:
Alexei Kotov 2025-01-08 07:34:15 +03:00
parent 710aa9ad4f
commit d4f4b3c304

View file

@ -417,19 +417,15 @@ namespace MWSound
{ {
{ {
const std::lock_guard<std::mutex> openLock(mOutput.mReopenMutex); const std::lock_guard<std::mutex> openLock(mOutput.mReopenMutex);
auto defaultName = getDeviceName(nullptr); std::basic_string_view<ALCchar> defaultName = getDeviceName(nullptr);
if (mCurrentName != defaultName) if (mCurrentName != defaultName)
{ {
Log(Debug::Info) << "Default audio device changed"; Log(Debug::Info) << "Default audio device changed";
ALCboolean reopened ALCboolean reopened = alcReopenDeviceSOFT(
= alcReopenDeviceSOFT(mOutput.mDevice, nullptr, mOutput.mContextAttributes.data()); mOutput.mDevice, defaultName.data(), mOutput.mContextAttributes.data());
if (reopened == AL_FALSE) if (reopened == AL_FALSE)
{
mCurrentName = defaultName;
Log(Debug::Warning) << "Failed to switch to new audio device"; Log(Debug::Warning) << "Failed to switch to new audio device";
} mCurrentName = defaultName;
else
mCurrentName = getDeviceName(mOutput.mDevice);
} }
} }
mCondVar.wait_for(lock, std::chrono::seconds(2)); mCondVar.wait_for(lock, std::chrono::seconds(2));