| 580 | return std::nullopt; |
| 581 | } |
| 582 | Settings Window::changeSettings(Settings settings) |
| 583 | { |
| 584 | auto oldSettings = Globals::gSettings; |
| 585 | Globals::gSettings = settings; |
| 586 | |
| 587 | if ((settings.localVolume != oldSettings.localVolume || settings.remoteVolume != oldSettings.remoteVolume) && |
| 588 | !Globals::gAudio.getPlayingSounds().empty()) |
| 589 | { |
| 590 | for (const auto &playingSound : Globals::gAudio.getPlayingSounds()) |
| 591 | { |
| 592 | int newVolume = 0; |
| 593 | const auto &sound = playingSound.sound; |
| 594 | |
| 595 | if (playingSound.playbackDevice.isDefault) |
| 596 | { |
| 597 | newVolume = sound.localVolume ? *sound.localVolume : Globals::gSettings.localVolume; |
| 598 | } |
| 599 | else |
| 600 | { |
| 601 | newVolume = sound.remoteVolume ? *sound.remoteVolume : Globals::gSettings.remoteVolume; |
| 602 | } |
| 603 | |
| 604 | playingSound.raw.device.load()->masterVolumeFactor = static_cast<float>(newVolume) / 100.f; |
| 605 | } |
| 606 | } |
| 607 | |
| 608 | #if defined(__linux__) |
| 609 | if (settings.audioBackend != oldSettings.audioBackend) |
| 610 | { |
| 611 | stopSounds(true); |
| 612 | |
| 613 | if (Globals::gAudioBackend) |
| 614 | { |
| 615 | Globals::gAudioBackend->destroy(); |
| 616 | } |
| 617 | |
| 618 | Globals::gAudioBackend = AudioBackend::createInstance(settings.audioBackend); |
| 619 | Globals::gAudio.setup(); |
| 620 | } |
| 621 | if (Globals::gAudioBackend) |
| 622 | { |
| 623 | if (!Globals::gAudio.getPlayingSounds().empty()) |
| 624 | { |
| 625 | if (settings.muteDuringPlayback && !oldSettings.muteDuringPlayback) |
| 626 | { |
| 627 | if (!Globals::gAudioBackend->muteInput(true)) |
| 628 | { |
| 629 | onError(Enums::ErrorCode::FailedToMute); |
| 630 | } |
| 631 | } |
| 632 | else if (!settings.muteDuringPlayback && oldSettings.muteDuringPlayback) |
| 633 | { |
| 634 | if (!Globals::gAudioBackend->muteInput(false)) |
| 635 | { |
| 636 | onError(Enums::ErrorCode::FailedToMute); |
| 637 | } |
| 638 | } |
| 639 | } |
nothing calls this directly
no test coverage detected