diff options
Diffstat (limited to 'indra/media_plugins/cef/linux/volume_catcher_linux.cpp')
-rw-r--r-- | indra/media_plugins/cef/linux/volume_catcher_linux.cpp | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/indra/media_plugins/cef/linux/volume_catcher_linux.cpp b/indra/media_plugins/cef/linux/volume_catcher_linux.cpp new file mode 100644 index 0000000000..86cc329e66 --- /dev/null +++ b/indra/media_plugins/cef/linux/volume_catcher_linux.cpp @@ -0,0 +1,103 @@ +/** + * @file volume_catcher.cpp + * @brief Linux volume catcher which will pick an implementation to use + * + * @cond + * $LicenseInfo:firstyear=2010&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2010, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + * @endcond + */ + +#include "volume_catcher_linux.h" + +#define PULSEAUDIO pimpl +#define PIPEWIRE pimpl2 + +//////////////////////////////////////////////////// + +VolumeCatcher::VolumeCatcher() +{ + // only init once we receive which implementation to use + + // debugClear(); + // debugPrint("init volume catcher\n"); +} + +void VolumeCatcher::onEnablePipeWireVolumeCatcher(bool enable) { + if (enable) { + // load pipewire + + if (PULSEAUDIO != nullptr) { + delete PULSEAUDIO; + PULSEAUDIO = nullptr; + } + + if (PIPEWIRE == nullptr) { + // debugPrint("volume catcher using pipewire\n"); + PIPEWIRE = new VolumeCatcherPipeWire(); + } + } else { + // load pulseaudio + + if (PIPEWIRE != nullptr) { + delete PIPEWIRE; + PIPEWIRE = nullptr; + } + + if (PULSEAUDIO == nullptr) { + // debugPrint("volume catcher using pulseaudio\n"); + PULSEAUDIO = new VolumeCatcherPulseAudio(); + } + } +} + +VolumeCatcher::~VolumeCatcher() +{ + if (PULSEAUDIO != nullptr) { + delete PULSEAUDIO; + PULSEAUDIO = nullptr; + } + + if (PIPEWIRE != nullptr) { + delete PIPEWIRE; + PIPEWIRE = nullptr; + } +} + +void VolumeCatcher::setVolume(F32 volume) +{ + if (PULSEAUDIO != nullptr) PULSEAUDIO->setVolume(volume); + if (PIPEWIRE != nullptr) PIPEWIRE->setVolume(volume); +} + +void VolumeCatcher::setPan(F32 pan) +{ + // not implemented for both + // if (PULSEAUDIO) PULSEAUDIO->setPan(pan); + // if (PIPEWIRE) PIPEWIRE->setPan(pan); +} + +void VolumeCatcher::pump() +{ + if (PULSEAUDIO != nullptr) PULSEAUDIO->pump(); + if (PIPEWIRE != nullptr) PIPEWIRE->pump(); // doesn't need it +} + |