MCPcopy Create free account
hub / github.com/Soundux/Soundux / changeSettings

Method changeSettings

src/ui/ui.cpp:582–716  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 }

Callers

nothing calls this directly

Calls 12

getPlayingSoundsMethod · 0.80
loadMethod · 0.80
getMicMethod · 0.80
muteMethod · 0.80
destroyMethod · 0.45
setupMethod · 0.45
muteInputMethod · 0.45
revertDefaultMethod · 0.45
stopSoundInputMethod · 0.45
useAsDefaultMethod · 0.45
inputSoundToMethod · 0.45
getRecordingAppMethod · 0.45

Tested by

no test coverage detected