1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-30 16:20:21 +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);
auto defaultName = getDeviceName(nullptr);
std::basic_string_view<ALCchar> defaultName = getDeviceName(nullptr);
if (mCurrentName != defaultName)
{
Log(Debug::Info) << "Default audio device changed";
ALCboolean reopened
= alcReopenDeviceSOFT(mOutput.mDevice, nullptr, mOutput.mContextAttributes.data());
ALCboolean reopened = alcReopenDeviceSOFT(
mOutput.mDevice, defaultName.data(), mOutput.mContextAttributes.data());
if (reopened == AL_FALSE)
{
mCurrentName = defaultName;
Log(Debug::Warning) << "Failed to switch to new audio device";
}
else
mCurrentName = getDeviceName(mOutput.mDevice);
mCurrentName = defaultName;
}
}
mCondVar.wait_for(lock, std::chrono::seconds(2));