diff options
| author | Anton <anton@picapica.im> | 2026-11-24 02:40:10 +0400 |
|---|---|---|
| committer | Anton <anton@picapica.im> | 2026-11-24 02:40:10 +0400 |
| commit | 48417c1da102dc9eb332227237805b8e28f81f97 (patch) | |
| tree | 53defd47a60bf505a3431a0ae4193b1e40b29c2e /pica-client/nativeaudio.cpp | |
| parent | 3922dcc4c4822cc626d62f73ddefbe4fce8e94e5 (diff) | |
| parent | 98d341e2e55852f075001c6c2d084d025a97383f (diff) | |
| download | pica-pica-master.tar.gz pica-pica-master.zip | |
Diffstat (limited to 'pica-client/nativeaudio.cpp')
| -rw-r--r-- | pica-client/nativeaudio.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/pica-client/nativeaudio.cpp b/pica-client/nativeaudio.cpp new file mode 100644 index 0000000..499aad6 --- /dev/null +++ b/pica-client/nativeaudio.cpp @@ -0,0 +1,77 @@ +/* + (c) Copyright 2012 - 2026 Anton Sviridenko + https://picapica.im + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, version 3. + + This program 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <https://www.gnu.org/licenses/>. +*/ +#include "nativeaudio.h" + +#include <QtGlobal> + +// Per platform factories, defined next to the backends themselves. +#ifdef Q_OS_WIN +NativeAudioBackend *pica_create_wasapi_backend(); +QList<MediaDeviceInfo> pica_enumerate_wasapi(enum MediaDeviceStreamDirection dir); +#endif + +#if defined(Q_OS_MACOS) || defined(Q_OS_MAC) +NativeAudioBackend *pica_create_coreaudio_backend(); +QList<MediaDeviceInfo> pica_enumerate_coreaudio(enum MediaDeviceStreamDirection dir); +#endif + +NativeAudioBackend::~NativeAudioBackend() +{ +} + +bool NativeAudioBackend::isAvailable(const QString &api) +{ +#ifdef Q_OS_WIN + if (api == QLatin1String("wasapi")) + return true; +#endif +#if defined(Q_OS_MACOS) || defined(Q_OS_MAC) + if (api == QLatin1String("coreaudio")) + return true; +#endif + Q_UNUSED(api) + return false; +} + +NativeAudioBackend *NativeAudioBackend::create(const QString &api) +{ +#ifdef Q_OS_WIN + if (api == QLatin1String("wasapi")) + return pica_create_wasapi_backend(); +#endif +#if defined(Q_OS_MACOS) || defined(Q_OS_MAC) + if (api == QLatin1String("coreaudio")) + return pica_create_coreaudio_backend(); +#endif + Q_UNUSED(api) + return nullptr; +} + +QList<MediaDeviceInfo> NativeAudioBackend::enumerate(const QString &api, enum MediaDeviceStreamDirection dir) +{ +#ifdef Q_OS_WIN + if (api == QLatin1String("wasapi")) + return pica_enumerate_wasapi(dir); +#endif +#if defined(Q_OS_MACOS) || defined(Q_OS_MAC) + if (api == QLatin1String("coreaudio")) + return pica_enumerate_coreaudio(dir); +#endif + Q_UNUSED(api) + Q_UNUSED(dir) + return QList<MediaDeviceInfo>(); +} |
