diff options
author | Maki <maki@hotmilk.space> | 2024-04-20 17:50:43 -0400 |
---|---|---|
committer | Maki <maki@hotmilk.space> | 2024-04-20 17:50:43 -0400 |
commit | e6ca21549ee1d4a23c82e12d9215ce993d99ca3e (patch) | |
tree | 21c65f4f0fb6e18817fb8494a0aa4eb22a8a2484 /indra/media_plugins/cef/linux | |
parent | 576508ebab789207c5d82c13ff627cb623d74994 (diff) |
Only use one impl in Linux volume catcher
Diffstat (limited to 'indra/media_plugins/cef/linux')
-rw-r--r-- | indra/media_plugins/cef/linux/volume_catcher_linux.cpp | 59 |
1 files changed, 19 insertions, 40 deletions
diff --git a/indra/media_plugins/cef/linux/volume_catcher_linux.cpp b/indra/media_plugins/cef/linux/volume_catcher_linux.cpp index 86cc329e66..3c037b45ba 100644 --- a/indra/media_plugins/cef/linux/volume_catcher_linux.cpp +++ b/indra/media_plugins/cef/linux/volume_catcher_linux.cpp @@ -28,9 +28,6 @@ #include "volume_catcher_linux.h" -#define PULSEAUDIO pimpl -#define PIPEWIRE pimpl2 - //////////////////////////////////////////////////// VolumeCatcher::VolumeCatcher() @@ -42,62 +39,44 @@ VolumeCatcher::VolumeCatcher() } void VolumeCatcher::onEnablePipeWireVolumeCatcher(bool enable) { - if (enable) { - // load pipewire - - if (PULSEAUDIO != nullptr) { - delete PULSEAUDIO; - PULSEAUDIO = nullptr; - } + if (pimpl != nullptr) + return; - if (PIPEWIRE == nullptr) { - // debugPrint("volume catcher using pipewire\n"); - PIPEWIRE = new VolumeCatcherPipeWire(); - } + if (enable) { + // debugPrint("volume catcher using pipewire\n"); + pimpl = new VolumeCatcherPipeWire(); } else { - // load pulseaudio - - if (PIPEWIRE != nullptr) { - delete PIPEWIRE; - PIPEWIRE = nullptr; - } - - if (PULSEAUDIO == nullptr) { - // debugPrint("volume catcher using pulseaudio\n"); - PULSEAUDIO = new VolumeCatcherPulseAudio(); - } + // debugPrint("volume catcher using pulseaudio\n"); + pimpl = new VolumeCatcherPulseAudio(); } } VolumeCatcher::~VolumeCatcher() { - if (PULSEAUDIO != nullptr) { - delete PULSEAUDIO; - PULSEAUDIO = nullptr; - } - - if (PIPEWIRE != nullptr) { - delete PIPEWIRE; - PIPEWIRE = nullptr; + if (pimpl != nullptr) { + delete pimpl; + pimpl = nullptr; } } void VolumeCatcher::setVolume(F32 volume) { - if (PULSEAUDIO != nullptr) PULSEAUDIO->setVolume(volume); - if (PIPEWIRE != nullptr) PIPEWIRE->setVolume(volume); + if (pimpl != nullptr) { + pimpl->setVolume(volume); + } } void VolumeCatcher::setPan(F32 pan) { - // not implemented for both - // if (PULSEAUDIO) PULSEAUDIO->setPan(pan); - // if (PIPEWIRE) PIPEWIRE->setPan(pan); + if (pimpl != nullptr) { + pimpl->setPan(pan); + } } void VolumeCatcher::pump() { - if (PULSEAUDIO != nullptr) PULSEAUDIO->pump(); - if (PIPEWIRE != nullptr) PIPEWIRE->pump(); // doesn't need it + if (pimpl != nullptr) { + pimpl->pump(); + } } |