1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-16 16:59:56 +00:00

Merge branch 'defaultdevice' into 'master'

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

Closes #7731

See merge request OpenMW/openmw!4505
This commit is contained in:
psi29a 2025-01-10 14:29:17 +00:00
commit 763e88817a

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());
mCurrentName = defaultName;
Log(Debug::Info) << "Default audio device changed to \"" << mCurrentName << "\"";
ALCboolean reopened = alcReopenDeviceSOFT(
mOutput.mDevice, mCurrentName.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);
}
}
mCondVar.wait_for(lock, std::chrono::seconds(2));