Skip to content

Commit

Permalink
Merge branch 'defaultdevice' into 'master'
Browse files Browse the repository at this point in the history
Fix default audio device switch for PulseAudio backend (#7731)

Closes #7731

See merge request OpenMW/openmw!4505
  • Loading branch information
psi29a committed Jan 10, 2025
2 parents 4c92064 + dd44b26 commit 763e888
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions apps/openmw/mwsound/openal_output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit 763e888

Please sign in to comment.