2007-11-13 18:02:18 -08:00
|
|
|
/**
|
|
|
|
* OpenAL cross platform audio library
|
|
|
|
* Copyright (C) 1999-2007 by authors.
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
2014-08-18 14:11:03 +02:00
|
|
|
* Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
2007-11-13 18:02:18 -08:00
|
|
|
* Or go to http://www.gnu.org/copyleft/lgpl.html
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
2016-12-21 01:08:33 -08:00
|
|
|
#include "version.h"
|
|
|
|
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <exception>
|
|
|
|
#include <algorithm>
|
|
|
|
#include <array>
|
2018-11-14 04:15:44 -08:00
|
|
|
#include <atomic>
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <cctype>
|
|
|
|
#include <chrono>
|
|
|
|
#include <climits>
|
|
|
|
#include <cmath>
|
|
|
|
#include <csignal>
|
|
|
|
#include <cstdint>
|
|
|
|
#include <cstdio>
|
|
|
|
#include <cstdlib>
|
|
|
|
#include <cstring>
|
|
|
|
#include <functional>
|
|
|
|
#include <iterator>
|
|
|
|
#include <limits>
|
|
|
|
#include <memory>
|
2018-11-14 06:17:47 -08:00
|
|
|
#include <mutex>
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <new>
|
2018-11-28 11:30:44 -08:00
|
|
|
#include <numeric>
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <string>
|
|
|
|
#include <thread>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "AL/al.h"
|
|
|
|
#include "AL/alc.h"
|
|
|
|
#include "AL/alext.h"
|
|
|
|
#include "AL/efx.h"
|
2018-11-14 04:15:44 -08:00
|
|
|
|
2019-07-29 17:54:07 -07:00
|
|
|
#include "al/auxeffectslot.h"
|
|
|
|
#include "al/effect.h"
|
|
|
|
#include "al/event.h"
|
|
|
|
#include "al/filter.h"
|
|
|
|
#include "al/listener.h"
|
|
|
|
#include "al/source.h"
|
2019-07-28 18:33:29 -07:00
|
|
|
#include "alcmain.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "albyte.h"
|
2018-01-11 07:56:54 -08:00
|
|
|
#include "alconfig.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "alcontext.h"
|
|
|
|
#include "alexcpt.h"
|
|
|
|
#include "almalloc.h"
|
|
|
|
#include "alnumeric.h"
|
|
|
|
#include "aloptional.h"
|
|
|
|
#include "alspan.h"
|
|
|
|
#include "alu.h"
|
|
|
|
#include "ambidefs.h"
|
|
|
|
#include "atomic.h"
|
|
|
|
#include "bformatdec.h"
|
2018-11-22 06:49:37 -08:00
|
|
|
#include "bs2b.h"
|
2014-04-16 01:39:11 -07:00
|
|
|
#include "compat.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "cpu_caps.h"
|
2019-08-05 18:36:39 -07:00
|
|
|
#include "devformat.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "effects/base.h"
|
|
|
|
#include "filters/nfc.h"
|
|
|
|
#include "filters/splitter.h"
|
|
|
|
#include "fpu_modes.h"
|
|
|
|
#include "hrtf.h"
|
|
|
|
#include "inprogext.h"
|
2019-08-01 13:28:53 -07:00
|
|
|
#include "intrusive_ptr.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "logging.h"
|
|
|
|
#include "mastering.h"
|
|
|
|
#include "opthelpers.h"
|
|
|
|
#include "ringbuffer.h"
|
2019-08-11 18:50:07 -07:00
|
|
|
#include "strutils.h"
|
2014-04-16 01:39:11 -07:00
|
|
|
#include "threads.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "uhjfilter.h"
|
|
|
|
#include "vecmat.h"
|
|
|
|
#include "vector.h"
|
2014-03-28 05:40:24 -07:00
|
|
|
|
2013-10-27 14:24:55 -07:00
|
|
|
#include "backends/base.h"
|
2018-11-15 19:15:14 -08:00
|
|
|
#include "backends/null.h"
|
2018-11-15 19:42:13 -08:00
|
|
|
#include "backends/loopback.h"
|
2018-11-15 22:03:20 -08:00
|
|
|
#ifdef HAVE_JACK
|
|
|
|
#include "backends/jack.h"
|
|
|
|
#endif
|
2018-11-15 19:55:56 -08:00
|
|
|
#ifdef HAVE_PULSEAUDIO
|
|
|
|
#include "backends/pulseaudio.h"
|
|
|
|
#endif
|
2018-11-15 21:33:44 -08:00
|
|
|
#ifdef HAVE_ALSA
|
|
|
|
#include "backends/alsa.h"
|
|
|
|
#endif
|
2018-11-15 21:14:20 -08:00
|
|
|
#ifdef HAVE_WASAPI
|
|
|
|
#include "backends/wasapi.h"
|
|
|
|
#endif
|
2018-11-15 21:24:09 -08:00
|
|
|
#ifdef HAVE_COREAUDIO
|
|
|
|
#include "backends/coreaudio.h"
|
|
|
|
#endif
|
2018-11-15 21:42:17 -08:00
|
|
|
#ifdef HAVE_OPENSL
|
|
|
|
#include "backends/opensl.h"
|
|
|
|
#endif
|
2018-11-15 22:23:29 -08:00
|
|
|
#ifdef HAVE_SOLARIS
|
|
|
|
#include "backends/solaris.h"
|
|
|
|
#endif
|
2018-11-15 22:36:49 -08:00
|
|
|
#ifdef HAVE_SNDIO
|
|
|
|
#include "backends/sndio.h"
|
|
|
|
#endif
|
2018-11-15 23:02:26 -08:00
|
|
|
#ifdef HAVE_OSS
|
|
|
|
#include "backends/oss.h"
|
|
|
|
#endif
|
2018-11-15 23:10:06 -08:00
|
|
|
#ifdef HAVE_QSA
|
|
|
|
#include "backends/qsa.h"
|
|
|
|
#endif
|
2018-11-15 23:32:28 -08:00
|
|
|
#ifdef HAVE_DSOUND
|
|
|
|
#include "backends/dsound.h"
|
|
|
|
#endif
|
2018-11-15 23:41:09 -08:00
|
|
|
#ifdef HAVE_WINMM
|
|
|
|
#include "backends/winmm.h"
|
|
|
|
#endif
|
2018-11-15 23:50:15 -08:00
|
|
|
#ifdef HAVE_PORTAUDIO
|
|
|
|
#include "backends/portaudio.h"
|
|
|
|
#endif
|
2018-11-15 22:15:10 -08:00
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
#include "backends/sdl2.h"
|
|
|
|
#endif
|
2018-11-15 21:53:14 -08:00
|
|
|
#ifdef HAVE_WAVE
|
|
|
|
#include "backends/wave.h"
|
|
|
|
#endif
|
2013-10-27 14:24:55 -07:00
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-14 06:17:47 -08:00
|
|
|
namespace {
|
|
|
|
|
2019-04-01 17:27:31 -07:00
|
|
|
using namespace std::placeholders;
|
2019-04-01 21:35:52 -07:00
|
|
|
using std::chrono::seconds;
|
|
|
|
using std::chrono::nanoseconds;
|
|
|
|
|
2019-04-01 17:27:31 -07:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/************************************************
|
|
|
|
* Backends
|
|
|
|
************************************************/
|
2013-10-27 14:24:55 -07:00
|
|
|
struct BackendInfo {
|
|
|
|
const char *name;
|
2018-11-15 19:15:14 -08:00
|
|
|
BackendFactory& (*getFactory)(void);
|
2013-10-27 14:24:55 -07:00
|
|
|
};
|
|
|
|
|
2018-12-22 09:20:50 -08:00
|
|
|
BackendInfo BackendList[] = {
|
2018-11-15 22:03:20 -08:00
|
|
|
#ifdef HAVE_JACK
|
|
|
|
{ "jack", JackBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 19:55:56 -08:00
|
|
|
#ifdef HAVE_PULSEAUDIO
|
|
|
|
{ "pulse", PulseBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 21:33:44 -08:00
|
|
|
#ifdef HAVE_ALSA
|
|
|
|
{ "alsa", AlsaBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 21:14:20 -08:00
|
|
|
#ifdef HAVE_WASAPI
|
|
|
|
{ "wasapi", WasapiBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 21:24:09 -08:00
|
|
|
#ifdef HAVE_COREAUDIO
|
|
|
|
{ "core", CoreAudioBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 21:42:17 -08:00
|
|
|
#ifdef HAVE_OPENSL
|
|
|
|
{ "opensl", OSLBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 22:23:29 -08:00
|
|
|
#ifdef HAVE_SOLARIS
|
|
|
|
{ "solaris", SolarisBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 22:36:49 -08:00
|
|
|
#ifdef HAVE_SNDIO
|
|
|
|
{ "sndio", SndIOBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 23:02:26 -08:00
|
|
|
#ifdef HAVE_OSS
|
|
|
|
{ "oss", OSSBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 23:10:06 -08:00
|
|
|
#ifdef HAVE_QSA
|
|
|
|
{ "qsa", QSABackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 23:32:28 -08:00
|
|
|
#ifdef HAVE_DSOUND
|
|
|
|
{ "dsound", DSoundBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 23:41:09 -08:00
|
|
|
#ifdef HAVE_WINMM
|
|
|
|
{ "winmm", WinMMBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 23:50:15 -08:00
|
|
|
#ifdef HAVE_PORTAUDIO
|
|
|
|
{ "port", PortBackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 22:15:10 -08:00
|
|
|
#ifdef HAVE_SDL2
|
|
|
|
{ "sdl2", SDL2BackendFactory::getFactory },
|
|
|
|
#endif
|
2018-11-15 19:55:56 -08:00
|
|
|
|
2018-11-15 19:15:14 -08:00
|
|
|
{ "null", NullBackendFactory::getFactory },
|
2018-11-15 21:53:14 -08:00
|
|
|
#ifdef HAVE_WAVE
|
|
|
|
{ "wave", WaveBackendFactory::getFactory },
|
|
|
|
#endif
|
2007-11-13 18:02:18 -08:00
|
|
|
};
|
2019-04-11 02:49:13 -07:00
|
|
|
auto BackendListEnd = std::end(BackendList);
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-06-28 18:54:31 -07:00
|
|
|
BackendFactory *PlaybackFactory{};
|
|
|
|
BackendFactory *CaptureFactory{};
|
2011-08-19 00:23:26 -07:00
|
|
|
|
2013-10-27 14:24:55 -07:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/************************************************
|
|
|
|
* Functions, enums, and errors
|
|
|
|
************************************************/
|
2017-03-14 08:37:50 -07:00
|
|
|
#define DECL(x) { #x, (ALCvoid*)(x) }
|
2019-06-27 22:29:42 -07:00
|
|
|
const struct {
|
2010-03-24 22:43:08 -07:00
|
|
|
const ALCchar *funcName;
|
|
|
|
ALCvoid *address;
|
2017-03-14 08:37:50 -07:00
|
|
|
} alcFunctions[] = {
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(alcCreateContext),
|
|
|
|
DECL(alcMakeContextCurrent),
|
|
|
|
DECL(alcProcessContext),
|
|
|
|
DECL(alcSuspendContext),
|
|
|
|
DECL(alcDestroyContext),
|
|
|
|
DECL(alcGetCurrentContext),
|
|
|
|
DECL(alcGetContextsDevice),
|
|
|
|
DECL(alcOpenDevice),
|
|
|
|
DECL(alcCloseDevice),
|
|
|
|
DECL(alcGetError),
|
|
|
|
DECL(alcIsExtensionPresent),
|
|
|
|
DECL(alcGetProcAddress),
|
|
|
|
DECL(alcGetEnumValue),
|
|
|
|
DECL(alcGetString),
|
|
|
|
DECL(alcGetIntegerv),
|
|
|
|
DECL(alcCaptureOpenDevice),
|
|
|
|
DECL(alcCaptureCloseDevice),
|
|
|
|
DECL(alcCaptureStart),
|
|
|
|
DECL(alcCaptureStop),
|
|
|
|
DECL(alcCaptureSamples),
|
|
|
|
|
|
|
|
DECL(alcSetThreadContext),
|
|
|
|
DECL(alcGetThreadContext),
|
|
|
|
|
|
|
|
DECL(alcLoopbackOpenDeviceSOFT),
|
|
|
|
DECL(alcIsRenderFormatSupportedSOFT),
|
|
|
|
DECL(alcRenderSamplesSOFT),
|
|
|
|
|
2014-01-15 16:27:17 -08:00
|
|
|
DECL(alcDevicePauseSOFT),
|
|
|
|
DECL(alcDeviceResumeSOFT),
|
|
|
|
|
2015-10-02 23:54:30 -07:00
|
|
|
DECL(alcGetStringiSOFT),
|
2015-05-16 01:46:06 -07:00
|
|
|
DECL(alcResetDeviceSOFT),
|
|
|
|
|
2015-10-28 13:38:30 -07:00
|
|
|
DECL(alcGetInteger64vSOFT),
|
|
|
|
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(alEnable),
|
|
|
|
DECL(alDisable),
|
|
|
|
DECL(alIsEnabled),
|
|
|
|
DECL(alGetString),
|
|
|
|
DECL(alGetBooleanv),
|
|
|
|
DECL(alGetIntegerv),
|
|
|
|
DECL(alGetFloatv),
|
|
|
|
DECL(alGetDoublev),
|
|
|
|
DECL(alGetBoolean),
|
|
|
|
DECL(alGetInteger),
|
|
|
|
DECL(alGetFloat),
|
|
|
|
DECL(alGetDouble),
|
|
|
|
DECL(alGetError),
|
|
|
|
DECL(alIsExtensionPresent),
|
|
|
|
DECL(alGetProcAddress),
|
|
|
|
DECL(alGetEnumValue),
|
|
|
|
DECL(alListenerf),
|
|
|
|
DECL(alListener3f),
|
|
|
|
DECL(alListenerfv),
|
|
|
|
DECL(alListeneri),
|
|
|
|
DECL(alListener3i),
|
|
|
|
DECL(alListeneriv),
|
|
|
|
DECL(alGetListenerf),
|
|
|
|
DECL(alGetListener3f),
|
|
|
|
DECL(alGetListenerfv),
|
|
|
|
DECL(alGetListeneri),
|
|
|
|
DECL(alGetListener3i),
|
|
|
|
DECL(alGetListeneriv),
|
|
|
|
DECL(alGenSources),
|
|
|
|
DECL(alDeleteSources),
|
|
|
|
DECL(alIsSource),
|
|
|
|
DECL(alSourcef),
|
|
|
|
DECL(alSource3f),
|
|
|
|
DECL(alSourcefv),
|
|
|
|
DECL(alSourcei),
|
|
|
|
DECL(alSource3i),
|
|
|
|
DECL(alSourceiv),
|
|
|
|
DECL(alGetSourcef),
|
|
|
|
DECL(alGetSource3f),
|
|
|
|
DECL(alGetSourcefv),
|
|
|
|
DECL(alGetSourcei),
|
|
|
|
DECL(alGetSource3i),
|
|
|
|
DECL(alGetSourceiv),
|
|
|
|
DECL(alSourcePlayv),
|
|
|
|
DECL(alSourceStopv),
|
|
|
|
DECL(alSourceRewindv),
|
|
|
|
DECL(alSourcePausev),
|
|
|
|
DECL(alSourcePlay),
|
|
|
|
DECL(alSourceStop),
|
|
|
|
DECL(alSourceRewind),
|
|
|
|
DECL(alSourcePause),
|
|
|
|
DECL(alSourceQueueBuffers),
|
|
|
|
DECL(alSourceUnqueueBuffers),
|
|
|
|
DECL(alGenBuffers),
|
|
|
|
DECL(alDeleteBuffers),
|
|
|
|
DECL(alIsBuffer),
|
|
|
|
DECL(alBufferData),
|
|
|
|
DECL(alBufferf),
|
|
|
|
DECL(alBuffer3f),
|
|
|
|
DECL(alBufferfv),
|
|
|
|
DECL(alBufferi),
|
|
|
|
DECL(alBuffer3i),
|
|
|
|
DECL(alBufferiv),
|
|
|
|
DECL(alGetBufferf),
|
|
|
|
DECL(alGetBuffer3f),
|
|
|
|
DECL(alGetBufferfv),
|
|
|
|
DECL(alGetBufferi),
|
|
|
|
DECL(alGetBuffer3i),
|
|
|
|
DECL(alGetBufferiv),
|
|
|
|
DECL(alDopplerFactor),
|
|
|
|
DECL(alDopplerVelocity),
|
|
|
|
DECL(alSpeedOfSound),
|
|
|
|
DECL(alDistanceModel),
|
|
|
|
|
|
|
|
DECL(alGenFilters),
|
|
|
|
DECL(alDeleteFilters),
|
|
|
|
DECL(alIsFilter),
|
|
|
|
DECL(alFilteri),
|
|
|
|
DECL(alFilteriv),
|
|
|
|
DECL(alFilterf),
|
|
|
|
DECL(alFilterfv),
|
|
|
|
DECL(alGetFilteri),
|
|
|
|
DECL(alGetFilteriv),
|
|
|
|
DECL(alGetFilterf),
|
|
|
|
DECL(alGetFilterfv),
|
|
|
|
DECL(alGenEffects),
|
|
|
|
DECL(alDeleteEffects),
|
|
|
|
DECL(alIsEffect),
|
|
|
|
DECL(alEffecti),
|
|
|
|
DECL(alEffectiv),
|
|
|
|
DECL(alEffectf),
|
|
|
|
DECL(alEffectfv),
|
|
|
|
DECL(alGetEffecti),
|
|
|
|
DECL(alGetEffectiv),
|
|
|
|
DECL(alGetEffectf),
|
|
|
|
DECL(alGetEffectfv),
|
|
|
|
DECL(alGenAuxiliaryEffectSlots),
|
|
|
|
DECL(alDeleteAuxiliaryEffectSlots),
|
|
|
|
DECL(alIsAuxiliaryEffectSlot),
|
|
|
|
DECL(alAuxiliaryEffectSloti),
|
|
|
|
DECL(alAuxiliaryEffectSlotiv),
|
|
|
|
DECL(alAuxiliaryEffectSlotf),
|
|
|
|
DECL(alAuxiliaryEffectSlotfv),
|
|
|
|
DECL(alGetAuxiliaryEffectSloti),
|
|
|
|
DECL(alGetAuxiliaryEffectSlotiv),
|
|
|
|
DECL(alGetAuxiliaryEffectSlotf),
|
|
|
|
DECL(alGetAuxiliaryEffectSlotfv),
|
|
|
|
|
|
|
|
DECL(alDeferUpdatesSOFT),
|
|
|
|
DECL(alProcessUpdatesSOFT),
|
|
|
|
|
2012-10-13 00:56:39 -07:00
|
|
|
DECL(alSourcedSOFT),
|
|
|
|
DECL(alSource3dSOFT),
|
|
|
|
DECL(alSourcedvSOFT),
|
2012-08-20 15:26:35 -07:00
|
|
|
DECL(alGetSourcedSOFT),
|
|
|
|
DECL(alGetSource3dSOFT),
|
|
|
|
DECL(alGetSourcedvSOFT),
|
2012-10-13 00:56:39 -07:00
|
|
|
DECL(alSourcei64SOFT),
|
|
|
|
DECL(alSource3i64SOFT),
|
|
|
|
DECL(alSourcei64vSOFT),
|
2012-08-18 11:02:54 -07:00
|
|
|
DECL(alGetSourcei64SOFT),
|
2012-08-20 14:48:08 -07:00
|
|
|
DECL(alGetSource3i64SOFT),
|
2012-08-18 11:02:54 -07:00
|
|
|
DECL(alGetSourcei64vSOFT),
|
|
|
|
|
2017-04-21 04:15:08 -07:00
|
|
|
DECL(alGetStringiSOFT),
|
2018-01-20 13:37:43 -08:00
|
|
|
|
2018-01-23 14:33:30 -08:00
|
|
|
DECL(alBufferStorageSOFT),
|
2018-01-20 13:37:43 -08:00
|
|
|
DECL(alMapBufferSOFT),
|
|
|
|
DECL(alUnmapBufferSOFT),
|
2018-01-23 14:33:30 -08:00
|
|
|
DECL(alFlushMappedBufferSOFT),
|
2018-01-23 18:25:59 -08:00
|
|
|
|
|
|
|
DECL(alEventControlSOFT),
|
|
|
|
DECL(alEventCallbackSOFT),
|
|
|
|
DECL(alGetPointerSOFT),
|
|
|
|
DECL(alGetPointervSOFT),
|
2007-11-13 18:02:18 -08:00
|
|
|
};
|
2012-04-20 22:38:03 -07:00
|
|
|
#undef DECL
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2012-04-20 22:38:03 -07:00
|
|
|
#define DECL(x) { #x, (x) }
|
2018-11-14 06:17:47 -08:00
|
|
|
constexpr struct {
|
2017-03-14 08:37:50 -07:00
|
|
|
const ALCchar *enumName;
|
|
|
|
ALCenum value;
|
|
|
|
} alcEnumerations[] = {
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(ALC_INVALID),
|
|
|
|
DECL(ALC_FALSE),
|
|
|
|
DECL(ALC_TRUE),
|
|
|
|
|
|
|
|
DECL(ALC_MAJOR_VERSION),
|
|
|
|
DECL(ALC_MINOR_VERSION),
|
|
|
|
DECL(ALC_ATTRIBUTES_SIZE),
|
|
|
|
DECL(ALC_ALL_ATTRIBUTES),
|
|
|
|
DECL(ALC_DEFAULT_DEVICE_SPECIFIER),
|
|
|
|
DECL(ALC_DEVICE_SPECIFIER),
|
|
|
|
DECL(ALC_ALL_DEVICES_SPECIFIER),
|
|
|
|
DECL(ALC_DEFAULT_ALL_DEVICES_SPECIFIER),
|
|
|
|
DECL(ALC_EXTENSIONS),
|
|
|
|
DECL(ALC_FREQUENCY),
|
|
|
|
DECL(ALC_REFRESH),
|
|
|
|
DECL(ALC_SYNC),
|
|
|
|
DECL(ALC_MONO_SOURCES),
|
|
|
|
DECL(ALC_STEREO_SOURCES),
|
|
|
|
DECL(ALC_CAPTURE_DEVICE_SPECIFIER),
|
|
|
|
DECL(ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER),
|
|
|
|
DECL(ALC_CAPTURE_SAMPLES),
|
|
|
|
DECL(ALC_CONNECTED),
|
|
|
|
|
|
|
|
DECL(ALC_EFX_MAJOR_VERSION),
|
|
|
|
DECL(ALC_EFX_MINOR_VERSION),
|
|
|
|
DECL(ALC_MAX_AUXILIARY_SENDS),
|
|
|
|
|
|
|
|
DECL(ALC_FORMAT_CHANNELS_SOFT),
|
|
|
|
DECL(ALC_FORMAT_TYPE_SOFT),
|
|
|
|
|
|
|
|
DECL(ALC_MONO_SOFT),
|
|
|
|
DECL(ALC_STEREO_SOFT),
|
|
|
|
DECL(ALC_QUAD_SOFT),
|
|
|
|
DECL(ALC_5POINT1_SOFT),
|
|
|
|
DECL(ALC_6POINT1_SOFT),
|
|
|
|
DECL(ALC_7POINT1_SOFT),
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
DECL(ALC_BFORMAT3D_SOFT),
|
2012-04-20 22:38:03 -07:00
|
|
|
|
|
|
|
DECL(ALC_BYTE_SOFT),
|
|
|
|
DECL(ALC_UNSIGNED_BYTE_SOFT),
|
|
|
|
DECL(ALC_SHORT_SOFT),
|
|
|
|
DECL(ALC_UNSIGNED_SHORT_SOFT),
|
|
|
|
DECL(ALC_INT_SOFT),
|
|
|
|
DECL(ALC_UNSIGNED_INT_SOFT),
|
|
|
|
DECL(ALC_FLOAT_SOFT),
|
|
|
|
|
2015-09-17 04:01:46 -07:00
|
|
|
DECL(ALC_HRTF_SOFT),
|
|
|
|
DECL(ALC_DONT_CARE_SOFT),
|
|
|
|
DECL(ALC_HRTF_STATUS_SOFT),
|
|
|
|
DECL(ALC_HRTF_DISABLED_SOFT),
|
|
|
|
DECL(ALC_HRTF_ENABLED_SOFT),
|
|
|
|
DECL(ALC_HRTF_DENIED_SOFT),
|
|
|
|
DECL(ALC_HRTF_REQUIRED_SOFT),
|
|
|
|
DECL(ALC_HRTF_HEADPHONES_DETECTED_SOFT),
|
|
|
|
DECL(ALC_HRTF_UNSUPPORTED_FORMAT_SOFT),
|
2015-10-26 22:34:02 -07:00
|
|
|
DECL(ALC_NUM_HRTF_SPECIFIERS_SOFT),
|
2015-10-02 23:54:30 -07:00
|
|
|
DECL(ALC_HRTF_SPECIFIER_SOFT),
|
2015-10-07 03:29:53 -07:00
|
|
|
DECL(ALC_HRTF_ID_SOFT),
|
2015-09-17 04:01:46 -07:00
|
|
|
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
DECL(ALC_AMBISONIC_LAYOUT_SOFT),
|
|
|
|
DECL(ALC_AMBISONIC_SCALING_SOFT),
|
|
|
|
DECL(ALC_AMBISONIC_ORDER_SOFT),
|
|
|
|
DECL(ALC_ACN_SOFT),
|
|
|
|
DECL(ALC_FUMA_SOFT),
|
|
|
|
DECL(ALC_N3D_SOFT),
|
|
|
|
DECL(ALC_SN3D_SOFT),
|
|
|
|
|
2017-04-30 04:21:48 -07:00
|
|
|
DECL(ALC_OUTPUT_LIMITER_SOFT),
|
|
|
|
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(ALC_NO_ERROR),
|
|
|
|
DECL(ALC_INVALID_DEVICE),
|
|
|
|
DECL(ALC_INVALID_CONTEXT),
|
|
|
|
DECL(ALC_INVALID_ENUM),
|
|
|
|
DECL(ALC_INVALID_VALUE),
|
|
|
|
DECL(ALC_OUT_OF_MEMORY),
|
|
|
|
|
|
|
|
|
|
|
|
DECL(AL_INVALID),
|
|
|
|
DECL(AL_NONE),
|
|
|
|
DECL(AL_FALSE),
|
|
|
|
DECL(AL_TRUE),
|
|
|
|
|
|
|
|
DECL(AL_SOURCE_RELATIVE),
|
|
|
|
DECL(AL_CONE_INNER_ANGLE),
|
|
|
|
DECL(AL_CONE_OUTER_ANGLE),
|
|
|
|
DECL(AL_PITCH),
|
|
|
|
DECL(AL_POSITION),
|
|
|
|
DECL(AL_DIRECTION),
|
|
|
|
DECL(AL_VELOCITY),
|
|
|
|
DECL(AL_LOOPING),
|
|
|
|
DECL(AL_BUFFER),
|
|
|
|
DECL(AL_GAIN),
|
|
|
|
DECL(AL_MIN_GAIN),
|
|
|
|
DECL(AL_MAX_GAIN),
|
|
|
|
DECL(AL_ORIENTATION),
|
|
|
|
DECL(AL_REFERENCE_DISTANCE),
|
|
|
|
DECL(AL_ROLLOFF_FACTOR),
|
|
|
|
DECL(AL_CONE_OUTER_GAIN),
|
|
|
|
DECL(AL_MAX_DISTANCE),
|
|
|
|
DECL(AL_SEC_OFFSET),
|
|
|
|
DECL(AL_SAMPLE_OFFSET),
|
|
|
|
DECL(AL_BYTE_OFFSET),
|
|
|
|
DECL(AL_SOURCE_TYPE),
|
|
|
|
DECL(AL_STATIC),
|
|
|
|
DECL(AL_STREAMING),
|
|
|
|
DECL(AL_UNDETERMINED),
|
|
|
|
DECL(AL_METERS_PER_UNIT),
|
2015-09-17 04:01:46 -07:00
|
|
|
DECL(AL_LOOP_POINTS_SOFT),
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_DIRECT_CHANNELS_SOFT),
|
|
|
|
|
|
|
|
DECL(AL_DIRECT_FILTER),
|
|
|
|
DECL(AL_AUXILIARY_SEND_FILTER),
|
|
|
|
DECL(AL_AIR_ABSORPTION_FACTOR),
|
|
|
|
DECL(AL_ROOM_ROLLOFF_FACTOR),
|
|
|
|
DECL(AL_CONE_OUTER_GAINHF),
|
|
|
|
DECL(AL_DIRECT_FILTER_GAINHF_AUTO),
|
|
|
|
DECL(AL_AUXILIARY_SEND_FILTER_GAIN_AUTO),
|
|
|
|
DECL(AL_AUXILIARY_SEND_FILTER_GAINHF_AUTO),
|
|
|
|
|
|
|
|
DECL(AL_SOURCE_STATE),
|
|
|
|
DECL(AL_INITIAL),
|
|
|
|
DECL(AL_PLAYING),
|
|
|
|
DECL(AL_PAUSED),
|
|
|
|
DECL(AL_STOPPED),
|
|
|
|
|
|
|
|
DECL(AL_BUFFERS_QUEUED),
|
|
|
|
DECL(AL_BUFFERS_PROCESSED),
|
|
|
|
|
|
|
|
DECL(AL_FORMAT_MONO8),
|
|
|
|
DECL(AL_FORMAT_MONO16),
|
|
|
|
DECL(AL_FORMAT_MONO_FLOAT32),
|
|
|
|
DECL(AL_FORMAT_MONO_DOUBLE_EXT),
|
|
|
|
DECL(AL_FORMAT_STEREO8),
|
|
|
|
DECL(AL_FORMAT_STEREO16),
|
|
|
|
DECL(AL_FORMAT_STEREO_FLOAT32),
|
|
|
|
DECL(AL_FORMAT_STEREO_DOUBLE_EXT),
|
|
|
|
DECL(AL_FORMAT_MONO_IMA4),
|
|
|
|
DECL(AL_FORMAT_STEREO_IMA4),
|
2014-03-04 22:44:30 -08:00
|
|
|
DECL(AL_FORMAT_MONO_MSADPCM_SOFT),
|
|
|
|
DECL(AL_FORMAT_STEREO_MSADPCM_SOFT),
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_FORMAT_QUAD8_LOKI),
|
|
|
|
DECL(AL_FORMAT_QUAD16_LOKI),
|
|
|
|
DECL(AL_FORMAT_QUAD8),
|
|
|
|
DECL(AL_FORMAT_QUAD16),
|
|
|
|
DECL(AL_FORMAT_QUAD32),
|
|
|
|
DECL(AL_FORMAT_51CHN8),
|
|
|
|
DECL(AL_FORMAT_51CHN16),
|
|
|
|
DECL(AL_FORMAT_51CHN32),
|
|
|
|
DECL(AL_FORMAT_61CHN8),
|
|
|
|
DECL(AL_FORMAT_61CHN16),
|
|
|
|
DECL(AL_FORMAT_61CHN32),
|
|
|
|
DECL(AL_FORMAT_71CHN8),
|
|
|
|
DECL(AL_FORMAT_71CHN16),
|
|
|
|
DECL(AL_FORMAT_71CHN32),
|
|
|
|
DECL(AL_FORMAT_REAR8),
|
|
|
|
DECL(AL_FORMAT_REAR16),
|
|
|
|
DECL(AL_FORMAT_REAR32),
|
|
|
|
DECL(AL_FORMAT_MONO_MULAW),
|
|
|
|
DECL(AL_FORMAT_MONO_MULAW_EXT),
|
|
|
|
DECL(AL_FORMAT_STEREO_MULAW),
|
|
|
|
DECL(AL_FORMAT_STEREO_MULAW_EXT),
|
|
|
|
DECL(AL_FORMAT_QUAD_MULAW),
|
|
|
|
DECL(AL_FORMAT_51CHN_MULAW),
|
|
|
|
DECL(AL_FORMAT_61CHN_MULAW),
|
|
|
|
DECL(AL_FORMAT_71CHN_MULAW),
|
|
|
|
DECL(AL_FORMAT_REAR_MULAW),
|
|
|
|
DECL(AL_FORMAT_MONO_ALAW_EXT),
|
|
|
|
DECL(AL_FORMAT_STEREO_ALAW_EXT),
|
|
|
|
|
2016-04-25 18:56:59 -07:00
|
|
|
DECL(AL_FORMAT_BFORMAT2D_8),
|
|
|
|
DECL(AL_FORMAT_BFORMAT2D_16),
|
|
|
|
DECL(AL_FORMAT_BFORMAT2D_FLOAT32),
|
|
|
|
DECL(AL_FORMAT_BFORMAT2D_MULAW),
|
|
|
|
DECL(AL_FORMAT_BFORMAT3D_8),
|
|
|
|
DECL(AL_FORMAT_BFORMAT3D_16),
|
|
|
|
DECL(AL_FORMAT_BFORMAT3D_FLOAT32),
|
|
|
|
DECL(AL_FORMAT_BFORMAT3D_MULAW),
|
|
|
|
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_FREQUENCY),
|
|
|
|
DECL(AL_BITS),
|
|
|
|
DECL(AL_CHANNELS),
|
|
|
|
DECL(AL_SIZE),
|
Add an extension to alter the block alignment for buffer unpack/pack ops
This is for unpacking (reading, e.g. alBufferData) and packing (writing, e.g.
alGetBufferSamplesSOFT) operations. The alignments are specified in sample
frames, with 0 meaning the default (65 for IMA4, 1 otherwise). IMA4 alignment
must be a multiple of 8, plus 1 (e.g. alignment = n*8 + 1), otherwise an error
will occur during (un)packing. Chenging the block alignment does not affect
already-loaded sample data, only future unpack/pack operations... so for
example, this is perfectly valid:
// Load mono IMA4 data with a block alignment of 1024 bytes, or 2041 sample
// frames.
alBufferi(buffer, AL_UNPACK_BLOCK_ALIGNMENT_SOFT, 2041);
alBufferData(buffer, AL_FORMAT_MONO_IMA4, data, data_len, srate);
alBufferi(buffer, AL_UNPACK_BLOCK_ALIGNMENT_SOFT, 0);
2014-03-04 05:16:45 -08:00
|
|
|
DECL(AL_UNPACK_BLOCK_ALIGNMENT_SOFT),
|
|
|
|
DECL(AL_PACK_BLOCK_ALIGNMENT_SOFT),
|
2012-04-20 22:38:03 -07:00
|
|
|
|
2016-04-25 00:30:47 -07:00
|
|
|
DECL(AL_SOURCE_RADIUS),
|
|
|
|
|
2016-03-25 14:40:44 -07:00
|
|
|
DECL(AL_STEREO_ANGLES),
|
|
|
|
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_UNUSED),
|
|
|
|
DECL(AL_PENDING),
|
|
|
|
DECL(AL_PROCESSED),
|
|
|
|
|
|
|
|
DECL(AL_NO_ERROR),
|
|
|
|
DECL(AL_INVALID_NAME),
|
|
|
|
DECL(AL_INVALID_ENUM),
|
|
|
|
DECL(AL_INVALID_VALUE),
|
|
|
|
DECL(AL_INVALID_OPERATION),
|
|
|
|
DECL(AL_OUT_OF_MEMORY),
|
|
|
|
|
|
|
|
DECL(AL_VENDOR),
|
|
|
|
DECL(AL_VERSION),
|
|
|
|
DECL(AL_RENDERER),
|
|
|
|
DECL(AL_EXTENSIONS),
|
|
|
|
|
|
|
|
DECL(AL_DOPPLER_FACTOR),
|
|
|
|
DECL(AL_DOPPLER_VELOCITY),
|
|
|
|
DECL(AL_DISTANCE_MODEL),
|
|
|
|
DECL(AL_SPEED_OF_SOUND),
|
|
|
|
DECL(AL_SOURCE_DISTANCE_MODEL),
|
|
|
|
DECL(AL_DEFERRED_UPDATES_SOFT),
|
2016-08-28 18:21:09 -07:00
|
|
|
DECL(AL_GAIN_LIMIT_SOFT),
|
2012-04-20 22:38:03 -07:00
|
|
|
|
|
|
|
DECL(AL_INVERSE_DISTANCE),
|
|
|
|
DECL(AL_INVERSE_DISTANCE_CLAMPED),
|
|
|
|
DECL(AL_LINEAR_DISTANCE),
|
|
|
|
DECL(AL_LINEAR_DISTANCE_CLAMPED),
|
|
|
|
DECL(AL_EXPONENT_DISTANCE),
|
|
|
|
DECL(AL_EXPONENT_DISTANCE_CLAMPED),
|
|
|
|
|
|
|
|
DECL(AL_FILTER_TYPE),
|
|
|
|
DECL(AL_FILTER_NULL),
|
|
|
|
DECL(AL_FILTER_LOWPASS),
|
|
|
|
DECL(AL_FILTER_HIGHPASS),
|
|
|
|
DECL(AL_FILTER_BANDPASS),
|
2012-04-20 01:24:58 -07:00
|
|
|
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_LOWPASS_GAIN),
|
|
|
|
DECL(AL_LOWPASS_GAINHF),
|
2012-04-20 01:24:58 -07:00
|
|
|
|
2014-05-17 07:29:50 -07:00
|
|
|
DECL(AL_HIGHPASS_GAIN),
|
|
|
|
DECL(AL_HIGHPASS_GAINLF),
|
|
|
|
|
2014-05-17 08:04:14 -07:00
|
|
|
DECL(AL_BANDPASS_GAIN),
|
|
|
|
DECL(AL_BANDPASS_GAINHF),
|
|
|
|
DECL(AL_BANDPASS_GAINLF),
|
|
|
|
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_EFFECT_TYPE),
|
|
|
|
DECL(AL_EFFECT_NULL),
|
|
|
|
DECL(AL_EFFECT_REVERB),
|
|
|
|
DECL(AL_EFFECT_EAXREVERB),
|
|
|
|
DECL(AL_EFFECT_CHORUS),
|
|
|
|
DECL(AL_EFFECT_DISTORTION),
|
|
|
|
DECL(AL_EFFECT_ECHO),
|
|
|
|
DECL(AL_EFFECT_FLANGER),
|
2018-03-18 17:47:17 +01:00
|
|
|
DECL(AL_EFFECT_PITCH_SHIFTER),
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_EFFECT_FREQUENCY_SHIFTER),
|
|
|
|
DECL(AL_EFFECT_VOCAL_MORPHER),
|
|
|
|
DECL(AL_EFFECT_RING_MODULATOR),
|
|
|
|
DECL(AL_EFFECT_AUTOWAH),
|
|
|
|
DECL(AL_EFFECT_COMPRESSOR),
|
2013-05-18 01:33:01 -07:00
|
|
|
DECL(AL_EFFECT_EQUALIZER),
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_EFFECT_DEDICATED_LOW_FREQUENCY_EFFECT),
|
|
|
|
DECL(AL_EFFECT_DEDICATED_DIALOGUE),
|
|
|
|
|
2017-01-05 20:06:24 -08:00
|
|
|
DECL(AL_EFFECTSLOT_EFFECT),
|
|
|
|
DECL(AL_EFFECTSLOT_GAIN),
|
|
|
|
DECL(AL_EFFECTSLOT_AUXILIARY_SEND_AUTO),
|
|
|
|
DECL(AL_EFFECTSLOT_NULL),
|
|
|
|
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_EAXREVERB_DENSITY),
|
|
|
|
DECL(AL_EAXREVERB_DIFFUSION),
|
|
|
|
DECL(AL_EAXREVERB_GAIN),
|
|
|
|
DECL(AL_EAXREVERB_GAINHF),
|
|
|
|
DECL(AL_EAXREVERB_GAINLF),
|
|
|
|
DECL(AL_EAXREVERB_DECAY_TIME),
|
|
|
|
DECL(AL_EAXREVERB_DECAY_HFRATIO),
|
|
|
|
DECL(AL_EAXREVERB_DECAY_LFRATIO),
|
|
|
|
DECL(AL_EAXREVERB_REFLECTIONS_GAIN),
|
|
|
|
DECL(AL_EAXREVERB_REFLECTIONS_DELAY),
|
|
|
|
DECL(AL_EAXREVERB_REFLECTIONS_PAN),
|
|
|
|
DECL(AL_EAXREVERB_LATE_REVERB_GAIN),
|
|
|
|
DECL(AL_EAXREVERB_LATE_REVERB_DELAY),
|
|
|
|
DECL(AL_EAXREVERB_LATE_REVERB_PAN),
|
|
|
|
DECL(AL_EAXREVERB_ECHO_TIME),
|
|
|
|
DECL(AL_EAXREVERB_ECHO_DEPTH),
|
|
|
|
DECL(AL_EAXREVERB_MODULATION_TIME),
|
|
|
|
DECL(AL_EAXREVERB_MODULATION_DEPTH),
|
|
|
|
DECL(AL_EAXREVERB_AIR_ABSORPTION_GAINHF),
|
|
|
|
DECL(AL_EAXREVERB_HFREFERENCE),
|
|
|
|
DECL(AL_EAXREVERB_LFREFERENCE),
|
|
|
|
DECL(AL_EAXREVERB_ROOM_ROLLOFF_FACTOR),
|
|
|
|
DECL(AL_EAXREVERB_DECAY_HFLIMIT),
|
|
|
|
|
|
|
|
DECL(AL_REVERB_DENSITY),
|
|
|
|
DECL(AL_REVERB_DIFFUSION),
|
|
|
|
DECL(AL_REVERB_GAIN),
|
|
|
|
DECL(AL_REVERB_GAINHF),
|
|
|
|
DECL(AL_REVERB_DECAY_TIME),
|
|
|
|
DECL(AL_REVERB_DECAY_HFRATIO),
|
|
|
|
DECL(AL_REVERB_REFLECTIONS_GAIN),
|
|
|
|
DECL(AL_REVERB_REFLECTIONS_DELAY),
|
|
|
|
DECL(AL_REVERB_LATE_REVERB_GAIN),
|
|
|
|
DECL(AL_REVERB_LATE_REVERB_DELAY),
|
|
|
|
DECL(AL_REVERB_AIR_ABSORPTION_GAINHF),
|
|
|
|
DECL(AL_REVERB_ROOM_ROLLOFF_FACTOR),
|
|
|
|
DECL(AL_REVERB_DECAY_HFLIMIT),
|
|
|
|
|
2013-03-13 23:31:12 -07:00
|
|
|
DECL(AL_CHORUS_WAVEFORM),
|
|
|
|
DECL(AL_CHORUS_PHASE),
|
|
|
|
DECL(AL_CHORUS_RATE),
|
|
|
|
DECL(AL_CHORUS_DEPTH),
|
|
|
|
DECL(AL_CHORUS_FEEDBACK),
|
|
|
|
DECL(AL_CHORUS_DELAY),
|
|
|
|
|
2013-10-03 07:55:12 -07:00
|
|
|
DECL(AL_DISTORTION_EDGE),
|
|
|
|
DECL(AL_DISTORTION_GAIN),
|
|
|
|
DECL(AL_DISTORTION_LOWPASS_CUTOFF),
|
|
|
|
DECL(AL_DISTORTION_EQCENTER),
|
|
|
|
DECL(AL_DISTORTION_EQBANDWIDTH),
|
|
|
|
|
|
|
|
DECL(AL_ECHO_DELAY),
|
|
|
|
DECL(AL_ECHO_LRDELAY),
|
|
|
|
DECL(AL_ECHO_DAMPING),
|
|
|
|
DECL(AL_ECHO_FEEDBACK),
|
|
|
|
DECL(AL_ECHO_SPREAD),
|
|
|
|
|
2013-03-13 23:31:12 -07:00
|
|
|
DECL(AL_FLANGER_WAVEFORM),
|
|
|
|
DECL(AL_FLANGER_PHASE),
|
|
|
|
DECL(AL_FLANGER_RATE),
|
|
|
|
DECL(AL_FLANGER_DEPTH),
|
|
|
|
DECL(AL_FLANGER_FEEDBACK),
|
|
|
|
DECL(AL_FLANGER_DELAY),
|
|
|
|
|
2018-05-20 17:23:03 +02:00
|
|
|
DECL(AL_FREQUENCY_SHIFTER_FREQUENCY),
|
|
|
|
DECL(AL_FREQUENCY_SHIFTER_LEFT_DIRECTION),
|
|
|
|
DECL(AL_FREQUENCY_SHIFTER_RIGHT_DIRECTION),
|
|
|
|
|
2013-10-03 07:55:12 -07:00
|
|
|
DECL(AL_RING_MODULATOR_FREQUENCY),
|
|
|
|
DECL(AL_RING_MODULATOR_HIGHPASS_CUTOFF),
|
|
|
|
DECL(AL_RING_MODULATOR_WAVEFORM),
|
|
|
|
|
2018-03-18 17:47:17 +01:00
|
|
|
DECL(AL_PITCH_SHIFTER_COARSE_TUNE),
|
|
|
|
DECL(AL_PITCH_SHIFTER_FINE_TUNE),
|
|
|
|
|
2013-10-03 07:55:12 -07:00
|
|
|
DECL(AL_COMPRESSOR_ONOFF),
|
|
|
|
|
2013-05-18 01:33:01 -07:00
|
|
|
DECL(AL_EQUALIZER_LOW_GAIN),
|
|
|
|
DECL(AL_EQUALIZER_LOW_CUTOFF),
|
|
|
|
DECL(AL_EQUALIZER_MID1_GAIN),
|
|
|
|
DECL(AL_EQUALIZER_MID1_CENTER),
|
|
|
|
DECL(AL_EQUALIZER_MID1_WIDTH),
|
|
|
|
DECL(AL_EQUALIZER_MID2_GAIN),
|
|
|
|
DECL(AL_EQUALIZER_MID2_CENTER),
|
|
|
|
DECL(AL_EQUALIZER_MID2_WIDTH),
|
|
|
|
DECL(AL_EQUALIZER_HIGH_GAIN),
|
|
|
|
DECL(AL_EQUALIZER_HIGH_CUTOFF),
|
|
|
|
|
2012-04-20 22:38:03 -07:00
|
|
|
DECL(AL_DEDICATED_GAIN),
|
2017-04-21 04:15:08 -07:00
|
|
|
|
2018-09-07 18:45:24 -07:00
|
|
|
DECL(AL_AUTOWAH_ATTACK_TIME),
|
|
|
|
DECL(AL_AUTOWAH_RELEASE_TIME),
|
|
|
|
DECL(AL_AUTOWAH_RESONANCE),
|
2018-07-22 00:48:54 +02:00
|
|
|
DECL(AL_AUTOWAH_PEAK_GAIN),
|
|
|
|
|
2019-08-10 18:42:02 +02:00
|
|
|
DECL(AL_VOCAL_MORPHER_PHONEMEA),
|
|
|
|
DECL(AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING),
|
|
|
|
DECL(AL_VOCAL_MORPHER_PHONEMEB),
|
|
|
|
DECL(AL_VOCAL_MORPHER_PHONEMEB_COARSE_TUNING),
|
|
|
|
DECL(AL_VOCAL_MORPHER_WAVEFORM),
|
|
|
|
DECL(AL_VOCAL_MORPHER_RATE),
|
|
|
|
|
2017-04-21 04:15:08 -07:00
|
|
|
DECL(AL_NUM_RESAMPLERS_SOFT),
|
|
|
|
DECL(AL_DEFAULT_RESAMPLER_SOFT),
|
|
|
|
DECL(AL_SOURCE_RESAMPLER_SOFT),
|
|
|
|
DECL(AL_RESAMPLER_NAME_SOFT),
|
2017-05-05 02:41:34 -07:00
|
|
|
|
|
|
|
DECL(AL_SOURCE_SPATIALIZE_SOFT),
|
|
|
|
DECL(AL_AUTO_SOFT),
|
2018-01-20 13:37:43 -08:00
|
|
|
|
|
|
|
DECL(AL_MAP_READ_BIT_SOFT),
|
|
|
|
DECL(AL_MAP_WRITE_BIT_SOFT),
|
2018-01-23 14:33:30 -08:00
|
|
|
DECL(AL_MAP_PERSISTENT_BIT_SOFT),
|
|
|
|
DECL(AL_PRESERVE_DATA_BIT_SOFT),
|
2018-01-23 18:25:59 -08:00
|
|
|
|
|
|
|
DECL(AL_EVENT_CALLBACK_FUNCTION_SOFT),
|
|
|
|
DECL(AL_EVENT_CALLBACK_USER_PARAM_SOFT),
|
|
|
|
DECL(AL_EVENT_TYPE_BUFFER_COMPLETED_SOFT),
|
|
|
|
DECL(AL_EVENT_TYPE_SOURCE_STATE_CHANGED_SOFT),
|
|
|
|
DECL(AL_EVENT_TYPE_ERROR_SOFT),
|
|
|
|
DECL(AL_EVENT_TYPE_PERFORMANCE_SOFT),
|
2018-01-24 18:42:00 -08:00
|
|
|
DECL(AL_EVENT_TYPE_DEPRECATED_SOFT),
|
2007-11-13 18:02:18 -08:00
|
|
|
};
|
2012-04-20 22:38:03 -07:00
|
|
|
#undef DECL
|
2012-04-20 01:18:38 -07:00
|
|
|
|
2018-11-14 06:17:47 -08:00
|
|
|
constexpr ALCchar alcNoError[] = "No Error";
|
|
|
|
constexpr ALCchar alcErrInvalidDevice[] = "Invalid Device";
|
|
|
|
constexpr ALCchar alcErrInvalidContext[] = "Invalid Context";
|
|
|
|
constexpr ALCchar alcErrInvalidEnum[] = "Invalid Enum";
|
|
|
|
constexpr ALCchar alcErrInvalidValue[] = "Invalid Value";
|
|
|
|
constexpr ALCchar alcErrOutOfMemory[] = "Out of Memory";
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
/************************************************
|
|
|
|
* Global variables
|
|
|
|
************************************************/
|
|
|
|
|
|
|
|
/* Enumerated device names */
|
2018-11-14 06:17:47 -08:00
|
|
|
constexpr ALCchar alcDefaultName[] = "OpenAL Soft\0";
|
2014-03-28 05:40:24 -07:00
|
|
|
|
2018-11-15 04:24:33 -08:00
|
|
|
std::string alcAllDevicesList;
|
|
|
|
std::string alcCaptureDeviceList;
|
2012-04-20 01:18:38 -07:00
|
|
|
|
2011-08-20 03:59:46 -07:00
|
|
|
/* Default is always the first in the list */
|
2018-11-14 06:17:47 -08:00
|
|
|
std::string alcDefaultAllDevicesSpecifier;
|
|
|
|
std::string alcCaptureDefaultDeviceSpecifier;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/* Default context extensions */
|
2018-11-14 06:17:47 -08:00
|
|
|
constexpr ALchar alExtList[] =
|
2018-01-20 13:37:43 -08:00
|
|
|
"AL_EXT_ALAW "
|
|
|
|
"AL_EXT_BFORMAT "
|
|
|
|
"AL_EXT_DOUBLE "
|
|
|
|
"AL_EXT_EXPONENT_DISTANCE "
|
|
|
|
"AL_EXT_FLOAT32 "
|
|
|
|
"AL_EXT_IMA4 "
|
|
|
|
"AL_EXT_LINEAR_DISTANCE "
|
|
|
|
"AL_EXT_MCFORMATS "
|
|
|
|
"AL_EXT_MULAW "
|
|
|
|
"AL_EXT_MULAW_BFORMAT "
|
|
|
|
"AL_EXT_MULAW_MCFORMATS "
|
|
|
|
"AL_EXT_OFFSET "
|
|
|
|
"AL_EXT_source_distance_model "
|
|
|
|
"AL_EXT_SOURCE_RADIUS "
|
|
|
|
"AL_EXT_STEREO_ANGLES "
|
|
|
|
"AL_LOKI_quadriphonic "
|
|
|
|
"AL_SOFT_block_alignment "
|
|
|
|
"AL_SOFT_deferred_updates "
|
|
|
|
"AL_SOFT_direct_channels "
|
2018-12-24 15:52:37 -08:00
|
|
|
"AL_SOFTX_effect_chain "
|
2018-01-24 19:59:22 -08:00
|
|
|
"AL_SOFTX_events "
|
2018-07-15 21:01:26 -07:00
|
|
|
"AL_SOFTX_filter_gain_ex "
|
2018-01-20 13:37:43 -08:00
|
|
|
"AL_SOFT_gain_clamp_ex "
|
|
|
|
"AL_SOFT_loop_points "
|
|
|
|
"AL_SOFTX_map_buffer "
|
|
|
|
"AL_SOFT_MSADPCM "
|
|
|
|
"AL_SOFT_source_latency "
|
|
|
|
"AL_SOFT_source_length "
|
|
|
|
"AL_SOFT_source_resampler "
|
|
|
|
"AL_SOFT_source_spatialize";
|
2010-01-09 02:48:18 -08:00
|
|
|
|
2018-11-14 06:17:47 -08:00
|
|
|
std::atomic<ALCenum> LastNullDeviceError{ALC_NO_ERROR};
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
/* Thread-local current context */
|
2018-12-08 21:58:44 -08:00
|
|
|
void ReleaseThreadCtx(ALCcontext *context)
|
|
|
|
{
|
2019-08-01 13:28:53 -07:00
|
|
|
const bool result{context->releaseIfNoDelete()};
|
|
|
|
ERR("Context %p current for thread being destroyed%s!\n", context,
|
|
|
|
result ? "" : ", leak detected");
|
2018-12-08 21:58:44 -08:00
|
|
|
}
|
|
|
|
|
2018-11-18 06:46:50 -08:00
|
|
|
class ThreadCtx {
|
2018-11-16 21:55:11 -08:00
|
|
|
ALCcontext *ctx{nullptr};
|
|
|
|
|
|
|
|
public:
|
|
|
|
~ThreadCtx()
|
|
|
|
{
|
2019-08-01 14:29:02 -07:00
|
|
|
if(ctx)
|
|
|
|
ReleaseThreadCtx(ctx);
|
2018-11-16 21:55:11 -08:00
|
|
|
ctx = nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
ALCcontext *get() const noexcept { return ctx; }
|
|
|
|
void set(ALCcontext *ctx_) noexcept { ctx = ctx_; }
|
2018-11-18 06:46:50 -08:00
|
|
|
};
|
|
|
|
thread_local ThreadCtx LocalContext;
|
2012-04-20 01:18:38 -07:00
|
|
|
/* Process-wide current context */
|
2018-11-14 06:17:47 -08:00
|
|
|
std::atomic<ALCcontext*> GlobalContext{nullptr};
|
2011-07-10 21:30:25 -07:00
|
|
|
|
2011-09-10 01:23:59 -07:00
|
|
|
/* Flag to trap ALC device errors */
|
2018-11-14 06:17:47 -08:00
|
|
|
bool TrapALCError{false};
|
2011-09-10 01:23:59 -07:00
|
|
|
|
2011-08-20 03:59:46 -07:00
|
|
|
/* One-time configuration init control */
|
2018-11-14 06:17:47 -08:00
|
|
|
std::once_flag alc_config_once{};
|
2011-08-20 03:59:46 -07:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/* Default effect that applies to sources that don't have an effect on send 0 */
|
2018-11-14 06:17:47 -08:00
|
|
|
ALeffect DefaultEffect;
|
2012-01-19 19:30:03 -08:00
|
|
|
|
2014-10-12 09:03:08 -07:00
|
|
|
/* Flag to specify if alcSuspendContext/alcProcessContext should defer/process
|
|
|
|
* updates.
|
|
|
|
*/
|
2018-11-14 06:17:47 -08:00
|
|
|
bool SuspendDefers{true};
|
2014-10-12 09:03:08 -07:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
/************************************************
|
|
|
|
* ALC information
|
|
|
|
************************************************/
|
2018-11-14 06:17:47 -08:00
|
|
|
constexpr ALCchar alcNoDeviceExtList[] =
|
2019-04-01 21:41:11 -07:00
|
|
|
"ALC_ENUMERATE_ALL_EXT "
|
|
|
|
"ALC_ENUMERATION_EXT "
|
|
|
|
"ALC_EXT_CAPTURE "
|
|
|
|
"ALC_EXT_thread_local_context "
|
|
|
|
"ALC_SOFT_loopback";
|
2018-11-14 06:17:47 -08:00
|
|
|
constexpr ALCchar alcExtensionList[] =
|
2019-04-01 21:41:11 -07:00
|
|
|
"ALC_ENUMERATE_ALL_EXT "
|
|
|
|
"ALC_ENUMERATION_EXT "
|
|
|
|
"ALC_EXT_CAPTURE "
|
|
|
|
"ALC_EXT_DEDICATED "
|
|
|
|
"ALC_EXT_disconnect "
|
|
|
|
"ALC_EXT_EFX "
|
|
|
|
"ALC_EXT_thread_local_context "
|
|
|
|
"ALC_SOFT_device_clock "
|
|
|
|
"ALC_SOFT_HRTF "
|
|
|
|
"ALC_SOFT_loopback "
|
|
|
|
"ALC_SOFT_output_limiter "
|
|
|
|
"ALC_SOFT_pause_device";
|
2018-11-14 06:17:47 -08:00
|
|
|
constexpr ALCint alcMajorVersion = 1;
|
|
|
|
constexpr ALCint alcMinorVersion = 1;
|
2012-04-20 01:18:38 -07:00
|
|
|
|
2018-11-14 06:17:47 -08:00
|
|
|
constexpr ALCint alcEFXMajorVersion = 1;
|
|
|
|
constexpr ALCint alcEFXMinorVersion = 0;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
|
2019-06-29 21:32:36 -07:00
|
|
|
/* To avoid extraneous allocations, a 0-sized FlexArray<ALCcontext*> is defined
|
|
|
|
* globally as a sharable object.
|
|
|
|
*/
|
|
|
|
al::FlexArray<ALCcontext*> EmptyContextArray{0u};
|
|
|
|
|
|
|
|
|
2019-08-01 15:19:37 -07:00
|
|
|
using DeviceRef = al::intrusive_ptr<ALCdevice>;
|
2019-06-29 22:38:38 -07:00
|
|
|
|
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/************************************************
|
|
|
|
* Device lists
|
|
|
|
************************************************/
|
2019-06-29 22:38:38 -07:00
|
|
|
al::vector<DeviceRef> DeviceList;
|
|
|
|
al::vector<ContextRef> ContextList;
|
2010-12-02 01:05:29 -08:00
|
|
|
|
2018-11-14 06:17:47 -08:00
|
|
|
std::recursive_mutex ListLock;
|
|
|
|
|
2009-09-12 17:29:35 -07:00
|
|
|
|
2019-06-29 12:16:38 -07:00
|
|
|
void alc_initconfig(void)
|
2011-06-14 09:43:33 -07:00
|
|
|
{
|
2019-08-12 03:59:52 -07:00
|
|
|
if(auto loglevel = al::getenv("ALSOFT_LOGLEVEL"))
|
2011-07-10 21:30:25 -07:00
|
|
|
{
|
2019-08-12 03:59:52 -07:00
|
|
|
long lvl = strtol(loglevel->c_str(), nullptr, 0);
|
2011-09-20 12:24:23 -07:00
|
|
|
if(lvl >= NoLog && lvl <= LogRef)
|
2018-12-09 15:07:44 -08:00
|
|
|
gLogLevel = static_cast<LogLevel>(lvl);
|
2011-07-10 21:30:25 -07:00
|
|
|
}
|
|
|
|
|
2019-08-12 03:59:52 -07:00
|
|
|
if(auto logfile = al::getenv("ALSOFT_LOGFILE"))
|
2011-06-17 18:54:05 -07:00
|
|
|
{
|
2018-11-10 04:27:10 -08:00
|
|
|
#ifdef _WIN32
|
2019-08-12 03:59:52 -07:00
|
|
|
std::wstring wname{utf8_to_wstr(logfile->c_str())};
|
|
|
|
FILE *logf{_wfopen(wname.c_str(), L"wt")};
|
2018-11-10 04:27:10 -08:00
|
|
|
#else
|
2019-08-12 03:59:52 -07:00
|
|
|
FILE *logf{fopen(logfile->c_str(), "wt")};
|
2018-11-10 04:27:10 -08:00
|
|
|
#endif
|
2019-08-12 03:59:52 -07:00
|
|
|
if(logf) gLogFile = logf;
|
|
|
|
else ERR("Failed to open log file '%s'\n", logfile->c_str());
|
2011-06-17 18:54:05 -07:00
|
|
|
}
|
|
|
|
|
2019-06-29 10:23:29 -07:00
|
|
|
TRACE("Initializing library v%s-%s %s\n", ALSOFT_VERSION, ALSOFT_GIT_COMMIT_HASH,
|
|
|
|
ALSOFT_GIT_BRANCH);
|
2012-12-04 13:46:51 -08:00
|
|
|
{
|
2018-11-18 07:00:43 -08:00
|
|
|
std::string names;
|
2019-06-29 10:23:29 -07:00
|
|
|
if(std::begin(BackendList) == BackendListEnd)
|
|
|
|
names += "(none)";
|
|
|
|
else
|
2018-11-18 07:00:43 -08:00
|
|
|
{
|
2019-06-29 10:23:29 -07:00
|
|
|
const al::span<const BackendInfo> infos{std::begin(BackendList), BackendListEnd};
|
|
|
|
names += infos[0].name;
|
|
|
|
for(const auto &backend : infos.subspan(1))
|
|
|
|
{
|
|
|
|
names += ", ";
|
|
|
|
names += backend.name;
|
|
|
|
}
|
2018-11-18 07:00:43 -08:00
|
|
|
}
|
|
|
|
TRACE("Supported backends: %s\n", names.c_str());
|
2012-12-04 13:46:51 -08:00
|
|
|
}
|
2010-06-08 02:02:48 -07:00
|
|
|
ReadALConfig();
|
|
|
|
|
2019-08-12 03:59:52 -07:00
|
|
|
if(auto suspendmode = al::getenv("__ALSOFT_SUSPEND_CONTEXT"))
|
2014-10-12 09:03:08 -07:00
|
|
|
{
|
2019-08-12 03:59:52 -07:00
|
|
|
if(strcasecmp(suspendmode->c_str(), "ignore") == 0)
|
2014-10-12 09:03:08 -07:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
SuspendDefers = false;
|
2014-10-12 09:03:08 -07:00
|
|
|
TRACE("Selected context suspend behavior, \"ignore\"\n");
|
|
|
|
}
|
|
|
|
else
|
2019-08-12 03:59:52 -07:00
|
|
|
ERR("Unhandled context suspend behavior setting: \"%s\"\n", suspendmode->c_str());
|
2014-10-12 09:03:08 -07:00
|
|
|
}
|
|
|
|
|
2019-04-11 02:49:13 -07:00
|
|
|
int capfilter{0};
|
2014-06-04 02:57:13 -07:00
|
|
|
#if defined(HAVE_SSE4_1)
|
2015-10-11 06:38:00 -07:00
|
|
|
capfilter |= CPU_CAP_SSE | CPU_CAP_SSE2 | CPU_CAP_SSE3 | CPU_CAP_SSE4_1;
|
|
|
|
#elif defined(HAVE_SSE3)
|
|
|
|
capfilter |= CPU_CAP_SSE | CPU_CAP_SSE2 | CPU_CAP_SSE3;
|
2014-06-04 02:57:13 -07:00
|
|
|
#elif defined(HAVE_SSE2)
|
2013-05-22 16:59:20 -07:00
|
|
|
capfilter |= CPU_CAP_SSE | CPU_CAP_SSE2;
|
2014-06-04 02:57:13 -07:00
|
|
|
#elif defined(HAVE_SSE)
|
|
|
|
capfilter |= CPU_CAP_SSE;
|
2012-08-15 01:24:50 -07:00
|
|
|
#endif
|
|
|
|
#ifdef HAVE_NEON
|
|
|
|
capfilter |= CPU_CAP_NEON;
|
|
|
|
#endif
|
2019-06-30 16:15:15 -07:00
|
|
|
if(auto cpuopt = ConfigValueStr(nullptr, nullptr, "disable-cpu-exts"))
|
2012-08-13 10:37:49 -07:00
|
|
|
{
|
2019-08-12 03:59:52 -07:00
|
|
|
const char *str{cpuopt->c_str()};
|
2012-08-13 10:37:49 -07:00
|
|
|
if(strcasecmp(str, "all") == 0)
|
|
|
|
capfilter = 0;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
const char *next = str;
|
|
|
|
do {
|
|
|
|
str = next;
|
|
|
|
while(isspace(str[0]))
|
|
|
|
str++;
|
2013-06-16 15:44:41 -07:00
|
|
|
next = strchr(str, ',');
|
|
|
|
|
2012-08-13 10:37:49 -07:00
|
|
|
if(!str[0] || str[0] == ',')
|
|
|
|
continue;
|
|
|
|
|
2019-01-08 19:42:44 +01:00
|
|
|
size_t len{next ? static_cast<size_t>(next-str) : strlen(str)};
|
2013-06-16 15:44:41 -07:00
|
|
|
while(len > 0 && isspace(str[len-1]))
|
|
|
|
len--;
|
|
|
|
if(len == 3 && strncasecmp(str, "sse", len) == 0)
|
2012-08-14 03:53:07 -07:00
|
|
|
capfilter &= ~CPU_CAP_SSE;
|
2013-06-16 15:44:41 -07:00
|
|
|
else if(len == 4 && strncasecmp(str, "sse2", len) == 0)
|
2013-05-22 16:59:20 -07:00
|
|
|
capfilter &= ~CPU_CAP_SSE2;
|
2015-10-11 06:38:00 -07:00
|
|
|
else if(len == 4 && strncasecmp(str, "sse3", len) == 0)
|
|
|
|
capfilter &= ~CPU_CAP_SSE3;
|
2014-06-04 02:57:13 -07:00
|
|
|
else if(len == 6 && strncasecmp(str, "sse4.1", len) == 0)
|
|
|
|
capfilter &= ~CPU_CAP_SSE4_1;
|
2013-06-16 15:44:41 -07:00
|
|
|
else if(len == 4 && strncasecmp(str, "neon", len) == 0)
|
2012-08-13 10:37:49 -07:00
|
|
|
capfilter &= ~CPU_CAP_NEON;
|
|
|
|
else
|
|
|
|
WARN("Invalid CPU extension \"%s\"\n", str);
|
|
|
|
} while(next++);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FillCPUCaps(capfilter);
|
|
|
|
|
2011-07-23 05:44:55 -07:00
|
|
|
#ifdef _WIN32
|
2019-06-30 12:00:10 -07:00
|
|
|
#define DEF_MIXER_PRIO 1
|
2011-07-23 05:44:55 -07:00
|
|
|
#else
|
2019-06-30 12:00:10 -07:00
|
|
|
#define DEF_MIXER_PRIO 0
|
2011-07-23 05:44:55 -07:00
|
|
|
#endif
|
2019-06-30 12:00:10 -07:00
|
|
|
RTPrioLevel = ConfigValueInt(nullptr, nullptr, "rt-prio").value_or(DEF_MIXER_PRIO);
|
|
|
|
#undef DEF_MIXER_PRIO
|
2009-12-01 23:15:09 -08:00
|
|
|
|
2017-08-07 01:38:26 -07:00
|
|
|
aluInit();
|
2015-09-27 20:55:39 -07:00
|
|
|
aluInitMixer();
|
2010-01-11 05:37:20 -08:00
|
|
|
|
2019-08-12 03:59:52 -07:00
|
|
|
auto traperr = al::getenv("ALSOFT_TRAP_ERROR");
|
|
|
|
if(traperr && (strcasecmp(traperr->c_str(), "true") == 0
|
|
|
|
|| strtol(traperr->c_str(), nullptr, 0) == 1))
|
2012-04-16 20:13:50 -07:00
|
|
|
{
|
2019-06-29 11:22:29 -07:00
|
|
|
TrapALError = true;
|
2018-11-14 06:17:47 -08:00
|
|
|
TrapALCError = true;
|
2012-04-16 20:13:50 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-12 03:59:52 -07:00
|
|
|
traperr = al::getenv("ALSOFT_TRAP_AL_ERROR");
|
|
|
|
if(traperr)
|
2019-08-12 17:10:04 -07:00
|
|
|
TrapALError = strcasecmp(traperr->c_str(), "true") == 0
|
|
|
|
|| strtol(traperr->c_str(), nullptr, 0) == 1;
|
|
|
|
else
|
|
|
|
TrapALError = !!GetConfigValueBool(nullptr, nullptr, "trap-al-error", false);
|
2011-09-10 01:23:59 -07:00
|
|
|
|
2019-08-12 03:59:52 -07:00
|
|
|
traperr = al::getenv("ALSOFT_TRAP_ALC_ERROR");
|
|
|
|
if(traperr)
|
2019-08-12 17:10:04 -07:00
|
|
|
TrapALCError = strcasecmp(traperr->c_str(), "true") == 0
|
|
|
|
|| strtol(traperr->c_str(), nullptr, 0) == 1;
|
|
|
|
else
|
|
|
|
TrapALCError = !!GetConfigValueBool(nullptr, nullptr, "trap-alc-error", false);
|
2012-04-16 20:13:50 -07:00
|
|
|
}
|
2011-09-10 01:12:34 -07:00
|
|
|
|
2019-06-30 16:38:25 -07:00
|
|
|
if(auto boostopt = ConfigValueFloat(nullptr, "reverb", "boost"))
|
|
|
|
{
|
|
|
|
const float valf{std::isfinite(*boostopt) ? clampf(*boostopt, -24.0f, 24.0f) : 0.0f};
|
2018-11-14 17:01:19 -08:00
|
|
|
ReverbBoost *= std::pow(10.0f, valf / 20.0f);
|
2019-06-30 16:38:25 -07:00
|
|
|
}
|
2011-09-18 16:16:55 -07:00
|
|
|
|
2019-08-12 03:59:52 -07:00
|
|
|
auto devopt = al::getenv("ALSOFT_DRIVERS");
|
|
|
|
if(devopt || (devopt=ConfigValueStr(nullptr, nullptr, "drivers")))
|
2009-09-12 17:49:08 -07:00
|
|
|
{
|
2019-04-11 02:49:13 -07:00
|
|
|
auto backendlist_cur = std::begin(BackendList);
|
2009-09-12 17:49:08 -07:00
|
|
|
|
2019-04-11 02:49:13 -07:00
|
|
|
bool endlist{true};
|
2019-06-30 16:15:15 -07:00
|
|
|
const char *next{devopt->c_str()};
|
2009-09-12 17:49:08 -07:00
|
|
|
do {
|
2019-06-30 16:15:15 -07:00
|
|
|
const char *devs{next};
|
2013-06-16 15:44:41 -07:00
|
|
|
while(isspace(devs[0]))
|
|
|
|
devs++;
|
2009-09-12 17:49:08 -07:00
|
|
|
next = strchr(devs, ',');
|
|
|
|
|
2019-04-11 02:49:13 -07:00
|
|
|
const bool delitem{devs[0] == '-'};
|
2010-06-05 19:33:06 -07:00
|
|
|
if(devs[0] == '-') devs++;
|
|
|
|
|
2009-09-12 17:49:08 -07:00
|
|
|
if(!devs[0] || devs[0] == ',')
|
2009-11-22 01:06:05 -08:00
|
|
|
{
|
2019-04-11 02:49:13 -07:00
|
|
|
endlist = false;
|
2009-09-12 17:49:08 -07:00
|
|
|
continue;
|
2009-11-22 01:06:05 -08:00
|
|
|
}
|
2019-04-11 02:49:13 -07:00
|
|
|
endlist = true;
|
2009-09-12 17:49:08 -07:00
|
|
|
|
2019-04-11 02:49:13 -07:00
|
|
|
size_t len{next ? (static_cast<size_t>(next-devs)) : strlen(devs)};
|
|
|
|
while(len > 0 && isspace(devs[len-1])) --len;
|
2018-03-09 18:56:24 -08:00
|
|
|
#ifdef HAVE_WASAPI
|
|
|
|
/* HACK: For backwards compatibility, convert backend references of
|
|
|
|
* mmdevapi to wasapi. This should eventually be removed.
|
|
|
|
*/
|
|
|
|
if(len == 8 && strncmp(devs, "mmdevapi", len) == 0)
|
|
|
|
{
|
|
|
|
devs = "wasapi";
|
|
|
|
len = 6;
|
|
|
|
}
|
|
|
|
#endif
|
2019-04-11 02:49:13 -07:00
|
|
|
|
|
|
|
auto find_backend = [devs,len](const BackendInfo &backend) -> bool
|
|
|
|
{ return len == strlen(backend.name) && strncmp(backend.name, devs, len) == 0; };
|
|
|
|
auto this_backend = std::find_if(std::begin(BackendList), BackendListEnd,
|
|
|
|
find_backend);
|
|
|
|
|
|
|
|
if(this_backend == BackendListEnd)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
if(delitem)
|
|
|
|
BackendListEnd = std::move(this_backend+1, BackendListEnd, this_backend);
|
|
|
|
else
|
|
|
|
backendlist_cur = std::rotate(backendlist_cur, this_backend, this_backend+1);
|
2009-09-12 17:49:08 -07:00
|
|
|
} while(next++);
|
|
|
|
|
2009-11-22 01:06:05 -08:00
|
|
|
if(endlist)
|
2019-04-11 02:49:13 -07:00
|
|
|
BackendListEnd = backendlist_cur;
|
2009-09-12 17:49:08 -07:00
|
|
|
}
|
|
|
|
|
2019-04-11 02:49:13 -07:00
|
|
|
auto init_backend = [](BackendInfo &backend) -> bool
|
2011-08-17 06:15:43 -07:00
|
|
|
{
|
2019-06-28 18:54:31 -07:00
|
|
|
if(PlaybackFactory && CaptureFactory)
|
2019-04-11 02:49:13 -07:00
|
|
|
return true;
|
2018-03-08 18:53:49 -08:00
|
|
|
|
2019-04-11 02:49:13 -07:00
|
|
|
BackendFactory &factory = backend.getFactory();
|
2018-11-15 19:15:14 -08:00
|
|
|
if(!factory.init())
|
2011-08-19 00:23:26 -07:00
|
|
|
{
|
2019-04-11 02:49:13 -07:00
|
|
|
WARN("Failed to initialize backend \"%s\"\n", backend.name);
|
|
|
|
return true;
|
2011-08-19 01:54:55 -07:00
|
|
|
}
|
|
|
|
|
2019-04-11 02:49:13 -07:00
|
|
|
TRACE("Initialized backend \"%s\"\n", backend.name);
|
2019-06-28 18:54:31 -07:00
|
|
|
if(!PlaybackFactory && factory.querySupport(BackendType::Playback))
|
2011-08-19 01:54:55 -07:00
|
|
|
{
|
2019-06-28 18:54:31 -07:00
|
|
|
PlaybackFactory = &factory;
|
|
|
|
TRACE("Added \"%s\" for playback\n", backend.name);
|
2011-08-19 00:23:26 -07:00
|
|
|
}
|
2019-06-28 18:54:31 -07:00
|
|
|
if(!CaptureFactory && factory.querySupport(BackendType::Capture))
|
2011-08-17 06:15:43 -07:00
|
|
|
{
|
2019-06-28 18:54:31 -07:00
|
|
|
CaptureFactory = &factory;
|
|
|
|
TRACE("Added \"%s\" for capture\n", backend.name);
|
2011-08-17 06:15:43 -07:00
|
|
|
}
|
2019-04-11 02:49:13 -07:00
|
|
|
return false;
|
|
|
|
};
|
|
|
|
BackendListEnd = std::remove_if(std::begin(BackendList), BackendListEnd, init_backend);
|
2018-03-08 18:53:49 -08:00
|
|
|
|
2018-11-15 19:42:13 -08:00
|
|
|
LoopbackBackendFactory::getFactory().init();
|
2009-09-12 17:49:08 -07:00
|
|
|
|
2019-06-28 18:54:31 -07:00
|
|
|
if(!PlaybackFactory)
|
2016-04-30 17:14:55 -07:00
|
|
|
WARN("No playback backend available!\n");
|
2019-06-28 18:54:31 -07:00
|
|
|
if(!CaptureFactory)
|
2016-04-30 17:14:55 -07:00
|
|
|
WARN("No capture backend available!\n");
|
|
|
|
|
2019-06-30 16:15:15 -07:00
|
|
|
if(auto exclopt = ConfigValueStr(nullptr, nullptr, "excludefx"))
|
2009-09-12 17:49:08 -07:00
|
|
|
{
|
2019-06-30 16:15:15 -07:00
|
|
|
const char *next{exclopt->c_str()};
|
2009-09-12 17:49:08 -07:00
|
|
|
do {
|
2019-08-12 03:59:52 -07:00
|
|
|
const char *str{next};
|
2009-09-12 17:49:08 -07:00
|
|
|
next = strchr(str, ',');
|
2009-08-26 23:45:00 -07:00
|
|
|
|
2009-09-12 17:49:08 -07:00
|
|
|
if(!str[0] || next == str)
|
|
|
|
continue;
|
|
|
|
|
2019-01-08 19:42:44 +01:00
|
|
|
size_t len{next ? static_cast<size_t>(next-str) : strlen(str)};
|
2019-05-26 21:28:51 -07:00
|
|
|
for(const EffectList &effectitem : gEffectList)
|
2009-09-12 17:49:08 -07:00
|
|
|
{
|
2019-05-26 21:28:51 -07:00
|
|
|
if(len == strlen(effectitem.name) &&
|
|
|
|
strncmp(effectitem.name, str, len) == 0)
|
|
|
|
DisabledEffects[effectitem.type] = AL_TRUE;
|
2009-09-12 17:49:08 -07:00
|
|
|
}
|
|
|
|
} while(next++);
|
|
|
|
}
|
2012-01-19 19:30:03 -08:00
|
|
|
|
2012-03-13 14:38:09 -07:00
|
|
|
InitEffect(&DefaultEffect);
|
2019-08-12 03:59:52 -07:00
|
|
|
auto defrevopt = al::getenv("ALSOFT_DEFAULT_REVERB");
|
|
|
|
if(defrevopt || (defrevopt=ConfigValueStr(nullptr, nullptr, "default-reverb")))
|
|
|
|
LoadReverbPreset(defrevopt->c_str(), &DefaultEffect);
|
2009-09-12 17:49:08 -07:00
|
|
|
}
|
2018-11-16 22:41:04 -08:00
|
|
|
#define DO_INITCONFIG() std::call_once(alc_config_once, [](){alc_initconfig();})
|
2009-09-12 17:49:08 -07:00
|
|
|
|
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/************************************************
|
|
|
|
* Device enumeration
|
|
|
|
************************************************/
|
2019-06-29 12:16:38 -07:00
|
|
|
void ProbeAllDevicesList()
|
2009-08-27 06:09:33 -07:00
|
|
|
{
|
2011-09-10 09:12:02 -07:00
|
|
|
DO_INITCONFIG();
|
|
|
|
|
2018-11-14 06:17:47 -08:00
|
|
|
std::lock_guard<std::recursive_mutex> _{ListLock};
|
2019-06-29 11:45:55 -07:00
|
|
|
alcAllDevicesList.clear();
|
|
|
|
if(PlaybackFactory)
|
|
|
|
PlaybackFactory->probe(DevProbe::Playback, &alcAllDevicesList);
|
|
|
|
}
|
2019-06-29 12:16:38 -07:00
|
|
|
void ProbeCaptureDeviceList()
|
2019-06-29 11:45:55 -07:00
|
|
|
{
|
|
|
|
DO_INITCONFIG();
|
|
|
|
|
|
|
|
std::lock_guard<std::recursive_mutex> _{ListLock};
|
|
|
|
alcCaptureDeviceList.clear();
|
|
|
|
if(CaptureFactory)
|
|
|
|
CaptureFactory->probe(DevProbe::Capture, &alcCaptureDeviceList);
|
2009-08-27 06:09:33 -07:00
|
|
|
}
|
|
|
|
|
2019-06-29 12:16:38 -07:00
|
|
|
} // namespace
|
|
|
|
|
|
|
|
/* Mixing thread piority level */
|
|
|
|
ALint RTPrioLevel;
|
|
|
|
|
|
|
|
FILE *gLogFile{stderr};
|
|
|
|
#ifdef _DEBUG
|
|
|
|
LogLevel gLogLevel{LogWarning};
|
|
|
|
#else
|
|
|
|
LogLevel gLogLevel{LogError};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/************************************************
|
|
|
|
* Library initialization
|
|
|
|
************************************************/
|
|
|
|
#if defined(_WIN32) && !defined(AL_LIBTYPE_STATIC)
|
|
|
|
BOOL APIENTRY DllMain(HINSTANCE module, DWORD reason, LPVOID /*reserved*/)
|
|
|
|
{
|
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
|
|
|
/* Pin the DLL so we won't get unloaded until the process terminates */
|
|
|
|
GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_PIN | GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS,
|
|
|
|
(WCHAR*)module, &module);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
#endif
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/************************************************
|
|
|
|
* Device format information
|
|
|
|
************************************************/
|
2018-12-19 03:13:15 -08:00
|
|
|
const ALCchar *DevFmtTypeString(DevFmtType type) noexcept
|
2011-05-15 04:03:15 -07:00
|
|
|
{
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case DevFmtByte: return "Signed Byte";
|
|
|
|
case DevFmtUByte: return "Unsigned Byte";
|
|
|
|
case DevFmtShort: return "Signed Short";
|
|
|
|
case DevFmtUShort: return "Unsigned Short";
|
2012-02-14 11:44:57 -08:00
|
|
|
case DevFmtInt: return "Signed Int";
|
|
|
|
case DevFmtUInt: return "Unsigned Int";
|
2011-05-15 04:03:15 -07:00
|
|
|
case DevFmtFloat: return "Float";
|
|
|
|
}
|
|
|
|
return "(unknown type)";
|
|
|
|
}
|
2018-12-19 03:13:15 -08:00
|
|
|
const ALCchar *DevFmtChannelsString(DevFmtChannels chans) noexcept
|
2011-05-15 04:03:15 -07:00
|
|
|
{
|
|
|
|
switch(chans)
|
|
|
|
{
|
|
|
|
case DevFmtMono: return "Mono";
|
|
|
|
case DevFmtStereo: return "Stereo";
|
2011-05-24 14:34:53 -07:00
|
|
|
case DevFmtQuad: return "Quadraphonic";
|
2011-05-15 04:03:15 -07:00
|
|
|
case DevFmtX51: return "5.1 Surround";
|
2014-11-07 00:54:16 -08:00
|
|
|
case DevFmtX51Rear: return "5.1 Surround (Rear)";
|
2011-05-15 04:03:15 -07:00
|
|
|
case DevFmtX61: return "6.1 Surround";
|
|
|
|
case DevFmtX71: return "7.1 Surround";
|
2017-04-12 18:26:07 -07:00
|
|
|
case DevFmtAmbi3D: return "Ambisonic 3D";
|
2011-05-15 04:03:15 -07:00
|
|
|
}
|
|
|
|
return "(unknown channels)";
|
|
|
|
}
|
|
|
|
|
2018-12-19 03:13:15 -08:00
|
|
|
ALsizei BytesFromDevFmt(DevFmtType type) noexcept
|
2010-12-04 19:50:00 -08:00
|
|
|
{
|
|
|
|
switch(type)
|
|
|
|
{
|
|
|
|
case DevFmtByte: return sizeof(ALbyte);
|
|
|
|
case DevFmtUByte: return sizeof(ALubyte);
|
|
|
|
case DevFmtShort: return sizeof(ALshort);
|
|
|
|
case DevFmtUShort: return sizeof(ALushort);
|
2012-02-14 11:44:57 -08:00
|
|
|
case DevFmtInt: return sizeof(ALint);
|
|
|
|
case DevFmtUInt: return sizeof(ALuint);
|
2010-12-04 19:50:00 -08:00
|
|
|
case DevFmtFloat: return sizeof(ALfloat);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2018-12-19 03:13:15 -08:00
|
|
|
ALsizei ChannelsFromDevFmt(DevFmtChannels chans, ALsizei ambiorder) noexcept
|
2010-12-04 19:50:00 -08:00
|
|
|
{
|
|
|
|
switch(chans)
|
|
|
|
{
|
|
|
|
case DevFmtMono: return 1;
|
|
|
|
case DevFmtStereo: return 2;
|
|
|
|
case DevFmtQuad: return 4;
|
|
|
|
case DevFmtX51: return 6;
|
2014-11-07 00:54:16 -08:00
|
|
|
case DevFmtX51Rear: return 6;
|
2010-12-04 19:50:00 -08:00
|
|
|
case DevFmtX61: return 7;
|
|
|
|
case DevFmtX71: return 8;
|
2018-12-19 03:13:15 -08:00
|
|
|
case DevFmtAmbi3D: return (ambiorder+1) * (ambiorder+1);
|
2010-12-04 19:50:00 -08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2012-04-20 01:18:38 -07:00
|
|
|
|
2019-06-30 16:57:10 -07:00
|
|
|
struct DevFmtPair { DevFmtChannels chans; DevFmtType type; };
|
|
|
|
static al::optional<DevFmtPair> DecomposeDevFormat(ALenum format)
|
2010-12-04 19:50:00 -08:00
|
|
|
{
|
2011-09-18 19:06:19 -07:00
|
|
|
static const struct {
|
|
|
|
ALenum format;
|
2018-12-24 19:29:01 -08:00
|
|
|
DevFmtChannels channels;
|
|
|
|
DevFmtType type;
|
2011-09-18 19:06:19 -07:00
|
|
|
} list[] = {
|
|
|
|
{ AL_FORMAT_MONO8, DevFmtMono, DevFmtUByte },
|
|
|
|
{ AL_FORMAT_MONO16, DevFmtMono, DevFmtShort },
|
|
|
|
{ AL_FORMAT_MONO_FLOAT32, DevFmtMono, DevFmtFloat },
|
|
|
|
|
|
|
|
{ AL_FORMAT_STEREO8, DevFmtStereo, DevFmtUByte },
|
|
|
|
{ AL_FORMAT_STEREO16, DevFmtStereo, DevFmtShort },
|
|
|
|
{ AL_FORMAT_STEREO_FLOAT32, DevFmtStereo, DevFmtFloat },
|
|
|
|
|
|
|
|
{ AL_FORMAT_QUAD8, DevFmtQuad, DevFmtUByte },
|
|
|
|
{ AL_FORMAT_QUAD16, DevFmtQuad, DevFmtShort },
|
|
|
|
{ AL_FORMAT_QUAD32, DevFmtQuad, DevFmtFloat },
|
|
|
|
|
|
|
|
{ AL_FORMAT_51CHN8, DevFmtX51, DevFmtUByte },
|
|
|
|
{ AL_FORMAT_51CHN16, DevFmtX51, DevFmtShort },
|
|
|
|
{ AL_FORMAT_51CHN32, DevFmtX51, DevFmtFloat },
|
|
|
|
|
|
|
|
{ AL_FORMAT_61CHN8, DevFmtX61, DevFmtUByte },
|
|
|
|
{ AL_FORMAT_61CHN16, DevFmtX61, DevFmtShort },
|
|
|
|
{ AL_FORMAT_61CHN32, DevFmtX61, DevFmtFloat },
|
|
|
|
|
|
|
|
{ AL_FORMAT_71CHN8, DevFmtX71, DevFmtUByte },
|
|
|
|
{ AL_FORMAT_71CHN16, DevFmtX71, DevFmtShort },
|
|
|
|
{ AL_FORMAT_71CHN32, DevFmtX71, DevFmtFloat },
|
|
|
|
};
|
|
|
|
|
2019-05-26 21:28:51 -07:00
|
|
|
for(const auto &item : list)
|
2010-12-04 19:50:00 -08:00
|
|
|
{
|
2019-05-26 21:28:51 -07:00
|
|
|
if(item.format == format)
|
2019-07-01 17:25:58 -07:00
|
|
|
return al::make_optional(DevFmtPair{item.channels, item.type});
|
2010-12-04 19:50:00 -08:00
|
|
|
}
|
2011-09-18 19:06:19 -07:00
|
|
|
|
2019-06-30 16:57:10 -07:00
|
|
|
return al::nullopt;
|
2010-12-04 19:50:00 -08:00
|
|
|
}
|
|
|
|
|
2016-09-06 09:09:25 -07:00
|
|
|
static ALCboolean IsValidALCType(ALCenum type)
|
2011-07-02 02:51:33 -07:00
|
|
|
{
|
|
|
|
switch(type)
|
|
|
|
{
|
2011-11-01 16:00:47 -07:00
|
|
|
case ALC_BYTE_SOFT:
|
|
|
|
case ALC_UNSIGNED_BYTE_SOFT:
|
|
|
|
case ALC_SHORT_SOFT:
|
|
|
|
case ALC_UNSIGNED_SHORT_SOFT:
|
|
|
|
case ALC_INT_SOFT:
|
|
|
|
case ALC_UNSIGNED_INT_SOFT:
|
|
|
|
case ALC_FLOAT_SOFT:
|
2011-07-02 02:51:33 -07:00
|
|
|
return ALC_TRUE;
|
|
|
|
}
|
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-09-06 09:09:25 -07:00
|
|
|
static ALCboolean IsValidALCChannels(ALCenum channels)
|
2011-07-02 02:51:33 -07:00
|
|
|
{
|
|
|
|
switch(channels)
|
|
|
|
{
|
2011-11-01 16:00:47 -07:00
|
|
|
case ALC_MONO_SOFT:
|
|
|
|
case ALC_STEREO_SOFT:
|
|
|
|
case ALC_QUAD_SOFT:
|
|
|
|
case ALC_5POINT1_SOFT:
|
|
|
|
case ALC_6POINT1_SOFT:
|
|
|
|
case ALC_7POINT1_SOFT:
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
case ALC_BFORMAT3D_SOFT:
|
2011-07-02 02:51:33 -07:00
|
|
|
return ALC_TRUE;
|
|
|
|
}
|
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
|
|
|
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
static ALCboolean IsValidAmbiLayout(ALCenum layout)
|
|
|
|
{
|
|
|
|
switch(layout)
|
|
|
|
{
|
|
|
|
case ALC_ACN_SOFT:
|
|
|
|
case ALC_FUMA_SOFT:
|
|
|
|
return ALC_TRUE;
|
|
|
|
}
|
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ALCboolean IsValidAmbiScaling(ALCenum scaling)
|
|
|
|
{
|
|
|
|
switch(scaling)
|
|
|
|
{
|
|
|
|
case ALC_N3D_SOFT:
|
|
|
|
case ALC_SN3D_SOFT:
|
|
|
|
case ALC_FUMA_SOFT:
|
|
|
|
return ALC_TRUE;
|
|
|
|
}
|
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/************************************************
|
|
|
|
* Miscellaneous ALC helpers
|
|
|
|
************************************************/
|
2015-09-05 01:32:12 -07:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/* SetDefaultWFXChannelOrder
|
|
|
|
*
|
|
|
|
* Sets the default channel order used by WaveFormatEx.
|
|
|
|
*/
|
|
|
|
void SetDefaultWFXChannelOrder(ALCdevice *device)
|
|
|
|
{
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex.fill(-1);
|
2012-11-04 04:41:11 -08:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
switch(device->FmtChans)
|
|
|
|
{
|
2014-11-07 00:54:16 -08:00
|
|
|
case DevFmtMono:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[FrontCenter] = 0;
|
2014-11-07 00:54:16 -08:00
|
|
|
break;
|
|
|
|
case DevFmtStereo:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[FrontLeft] = 0;
|
|
|
|
device->RealOut.ChannelIndex[FrontRight] = 1;
|
2014-11-07 00:54:16 -08:00
|
|
|
break;
|
|
|
|
case DevFmtQuad:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[FrontLeft] = 0;
|
|
|
|
device->RealOut.ChannelIndex[FrontRight] = 1;
|
|
|
|
device->RealOut.ChannelIndex[BackLeft] = 2;
|
|
|
|
device->RealOut.ChannelIndex[BackRight] = 3;
|
2014-11-07 00:54:16 -08:00
|
|
|
break;
|
|
|
|
case DevFmtX51:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[FrontLeft] = 0;
|
|
|
|
device->RealOut.ChannelIndex[FrontRight] = 1;
|
|
|
|
device->RealOut.ChannelIndex[FrontCenter] = 2;
|
|
|
|
device->RealOut.ChannelIndex[LFE] = 3;
|
|
|
|
device->RealOut.ChannelIndex[SideLeft] = 4;
|
|
|
|
device->RealOut.ChannelIndex[SideRight] = 5;
|
2014-11-07 00:54:16 -08:00
|
|
|
break;
|
|
|
|
case DevFmtX51Rear:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[FrontLeft] = 0;
|
|
|
|
device->RealOut.ChannelIndex[FrontRight] = 1;
|
|
|
|
device->RealOut.ChannelIndex[FrontCenter] = 2;
|
|
|
|
device->RealOut.ChannelIndex[LFE] = 3;
|
|
|
|
device->RealOut.ChannelIndex[BackLeft] = 4;
|
|
|
|
device->RealOut.ChannelIndex[BackRight] = 5;
|
2014-11-07 00:54:16 -08:00
|
|
|
break;
|
|
|
|
case DevFmtX61:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[FrontLeft] = 0;
|
|
|
|
device->RealOut.ChannelIndex[FrontRight] = 1;
|
|
|
|
device->RealOut.ChannelIndex[FrontCenter] = 2;
|
|
|
|
device->RealOut.ChannelIndex[LFE] = 3;
|
|
|
|
device->RealOut.ChannelIndex[BackCenter] = 4;
|
|
|
|
device->RealOut.ChannelIndex[SideLeft] = 5;
|
|
|
|
device->RealOut.ChannelIndex[SideRight] = 6;
|
2014-11-07 00:54:16 -08:00
|
|
|
break;
|
|
|
|
case DevFmtX71:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[FrontLeft] = 0;
|
|
|
|
device->RealOut.ChannelIndex[FrontRight] = 1;
|
|
|
|
device->RealOut.ChannelIndex[FrontCenter] = 2;
|
|
|
|
device->RealOut.ChannelIndex[LFE] = 3;
|
|
|
|
device->RealOut.ChannelIndex[BackLeft] = 4;
|
|
|
|
device->RealOut.ChannelIndex[BackRight] = 5;
|
|
|
|
device->RealOut.ChannelIndex[SideLeft] = 6;
|
|
|
|
device->RealOut.ChannelIndex[SideRight] = 7;
|
2014-11-07 00:54:16 -08:00
|
|
|
break;
|
2017-04-12 18:26:07 -07:00
|
|
|
case DevFmtAmbi3D:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[Aux0] = 0;
|
2018-11-18 08:01:50 -08:00
|
|
|
if(device->mAmbiOrder > 0)
|
2017-04-12 18:26:07 -07:00
|
|
|
{
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[Aux1] = 1;
|
|
|
|
device->RealOut.ChannelIndex[Aux2] = 2;
|
|
|
|
device->RealOut.ChannelIndex[Aux3] = 3;
|
2017-04-12 18:26:07 -07:00
|
|
|
}
|
2018-11-18 08:01:50 -08:00
|
|
|
if(device->mAmbiOrder > 1)
|
2017-04-12 18:26:07 -07:00
|
|
|
{
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[Aux4] = 4;
|
|
|
|
device->RealOut.ChannelIndex[Aux5] = 5;
|
|
|
|
device->RealOut.ChannelIndex[Aux6] = 6;
|
|
|
|
device->RealOut.ChannelIndex[Aux7] = 7;
|
|
|
|
device->RealOut.ChannelIndex[Aux8] = 8;
|
2017-04-12 18:26:07 -07:00
|
|
|
}
|
2018-11-18 08:01:50 -08:00
|
|
|
if(device->mAmbiOrder > 2)
|
2017-04-12 18:26:07 -07:00
|
|
|
{
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[Aux9] = 9;
|
|
|
|
device->RealOut.ChannelIndex[Aux10] = 10;
|
|
|
|
device->RealOut.ChannelIndex[Aux11] = 11;
|
|
|
|
device->RealOut.ChannelIndex[Aux12] = 12;
|
|
|
|
device->RealOut.ChannelIndex[Aux13] = 13;
|
|
|
|
device->RealOut.ChannelIndex[Aux14] = 14;
|
|
|
|
device->RealOut.ChannelIndex[Aux15] = 15;
|
2017-04-12 18:26:07 -07:00
|
|
|
}
|
2016-07-29 21:55:43 -07:00
|
|
|
break;
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* SetDefaultChannelOrder
|
|
|
|
*
|
|
|
|
* Sets the default channel order used by most non-WaveFormatEx-based APIs.
|
|
|
|
*/
|
|
|
|
void SetDefaultChannelOrder(ALCdevice *device)
|
|
|
|
{
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex.fill(-1);
|
2012-11-04 04:41:11 -08:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
switch(device->FmtChans)
|
|
|
|
{
|
2014-11-07 00:54:16 -08:00
|
|
|
case DevFmtX51Rear:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[FrontLeft] = 0;
|
|
|
|
device->RealOut.ChannelIndex[FrontRight] = 1;
|
|
|
|
device->RealOut.ChannelIndex[BackLeft] = 2;
|
|
|
|
device->RealOut.ChannelIndex[BackRight] = 3;
|
|
|
|
device->RealOut.ChannelIndex[FrontCenter] = 4;
|
|
|
|
device->RealOut.ChannelIndex[LFE] = 5;
|
2014-11-07 00:54:16 -08:00
|
|
|
return;
|
|
|
|
case DevFmtX71:
|
2019-04-02 15:53:27 -07:00
|
|
|
device->RealOut.ChannelIndex[FrontLeft] = 0;
|
|
|
|
device->RealOut.ChannelIndex[FrontRight] = 1;
|
|
|
|
device->RealOut.ChannelIndex[BackLeft] = 2;
|
|
|
|
device->RealOut.ChannelIndex[BackRight] = 3;
|
|
|
|
device->RealOut.ChannelIndex[FrontCenter] = 4;
|
|
|
|
device->RealOut.ChannelIndex[LFE] = 5;
|
|
|
|
device->RealOut.ChannelIndex[SideLeft] = 6;
|
|
|
|
device->RealOut.ChannelIndex[SideRight] = 7;
|
2014-11-07 00:54:16 -08:00
|
|
|
return;
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
/* Same as WFX order */
|
|
|
|
case DevFmtMono:
|
|
|
|
case DevFmtStereo:
|
|
|
|
case DevFmtQuad:
|
2014-11-07 00:54:16 -08:00
|
|
|
case DevFmtX51:
|
2012-04-20 01:18:38 -07:00
|
|
|
case DevFmtX61:
|
2017-04-12 18:26:07 -07:00
|
|
|
case DevFmtAmbi3D:
|
2014-09-10 16:52:54 -07:00
|
|
|
SetDefaultWFXChannelOrder(device);
|
2012-04-20 01:18:38 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-30 14:13:05 -07:00
|
|
|
void ALCcontext::processUpdates()
|
2014-10-12 09:03:08 -07:00
|
|
|
{
|
2019-07-30 14:13:05 -07:00
|
|
|
std::lock_guard<std::mutex> _{mPropLock};
|
|
|
|
if(mDeferUpdates.exchange(false))
|
2014-10-12 09:03:08 -07:00
|
|
|
{
|
2016-08-23 19:37:26 -07:00
|
|
|
/* Tell the mixer to stop applying updates, then wait for any active
|
|
|
|
* updating to finish, before providing updates.
|
|
|
|
*/
|
2019-07-30 14:13:05 -07:00
|
|
|
mHoldUpdates.store(true, std::memory_order_release);
|
|
|
|
while((mUpdateCount.load(std::memory_order_acquire)&1) != 0)
|
2018-11-26 23:06:49 -08:00
|
|
|
std::this_thread::yield();
|
2016-08-23 19:37:26 -07:00
|
|
|
|
2019-07-30 14:13:05 -07:00
|
|
|
if(!mPropsClean.test_and_set(std::memory_order_acq_rel))
|
|
|
|
UpdateContextProps(this);
|
|
|
|
if(!mListener.PropsClean.test_and_set(std::memory_order_acq_rel))
|
|
|
|
UpdateListenerProps(this);
|
|
|
|
UpdateAllEffectSlotProps(this);
|
|
|
|
UpdateAllSourceProps(this);
|
2016-08-23 19:37:26 -07:00
|
|
|
|
|
|
|
/* Now with all updates declared, let the mixer continue applying them
|
|
|
|
* so they all happen at once.
|
|
|
|
*/
|
2019-07-30 14:13:05 -07:00
|
|
|
mHoldUpdates.store(false, std::memory_order_release);
|
2014-10-12 09:03:08 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-09-14 11:58:51 -07:00
|
|
|
/* alcSetError
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Stores the latest ALC device error
|
2011-09-14 11:58:51 -07:00
|
|
|
*/
|
|
|
|
static void alcSetError(ALCdevice *device, ALCenum errorCode)
|
|
|
|
{
|
2017-02-27 20:56:34 -08:00
|
|
|
WARN("Error generated on device %p, code 0x%04x\n", device, errorCode);
|
2011-09-14 11:58:51 -07:00
|
|
|
if(TrapALCError)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
/* DebugBreak() will cause an exception if there is no debugger */
|
|
|
|
if(IsDebuggerPresent())
|
|
|
|
DebugBreak();
|
|
|
|
#elif defined(SIGTRAP)
|
2011-09-30 20:46:18 -07:00
|
|
|
raise(SIGTRAP);
|
2011-09-14 11:58:51 -07:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
if(device)
|
2018-11-21 07:52:17 -08:00
|
|
|
device->LastError.store(errorCode);
|
2011-09-14 11:58:51 -07:00
|
|
|
else
|
2018-11-14 06:17:47 -08:00
|
|
|
LastNullDeviceError.store(errorCode);
|
2011-09-14 11:58:51 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2018-12-24 09:17:00 -08:00
|
|
|
static std::unique_ptr<Compressor> CreateDeviceLimiter(const ALCdevice *device, const ALfloat threshold)
|
2017-05-27 03:36:34 -07:00
|
|
|
{
|
2019-07-03 23:26:33 -07:00
|
|
|
return CompressorInit(static_cast<ALuint>(device->RealOut.Buffer.size()), device->Frequency,
|
|
|
|
AL_TRUE, AL_TRUE, AL_TRUE, AL_TRUE, AL_TRUE, 0.001f, 0.002f, 0.0f, 0.0f, threshold,
|
|
|
|
INFINITY, 0.0f, 0.020f, 0.200f);
|
2017-05-27 03:36:34 -07:00
|
|
|
}
|
|
|
|
|
2014-02-01 16:37:11 -08:00
|
|
|
/* UpdateClockBase
|
|
|
|
*
|
|
|
|
* Updates the device's base clock time with however many samples have been
|
|
|
|
* done. This is used so frequency changes on the device don't cause the time
|
2017-02-28 23:18:51 -08:00
|
|
|
* to jump forward or back. Must not be called while the device is running/
|
|
|
|
* mixing.
|
2014-02-01 16:37:11 -08:00
|
|
|
*/
|
|
|
|
static inline void UpdateClockBase(ALCdevice *device)
|
|
|
|
{
|
2019-08-01 13:28:53 -07:00
|
|
|
IncrementRef(device->MixCount);
|
2019-03-26 10:18:02 -07:00
|
|
|
device->ClockBase += nanoseconds{seconds{device->SamplesDone}} / device->Frequency;
|
2014-02-01 16:37:11 -08:00
|
|
|
device->SamplesDone = 0;
|
2019-08-01 13:28:53 -07:00
|
|
|
IncrementRef(device->MixCount);
|
2014-02-01 16:37:11 -08:00
|
|
|
}
|
|
|
|
|
2011-09-10 09:00:01 -07:00
|
|
|
/* UpdateDeviceParams
|
2010-08-09 00:28:48 -07:00
|
|
|
*
|
2011-09-10 09:00:01 -07:00
|
|
|
* Updates device parameters according to the attribute list (caller is
|
|
|
|
* responsible for holding the list lock).
|
2010-08-09 00:28:48 -07:00
|
|
|
*/
|
2012-01-25 20:00:34 -08:00
|
|
|
static ALCenum UpdateDeviceParams(ALCdevice *device, const ALCint *attrList)
|
2010-08-09 00:28:48 -07:00
|
|
|
{
|
2018-12-24 19:29:01 -08:00
|
|
|
HrtfRequestMode hrtf_userreq = Hrtf_Default;
|
|
|
|
HrtfRequestMode hrtf_appreq = Hrtf_Default;
|
2018-10-03 13:48:04 -07:00
|
|
|
ALCenum gainLimiter = device->LimiterState;
|
2017-02-21 16:31:59 -08:00
|
|
|
const ALsizei old_sends = device->NumAuxSends;
|
|
|
|
ALsizei new_sends = device->NumAuxSends;
|
2018-12-24 19:29:01 -08:00
|
|
|
DevFmtChannels oldChans;
|
|
|
|
DevFmtType oldType;
|
2017-02-21 16:31:59 -08:00
|
|
|
ALboolean update_failed;
|
|
|
|
ALCsizei hrtf_id = -1;
|
2012-01-20 12:20:24 -08:00
|
|
|
ALCuint oldFreq;
|
2010-08-09 00:28:48 -07:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
if((!attrList || !attrList[0]) && device->Type == Loopback)
|
|
|
|
{
|
|
|
|
WARN("Missing attributes for loopback device\n");
|
|
|
|
return ALC_INVALID_VALUE;
|
|
|
|
}
|
|
|
|
|
2010-08-12 17:24:55 -07:00
|
|
|
// Check for attributes
|
2018-12-18 09:27:00 -08:00
|
|
|
if(attrList && attrList[0])
|
2010-08-09 00:28:48 -07:00
|
|
|
{
|
2019-07-06 13:20:21 -07:00
|
|
|
ALCenum alayout{AL_NONE};
|
|
|
|
ALCenum ascale{AL_NONE};
|
|
|
|
ALCenum schans{AL_NONE};
|
|
|
|
ALCenum stype{AL_NONE};
|
|
|
|
ALCsizei attrIdx{0};
|
|
|
|
ALCsizei aorder{0};
|
|
|
|
ALCuint freq{0u};
|
2010-08-09 00:28:48 -07:00
|
|
|
|
2019-07-06 00:19:48 -07:00
|
|
|
ALuint numMono{device->NumMonoSources};
|
|
|
|
ALuint numStereo{device->NumStereoSources};
|
|
|
|
ALsizei numSends{old_sends};
|
2010-08-12 17:24:55 -07:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
#define TRACE_ATTR(a, v) TRACE("%s = %d\n", #a, v)
|
2010-08-12 17:24:55 -07:00
|
|
|
while(attrList[attrIdx])
|
2010-08-09 00:28:48 -07:00
|
|
|
{
|
2017-04-16 16:21:11 -07:00
|
|
|
switch(attrList[attrIdx])
|
2010-08-12 17:24:55 -07:00
|
|
|
{
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_FORMAT_CHANNELS_SOFT:
|
|
|
|
schans = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_FORMAT_CHANNELS_SOFT, schans);
|
|
|
|
break;
|
2011-03-11 00:13:44 -08:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_FORMAT_TYPE_SOFT:
|
|
|
|
stype = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_FORMAT_TYPE_SOFT, stype);
|
|
|
|
break;
|
2011-03-11 00:13:44 -08:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_FREQUENCY:
|
|
|
|
freq = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_FREQUENCY, freq);
|
|
|
|
break;
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_AMBISONIC_LAYOUT_SOFT:
|
|
|
|
alayout = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_AMBISONIC_LAYOUT_SOFT, alayout);
|
|
|
|
break;
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_AMBISONIC_SCALING_SOFT:
|
|
|
|
ascale = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_AMBISONIC_SCALING_SOFT, ascale);
|
|
|
|
break;
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_AMBISONIC_ORDER_SOFT:
|
|
|
|
aorder = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_AMBISONIC_ORDER_SOFT, aorder);
|
|
|
|
break;
|
2010-08-09 00:28:48 -07:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_MONO_SOURCES:
|
|
|
|
numMono = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_MONO_SOURCES, numMono);
|
2019-07-06 00:19:48 -07:00
|
|
|
if(numMono > INT_MAX) numMono = 0;
|
2018-12-18 09:27:00 -08:00
|
|
|
break;
|
2017-04-14 22:56:54 -07:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_STEREO_SOURCES:
|
|
|
|
numStereo = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_STEREO_SOURCES, numStereo);
|
2019-07-06 00:19:48 -07:00
|
|
|
if(numStereo > INT_MAX) numStereo = 0;
|
2018-12-18 09:27:00 -08:00
|
|
|
break;
|
2010-08-12 17:24:55 -07:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_MAX_AUXILIARY_SENDS:
|
|
|
|
numSends = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_MAX_AUXILIARY_SENDS, numSends);
|
|
|
|
numSends = clampi(numSends, 0, MAX_SENDS);
|
|
|
|
break;
|
2010-08-12 17:24:55 -07:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_HRTF_SOFT:
|
|
|
|
TRACE_ATTR(ALC_HRTF_SOFT, attrList[attrIdx + 1]);
|
|
|
|
if(attrList[attrIdx + 1] == ALC_FALSE)
|
|
|
|
hrtf_appreq = Hrtf_Disable;
|
|
|
|
else if(attrList[attrIdx + 1] == ALC_TRUE)
|
|
|
|
hrtf_appreq = Hrtf_Enable;
|
|
|
|
else
|
|
|
|
hrtf_appreq = Hrtf_Default;
|
|
|
|
break;
|
2013-05-31 19:29:32 -07:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_HRTF_ID_SOFT:
|
|
|
|
hrtf_id = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_HRTF_ID_SOFT, hrtf_id);
|
|
|
|
break;
|
2017-04-16 16:21:11 -07:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
case ALC_OUTPUT_LIMITER_SOFT:
|
|
|
|
gainLimiter = attrList[attrIdx + 1];
|
|
|
|
TRACE_ATTR(ALC_OUTPUT_LIMITER_SOFT, gainLimiter);
|
|
|
|
break;
|
2017-04-30 04:21:48 -07:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
default:
|
|
|
|
TRACE("0x%04X = %d (0x%x)\n", attrList[attrIdx],
|
|
|
|
attrList[attrIdx + 1], attrList[attrIdx + 1]);
|
|
|
|
break;
|
2016-04-17 17:22:03 -07:00
|
|
|
}
|
2015-10-07 03:29:53 -07:00
|
|
|
|
2010-08-12 17:24:55 -07:00
|
|
|
attrIdx += 2;
|
2010-08-09 00:28:48 -07:00
|
|
|
}
|
2016-04-17 17:22:03 -07:00
|
|
|
#undef TRACE_ATTR
|
2010-08-09 00:28:48 -07:00
|
|
|
|
2019-07-06 13:20:21 -07:00
|
|
|
const bool loopback{device->Type == Loopback};
|
2018-12-18 09:27:00 -08:00
|
|
|
if(loopback)
|
2012-01-25 19:54:55 -08:00
|
|
|
{
|
2018-12-18 09:27:00 -08:00
|
|
|
if(!schans || !stype || !freq)
|
|
|
|
{
|
|
|
|
WARN("Missing format for loopback device\n");
|
|
|
|
return ALC_INVALID_VALUE;
|
|
|
|
}
|
|
|
|
if(!IsValidALCChannels(schans) || !IsValidALCType(stype) || freq < MIN_OUTPUT_RATE)
|
|
|
|
return ALC_INVALID_VALUE;
|
2018-12-24 07:33:38 -08:00
|
|
|
if(schans == ALC_BFORMAT3D_SOFT)
|
|
|
|
{
|
|
|
|
if(!alayout || !ascale || !aorder)
|
|
|
|
{
|
|
|
|
WARN("Missing ambisonic info for loopback device\n");
|
|
|
|
return ALC_INVALID_VALUE;
|
|
|
|
}
|
|
|
|
if(!IsValidAmbiLayout(alayout) || !IsValidAmbiScaling(ascale))
|
|
|
|
return ALC_INVALID_VALUE;
|
|
|
|
if(aorder < 1 || aorder > MAX_AMBI_ORDER)
|
|
|
|
return ALC_INVALID_VALUE;
|
|
|
|
if((alayout == ALC_FUMA_SOFT || ascale == ALC_FUMA_SOFT) && aorder > 3)
|
|
|
|
return ALC_INVALID_VALUE;
|
|
|
|
}
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
}
|
2012-02-25 18:03:33 -08:00
|
|
|
|
2019-07-06 13:20:21 -07:00
|
|
|
/* If a context is already running on the device, stop playback so the
|
|
|
|
* device attributes can be updated.
|
|
|
|
*/
|
2019-06-09 02:20:30 -07:00
|
|
|
if(device->Flags.get<DeviceRunning>())
|
2018-12-28 22:56:20 -08:00
|
|
|
device->Backend->stop();
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.unset<DeviceRunning>();
|
2012-02-25 18:03:33 -08:00
|
|
|
|
2014-08-29 19:34:20 -07:00
|
|
|
UpdateClockBase(device);
|
|
|
|
|
2019-07-06 13:20:21 -07:00
|
|
|
const char *devname{nullptr};
|
2018-12-18 09:27:00 -08:00
|
|
|
if(!loopback)
|
2017-04-14 22:56:54 -07:00
|
|
|
{
|
2019-07-06 13:20:21 -07:00
|
|
|
devname = device->DeviceName.c_str();
|
|
|
|
|
2019-04-26 15:58:25 -07:00
|
|
|
device->BufferSize = DEFAULT_UPDATE_SIZE * DEFAULT_NUM_UPDATES;
|
2018-12-18 09:27:00 -08:00
|
|
|
device->UpdateSize = DEFAULT_UPDATE_SIZE;
|
|
|
|
device->Frequency = DEFAULT_OUTPUT_RATE;
|
2017-02-21 16:31:59 -08:00
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
freq = ConfigValueUInt(devname, nullptr, "frequency").value_or(freq);
|
2018-12-18 09:27:00 -08:00
|
|
|
if(freq < 1)
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.unset<FrequencyRequest>();
|
2018-12-18 09:27:00 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
freq = maxi(freq, MIN_OUTPUT_RATE);
|
2012-02-25 18:03:33 -08:00
|
|
|
|
2019-04-26 18:04:22 -07:00
|
|
|
device->UpdateSize = (device->UpdateSize*freq + device->Frequency/2) /
|
|
|
|
device->Frequency;
|
2019-04-26 15:58:25 -07:00
|
|
|
device->BufferSize = (device->BufferSize*freq + device->Frequency/2) /
|
|
|
|
device->Frequency;
|
2012-02-25 18:03:33 -08:00
|
|
|
|
2018-12-18 09:27:00 -08:00
|
|
|
device->Frequency = freq;
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.set<FrequencyRequest>();
|
2018-12-18 09:27:00 -08:00
|
|
|
}
|
2017-02-21 16:31:59 -08:00
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
if(auto persizeopt = ConfigValueUInt(devname, nullptr, "period_size"))
|
|
|
|
device->UpdateSize = clampu(*persizeopt, 64, 8192);
|
2019-04-26 15:58:25 -07:00
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
if(auto peropt = ConfigValueUInt(devname, nullptr, "periods"))
|
|
|
|
device->BufferSize = device->UpdateSize * clampu(*peropt, 2, 16);
|
2019-04-26 15:58:25 -07:00
|
|
|
else
|
|
|
|
device->BufferSize = maxu(device->BufferSize, device->UpdateSize*2);
|
2018-12-18 09:27:00 -08:00
|
|
|
}
|
|
|
|
else
|
2011-09-18 16:16:55 -07:00
|
|
|
{
|
2018-12-18 09:27:00 -08:00
|
|
|
device->Frequency = freq;
|
2018-12-24 19:29:01 -08:00
|
|
|
device->FmtChans = static_cast<DevFmtChannels>(schans);
|
|
|
|
device->FmtType = static_cast<DevFmtType>(stype);
|
2018-12-18 09:27:00 -08:00
|
|
|
if(schans == ALC_BFORMAT3D_SOFT)
|
2012-02-25 18:03:33 -08:00
|
|
|
{
|
2018-12-18 09:27:00 -08:00
|
|
|
device->mAmbiOrder = aorder;
|
|
|
|
device->mAmbiLayout = static_cast<AmbiLayout>(alayout);
|
|
|
|
device->mAmbiScale = static_cast<AmbiNorm>(ascale);
|
2016-04-17 17:22:03 -07:00
|
|
|
}
|
2011-09-18 16:16:55 -07:00
|
|
|
}
|
2017-04-14 22:56:54 -07:00
|
|
|
|
|
|
|
if(numMono > INT_MAX-numStereo)
|
|
|
|
numMono = INT_MAX-numStereo;
|
|
|
|
numMono += numStereo;
|
2019-07-06 00:19:48 -07:00
|
|
|
if(auto srcsopt = ConfigValueUInt(devname, nullptr, "sources"))
|
2017-04-14 22:56:54 -07:00
|
|
|
{
|
2019-06-30 12:00:10 -07:00
|
|
|
if(*srcsopt <= 0) numMono = 256;
|
|
|
|
else numMono = *srcsopt;
|
2017-04-14 22:56:54 -07:00
|
|
|
}
|
|
|
|
else
|
2019-07-06 00:19:48 -07:00
|
|
|
numMono = maxu(numMono, 256);
|
|
|
|
numStereo = minu(numStereo, numMono);
|
2017-04-14 22:56:54 -07:00
|
|
|
numMono -= numStereo;
|
|
|
|
device->SourcesMax = numMono + numStereo;
|
|
|
|
|
2010-08-12 17:24:55 -07:00
|
|
|
device->NumMonoSources = numMono;
|
|
|
|
device->NumStereoSources = numStereo;
|
2017-02-21 16:31:59 -08:00
|
|
|
|
2019-06-30 12:00:10 -07:00
|
|
|
if(auto sendsopt = ConfigValueInt(devname, nullptr, "sends"))
|
|
|
|
new_sends = mini(numSends, clampi(*sendsopt, 0, MAX_SENDS));
|
2017-02-21 17:19:02 -08:00
|
|
|
else
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
new_sends = numSends;
|
2010-08-09 00:28:48 -07:00
|
|
|
}
|
|
|
|
|
2019-06-09 02:20:30 -07:00
|
|
|
if(device->Flags.get<DeviceRunning>())
|
2012-01-25 20:00:34 -08:00
|
|
|
return ALC_NO_ERROR;
|
2012-01-17 15:55:37 -08:00
|
|
|
|
2019-06-15 23:10:11 -07:00
|
|
|
device->AvgSpeakerDist = 0.0f;
|
2018-11-14 04:15:44 -08:00
|
|
|
device->Uhj_Encoder = nullptr;
|
2019-06-15 23:10:11 -07:00
|
|
|
device->AmbiDecoder = nullptr;
|
2018-11-14 04:15:44 -08:00
|
|
|
device->Bs2b = nullptr;
|
2019-06-15 23:10:11 -07:00
|
|
|
device->PostProcess = nullptr;
|
2016-02-26 16:09:06 -08:00
|
|
|
|
2019-06-15 23:10:11 -07:00
|
|
|
device->Stablizer = nullptr;
|
2018-12-24 09:17:00 -08:00
|
|
|
device->Limiter = nullptr;
|
2018-11-21 05:06:31 -08:00
|
|
|
device->ChannelDelay.clear();
|
2017-02-28 21:01:13 -08:00
|
|
|
|
2019-06-15 23:10:11 -07:00
|
|
|
device->Dry.AmbiMap.fill(BFChannelConfig{});
|
2019-07-04 15:02:12 -07:00
|
|
|
device->Dry.Buffer = {};
|
2019-06-15 23:10:11 -07:00
|
|
|
std::fill(std::begin(device->NumChannelsPerOrder), std::end(device->NumChannelsPerOrder), 0u);
|
|
|
|
device->RealOut.ChannelIndex.fill(-1);
|
2019-07-03 23:26:33 -07:00
|
|
|
device->RealOut.Buffer = {};
|
2018-11-19 06:22:09 -08:00
|
|
|
device->MixBuffer.clear();
|
|
|
|
device->MixBuffer.shrink_to_fit();
|
2014-11-22 04:20:17 -08:00
|
|
|
|
2014-02-01 16:37:11 -08:00
|
|
|
UpdateClockBase(device);
|
2019-03-26 10:18:02 -07:00
|
|
|
device->FixedLatency = nanoseconds::zero();
|
2014-02-01 16:37:11 -08:00
|
|
|
|
2019-06-15 23:10:11 -07:00
|
|
|
device->DitherDepth = 0.0f;
|
2017-05-23 00:02:04 -07:00
|
|
|
device->DitherSeed = DITHER_RNG_SEED;
|
|
|
|
|
2016-04-14 14:24:52 -07:00
|
|
|
/*************************************************************************
|
|
|
|
* Update device format request if HRTF is requested
|
|
|
|
*/
|
2017-03-10 10:47:43 -08:00
|
|
|
device->HrtfStatus = ALC_HRTF_DISABLED_SOFT;
|
2015-09-04 20:16:48 -07:00
|
|
|
if(device->Type != Loopback)
|
2013-05-31 19:29:32 -07:00
|
|
|
{
|
2019-06-30 16:15:15 -07:00
|
|
|
if(auto hrtfopt = ConfigValueStr(device->DeviceName.c_str(), nullptr, "hrtf"))
|
2015-05-15 23:28:03 -07:00
|
|
|
{
|
2019-06-30 16:15:15 -07:00
|
|
|
const char *hrtf{hrtfopt->c_str()};
|
2015-09-04 20:16:48 -07:00
|
|
|
if(strcasecmp(hrtf, "true") == 0)
|
2015-09-05 01:32:12 -07:00
|
|
|
hrtf_userreq = Hrtf_Enable;
|
2015-09-04 20:16:48 -07:00
|
|
|
else if(strcasecmp(hrtf, "false") == 0)
|
2015-09-05 01:32:12 -07:00
|
|
|
hrtf_userreq = Hrtf_Disable;
|
2015-09-04 20:16:48 -07:00
|
|
|
else if(strcasecmp(hrtf, "auto") != 0)
|
|
|
|
ERR("Unexpected hrtf value: %s\n", hrtf);
|
|
|
|
}
|
|
|
|
|
2015-09-05 14:22:19 -07:00
|
|
|
if(hrtf_userreq == Hrtf_Enable || (hrtf_userreq != Hrtf_Disable && hrtf_appreq == Hrtf_Enable))
|
2015-09-04 20:16:48 -07:00
|
|
|
{
|
2018-12-22 09:20:50 -08:00
|
|
|
HrtfEntry *hrtf{nullptr};
|
2018-11-18 19:19:35 -08:00
|
|
|
if(device->HrtfList.empty())
|
2018-11-18 18:45:45 -08:00
|
|
|
device->HrtfList = EnumerateHrtf(device->DeviceName.c_str());
|
2018-11-18 19:19:35 -08:00
|
|
|
if(!device->HrtfList.empty())
|
2015-10-06 06:48:53 -07:00
|
|
|
{
|
2019-01-08 19:42:44 +01:00
|
|
|
if(hrtf_id >= 0 && static_cast<size_t>(hrtf_id) < device->HrtfList.size())
|
2018-11-18 19:19:35 -08:00
|
|
|
hrtf = GetLoadedHrtf(device->HrtfList[hrtf_id].hrtf);
|
2017-04-05 12:27:30 -07:00
|
|
|
else
|
2018-11-18 19:19:35 -08:00
|
|
|
hrtf = GetLoadedHrtf(device->HrtfList.front().hrtf);
|
2017-04-05 12:27:30 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if(hrtf)
|
|
|
|
{
|
2017-04-05 11:29:58 -07:00
|
|
|
device->FmtChans = DevFmtStereo;
|
|
|
|
device->Frequency = hrtf->sampleRate;
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.set<ChannelsRequest, FrequencyRequest>();
|
2019-01-24 10:05:37 -08:00
|
|
|
if(HrtfEntry *oldhrtf{device->mHrtf})
|
|
|
|
oldhrtf->DecRef();
|
2018-12-22 09:20:50 -08:00
|
|
|
device->mHrtf = hrtf;
|
2015-10-06 06:48:53 -07:00
|
|
|
}
|
2015-09-05 14:22:19 -07:00
|
|
|
else
|
2015-09-04 20:16:48 -07:00
|
|
|
{
|
2016-04-14 14:24:52 -07:00
|
|
|
hrtf_userreq = Hrtf_Default;
|
|
|
|
hrtf_appreq = Hrtf_Disable;
|
2017-03-10 10:47:43 -08:00
|
|
|
device->HrtfStatus = ALC_HRTF_UNSUPPORTED_FORMAT_SOFT;
|
2015-09-04 20:16:48 -07:00
|
|
|
}
|
2015-05-15 23:28:03 -07:00
|
|
|
}
|
2014-11-23 08:38:33 -08:00
|
|
|
}
|
2013-05-31 19:29:32 -07:00
|
|
|
|
2014-08-29 19:34:20 -07:00
|
|
|
oldFreq = device->Frequency;
|
|
|
|
oldChans = device->FmtChans;
|
|
|
|
oldType = device->FmtType;
|
|
|
|
|
2019-04-26 15:58:25 -07:00
|
|
|
TRACE("Pre-reset: %s%s, %s%s, %s%uhz, %u / %u buffer\n",
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.get<ChannelsRequest>()?"*":"", DevFmtChannelsString(device->FmtChans),
|
|
|
|
device->Flags.get<SampleTypeRequest>()?"*":"", DevFmtTypeString(device->FmtType),
|
|
|
|
device->Flags.get<FrequencyRequest>()?"*":"", device->Frequency,
|
2019-04-26 15:58:25 -07:00
|
|
|
device->UpdateSize, device->BufferSize);
|
2014-08-29 19:34:20 -07:00
|
|
|
|
2019-05-04 20:17:54 -07:00
|
|
|
try {
|
|
|
|
if(device->Backend->reset() == ALC_FALSE)
|
|
|
|
return ALC_INVALID_DEVICE;
|
|
|
|
}
|
|
|
|
catch(std::exception &e) {
|
|
|
|
ERR("Device reset failed: %s\n", e.what());
|
2012-01-25 20:00:34 -08:00
|
|
|
return ALC_INVALID_DEVICE;
|
2019-05-04 20:17:54 -07:00
|
|
|
}
|
2012-01-17 15:55:37 -08:00
|
|
|
|
2019-06-09 02:20:30 -07:00
|
|
|
if(device->FmtChans != oldChans && device->Flags.get<ChannelsRequest>())
|
2012-01-20 12:20:24 -08:00
|
|
|
{
|
2012-02-15 11:28:19 -08:00
|
|
|
ERR("Failed to set %s, got %s instead\n", DevFmtChannelsString(oldChans),
|
|
|
|
DevFmtChannelsString(device->FmtChans));
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.unset<ChannelsRequest>();
|
2011-05-29 02:56:00 -07:00
|
|
|
}
|
2019-06-09 02:20:30 -07:00
|
|
|
if(device->FmtType != oldType && device->Flags.get<SampleTypeRequest>())
|
2012-02-15 16:26:32 -08:00
|
|
|
{
|
|
|
|
ERR("Failed to set %s, got %s instead\n", DevFmtTypeString(oldType),
|
|
|
|
DevFmtTypeString(device->FmtType));
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.unset<SampleTypeRequest>();
|
2012-02-15 16:26:32 -08:00
|
|
|
}
|
2019-06-09 02:20:30 -07:00
|
|
|
if(device->Frequency != oldFreq && device->Flags.get<FrequencyRequest>())
|
2012-01-20 12:20:24 -08:00
|
|
|
{
|
2019-07-02 01:56:59 -07:00
|
|
|
WARN("Failed to set %uhz, got %uhz instead\n", oldFreq, device->Frequency);
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.unset<FrequencyRequest>();
|
2012-01-20 12:20:24 -08:00
|
|
|
}
|
|
|
|
|
2019-04-26 15:58:25 -07:00
|
|
|
TRACE("Post-reset: %s, %s, %uhz, %u / %u buffer\n",
|
2016-04-14 15:25:12 -07:00
|
|
|
DevFmtChannelsString(device->FmtChans), DevFmtTypeString(device->FmtType),
|
2019-04-26 15:58:25 -07:00
|
|
|
device->Frequency, device->UpdateSize, device->BufferSize);
|
2016-04-14 15:25:12 -07:00
|
|
|
|
|
|
|
aluInitRenderer(device, hrtf_id, hrtf_appreq, hrtf_userreq);
|
2017-02-19 17:45:27 -08:00
|
|
|
|
2017-02-21 16:31:59 -08:00
|
|
|
device->NumAuxSends = new_sends;
|
2017-04-14 22:56:54 -07:00
|
|
|
TRACE("Max sources: %d (%d + %d), effect slots: %d, sends: %d\n",
|
2019-06-15 23:10:11 -07:00
|
|
|
device->SourcesMax, device->NumMonoSources, device->NumStereoSources,
|
|
|
|
device->AuxiliaryEffectSlotMax, device->NumAuxSends);
|
|
|
|
|
|
|
|
/* Enable the stablizer only for formats that have front-left, front-right,
|
|
|
|
* and front-center outputs.
|
|
|
|
*/
|
|
|
|
switch(device->FmtChans)
|
|
|
|
{
|
|
|
|
case DevFmtX51:
|
|
|
|
case DevFmtX51Rear:
|
|
|
|
case DevFmtX61:
|
|
|
|
case DevFmtX71:
|
|
|
|
if(GetConfigValueBool(device->DeviceName.c_str(), nullptr, "front-stablizer", 0))
|
|
|
|
{
|
|
|
|
auto stablizer = al::make_unique<FrontStablizer>();
|
2019-07-06 00:19:48 -07:00
|
|
|
/* Initialize band-splitting filters for the front-left and front-
|
|
|
|
* right channels, with a crossover at 5khz (could be higher).
|
|
|
|
*/
|
2019-07-14 17:39:45 -07:00
|
|
|
const ALfloat scale{5000.0f / static_cast<ALfloat>(device->Frequency)};
|
2019-06-15 23:10:11 -07:00
|
|
|
|
|
|
|
stablizer->LFilter.init(scale);
|
|
|
|
stablizer->RFilter = stablizer->LFilter;
|
|
|
|
|
|
|
|
device->Stablizer = std::move(stablizer);
|
|
|
|
/* NOTE: Don't know why this has to be "copied" into a local static
|
|
|
|
* constexpr variable to avoid a reference on
|
|
|
|
* FrontStablizer::DelayLength...
|
|
|
|
*/
|
|
|
|
static constexpr size_t StablizerDelay{FrontStablizer::DelayLength};
|
|
|
|
device->FixedLatency += nanoseconds{seconds{StablizerDelay}} / device->Frequency;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case DevFmtMono:
|
|
|
|
case DevFmtStereo:
|
|
|
|
case DevFmtQuad:
|
|
|
|
case DevFmtAmbi3D:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
TRACE("Front stablizer %s\n", device->Stablizer ? "enabled" : "disabled");
|
2017-04-26 18:38:09 -07:00
|
|
|
|
2018-11-18 18:45:45 -08:00
|
|
|
if(GetConfigValueBool(device->DeviceName.c_str(), nullptr, "dither", 1))
|
2017-06-17 23:09:51 -07:00
|
|
|
{
|
2019-06-30 12:00:10 -07:00
|
|
|
ALint depth{
|
|
|
|
ConfigValueInt(device->DeviceName.c_str(), nullptr, "dither-depth").value_or(0)};
|
2017-06-17 23:09:51 -07:00
|
|
|
if(depth <= 0)
|
|
|
|
{
|
|
|
|
switch(device->FmtType)
|
|
|
|
{
|
|
|
|
case DevFmtByte:
|
|
|
|
case DevFmtUByte:
|
|
|
|
depth = 8;
|
|
|
|
break;
|
|
|
|
case DevFmtShort:
|
|
|
|
case DevFmtUShort:
|
|
|
|
depth = 16;
|
|
|
|
break;
|
|
|
|
case DevFmtInt:
|
|
|
|
case DevFmtUInt:
|
|
|
|
case DevFmtFloat:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2018-05-23 19:49:49 -07:00
|
|
|
|
|
|
|
if(depth > 0)
|
|
|
|
{
|
2018-10-03 13:51:21 -07:00
|
|
|
depth = clampi(depth, 2, 24);
|
2019-01-08 19:42:44 +01:00
|
|
|
device->DitherDepth = std::pow(2.0f, static_cast<ALfloat>(depth-1));
|
2018-05-23 19:49:49 -07:00
|
|
|
}
|
2017-06-17 23:09:51 -07:00
|
|
|
}
|
2017-06-19 00:17:11 -07:00
|
|
|
if(!(device->DitherDepth > 0.0f))
|
|
|
|
TRACE("Dithering disabled\n");
|
|
|
|
else
|
2018-11-18 08:03:22 -08:00
|
|
|
TRACE("Dithering enabled (%d-bit, %g)\n", float2int(std::log2(device->DitherDepth)+0.5f)+1,
|
2017-06-19 00:17:11 -07:00
|
|
|
device->DitherDepth);
|
2017-06-17 23:09:51 -07:00
|
|
|
|
2018-10-03 13:48:04 -07:00
|
|
|
device->LimiterState = gainLimiter;
|
2019-06-30 16:38:25 -07:00
|
|
|
if(auto limopt = ConfigValueBool(device->DeviceName.c_str(), nullptr, "output-limiter"))
|
|
|
|
gainLimiter = *limopt ? ALC_TRUE : ALC_FALSE;
|
2018-10-03 13:48:04 -07:00
|
|
|
|
2017-05-11 11:04:25 -07:00
|
|
|
/* Valid values for gainLimiter are ALC_DONT_CARE_SOFT, ALC_TRUE, and
|
2018-10-03 13:48:04 -07:00
|
|
|
* ALC_FALSE. For ALC_DONT_CARE_SOFT, use the limiter for integer-based
|
|
|
|
* output (where samples must be clamped), and don't for floating-point
|
|
|
|
* (which can take unclamped samples).
|
2017-05-11 11:04:25 -07:00
|
|
|
*/
|
2018-10-03 13:48:04 -07:00
|
|
|
if(gainLimiter == ALC_DONT_CARE_SOFT)
|
|
|
|
{
|
|
|
|
switch(device->FmtType)
|
|
|
|
{
|
|
|
|
case DevFmtByte:
|
|
|
|
case DevFmtUByte:
|
|
|
|
case DevFmtShort:
|
|
|
|
case DevFmtUShort:
|
|
|
|
case DevFmtInt:
|
|
|
|
case DevFmtUInt:
|
|
|
|
gainLimiter = ALC_TRUE;
|
|
|
|
break;
|
|
|
|
case DevFmtFloat:
|
|
|
|
gainLimiter = ALC_FALSE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2019-05-04 13:53:11 -07:00
|
|
|
if(gainLimiter == ALC_FALSE)
|
|
|
|
TRACE("Output limiter disabled\n");
|
|
|
|
else
|
2017-05-05 07:38:26 -07:00
|
|
|
{
|
2018-09-25 10:29:38 -07:00
|
|
|
ALfloat thrshld = 1.0f;
|
|
|
|
switch(device->FmtType)
|
2017-05-27 03:36:34 -07:00
|
|
|
{
|
2018-09-25 10:29:38 -07:00
|
|
|
case DevFmtByte:
|
|
|
|
case DevFmtUByte:
|
|
|
|
thrshld = 127.0f / 128.0f;
|
|
|
|
break;
|
|
|
|
case DevFmtShort:
|
|
|
|
case DevFmtUShort:
|
|
|
|
thrshld = 32767.0f / 32768.0f;
|
|
|
|
break;
|
|
|
|
case DevFmtInt:
|
|
|
|
case DevFmtUInt:
|
|
|
|
case DevFmtFloat:
|
|
|
|
break;
|
2017-05-27 03:36:34 -07:00
|
|
|
}
|
2018-09-25 10:29:38 -07:00
|
|
|
if(device->DitherDepth > 0.0f)
|
|
|
|
thrshld -= 1.0f / device->DitherDepth;
|
|
|
|
|
2019-05-04 13:53:11 -07:00
|
|
|
const float thrshld_dB{std::log10(thrshld) * 20.0f};
|
|
|
|
auto limiter = CreateDeviceLimiter(device, thrshld_dB);
|
2018-11-22 12:53:16 -08:00
|
|
|
/* Convert the lookahead from samples to nanosamples to nanoseconds. */
|
2019-03-26 10:18:02 -07:00
|
|
|
device->FixedLatency += nanoseconds{seconds{limiter->getLookAhead()}} / device->Frequency;
|
2018-12-24 09:17:00 -08:00
|
|
|
device->Limiter = std::move(limiter);
|
2019-05-04 13:53:11 -07:00
|
|
|
TRACE("Output limiter enabled, %.4fdB limit\n", thrshld_dB);
|
2017-05-05 07:38:26 -07:00
|
|
|
}
|
2017-04-26 18:38:09 -07:00
|
|
|
|
2018-11-22 12:53:16 -08:00
|
|
|
TRACE("Fixed device latency: %ldns\n", (long)device->FixedLatency.count());
|
2018-09-25 23:05:27 -07:00
|
|
|
|
2017-04-26 18:38:09 -07:00
|
|
|
/* Need to delay returning failure until replacement Send arrays have been
|
|
|
|
* allocated with the appropriate size.
|
|
|
|
*/
|
2017-02-21 16:31:59 -08:00
|
|
|
update_failed = AL_FALSE;
|
2018-11-21 09:07:02 -08:00
|
|
|
FPUCtl mixer_mode{};
|
2019-06-29 21:32:36 -07:00
|
|
|
for(ALCcontext *context : *device->mContexts.load())
|
2010-08-09 00:28:48 -07:00
|
|
|
{
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mDefaultSlot)
|
2017-07-13 21:30:05 -07:00
|
|
|
{
|
2019-07-30 09:05:54 -07:00
|
|
|
ALeffectslot *slot = context->mDefaultSlot.get();
|
2019-02-21 04:23:01 -08:00
|
|
|
aluInitEffectPanning(slot, device);
|
2017-07-13 21:30:05 -07:00
|
|
|
|
2019-02-20 21:01:08 -08:00
|
|
|
EffectState *state{slot->Effect.State};
|
2019-07-04 15:02:12 -07:00
|
|
|
state->mOutTarget = device->Dry.Buffer;
|
2018-11-19 22:34:26 -08:00
|
|
|
if(state->deviceUpdate(device) == AL_FALSE)
|
2017-07-13 21:30:05 -07:00
|
|
|
update_failed = AL_TRUE;
|
|
|
|
else
|
2017-09-27 11:13:18 -07:00
|
|
|
UpdateEffectSlotProps(slot, context);
|
2017-07-13 21:30:05 -07:00
|
|
|
}
|
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::unique_lock<std::mutex> proplock{context->mPropLock};
|
|
|
|
std::unique_lock<std::mutex> slotlock{context->mEffectSlotLock};
|
|
|
|
for(auto &sublist : context->mEffectSlotList)
|
2010-08-09 00:28:48 -07:00
|
|
|
{
|
2019-02-20 22:00:26 -08:00
|
|
|
uint64_t usemask = ~sublist.FreeMask;
|
|
|
|
while(usemask)
|
|
|
|
{
|
|
|
|
ALsizei idx = CTZ64(usemask);
|
|
|
|
ALeffectslot *slot = sublist.EffectSlots + idx;
|
2010-08-09 00:28:48 -07:00
|
|
|
|
2019-02-20 22:00:26 -08:00
|
|
|
usemask &= ~(1_u64 << idx);
|
|
|
|
|
2019-02-21 04:23:01 -08:00
|
|
|
aluInitEffectPanning(slot, device);
|
2019-02-20 22:00:26 -08:00
|
|
|
|
|
|
|
EffectState *state{slot->Effect.State};
|
2019-07-04 15:02:12 -07:00
|
|
|
state->mOutTarget = device->Dry.Buffer;
|
2019-02-20 22:00:26 -08:00
|
|
|
if(state->deviceUpdate(device) == AL_FALSE)
|
|
|
|
update_failed = AL_TRUE;
|
|
|
|
else
|
|
|
|
UpdateEffectSlotProps(slot, context);
|
|
|
|
}
|
2010-08-09 00:28:48 -07:00
|
|
|
}
|
2018-11-21 05:35:47 -08:00
|
|
|
slotlock.unlock();
|
2010-08-09 00:28:48 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
std::unique_lock<std::mutex> srclock{context->mSourceLock};
|
|
|
|
for(auto &sublist : context->mSourceList)
|
2010-08-09 00:28:48 -07:00
|
|
|
{
|
2018-11-18 02:15:31 -08:00
|
|
|
uint64_t usemask = ~sublist.FreeMask;
|
2018-01-27 13:02:17 -08:00
|
|
|
while(usemask)
|
2010-08-09 00:28:48 -07:00
|
|
|
{
|
2018-01-27 13:02:17 -08:00
|
|
|
ALsizei idx = CTZ64(usemask);
|
2018-11-18 02:15:31 -08:00
|
|
|
ALsource *source = sublist.Sources + idx;
|
2017-02-21 16:31:59 -08:00
|
|
|
|
2019-01-07 04:06:40 -08:00
|
|
|
usemask &= ~(1_u64 << idx);
|
2018-01-27 13:02:17 -08:00
|
|
|
|
|
|
|
if(old_sends != device->NumAuxSends)
|
2017-02-21 16:31:59 -08:00
|
|
|
{
|
2018-01-27 13:02:17 -08:00
|
|
|
ALsizei s;
|
|
|
|
for(s = device->NumAuxSends;s < old_sends;s++)
|
|
|
|
{
|
|
|
|
if(source->Send[s].Slot)
|
2019-08-01 13:28:53 -07:00
|
|
|
DecrementRef(source->Send[s].Slot->ref);
|
2018-11-14 04:15:44 -08:00
|
|
|
source->Send[s].Slot = nullptr;
|
2018-01-27 13:02:17 -08:00
|
|
|
}
|
2018-11-20 12:25:15 -08:00
|
|
|
source->Send.resize(device->NumAuxSends);
|
|
|
|
source->Send.shrink_to_fit();
|
2018-01-27 13:02:17 -08:00
|
|
|
for(s = old_sends;s < device->NumAuxSends;s++)
|
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
source->Send[s].Slot = nullptr;
|
2018-01-27 13:02:17 -08:00
|
|
|
source->Send[s].Gain = 1.0f;
|
|
|
|
source->Send[s].GainHF = 1.0f;
|
|
|
|
source->Send[s].HFReference = LOWPASSFREQREF;
|
|
|
|
source->Send[s].GainLF = 1.0f;
|
|
|
|
source->Send[s].LFReference = HIGHPASSFREQREF;
|
|
|
|
}
|
2017-02-21 16:31:59 -08:00
|
|
|
}
|
2017-02-14 19:59:39 -08:00
|
|
|
|
2018-11-20 10:45:01 -08:00
|
|
|
source->PropsClean.clear(std::memory_order_release);
|
2018-01-27 13:02:17 -08:00
|
|
|
}
|
2017-04-17 21:16:01 -07:00
|
|
|
}
|
2017-09-27 11:13:18 -07:00
|
|
|
|
|
|
|
/* Clear any pre-existing voice property structs, in case the number of
|
|
|
|
* auxiliary sends is changing. Active sources will have updates
|
|
|
|
* respecified in UpdateAllSourceProps.
|
|
|
|
*/
|
2019-07-30 09:05:54 -07:00
|
|
|
ALvoiceProps *vprops{context->mFreeVoiceProps.exchange(nullptr, std::memory_order_acq_rel)};
|
2017-09-27 11:13:18 -07:00
|
|
|
while(vprops)
|
|
|
|
{
|
2018-11-30 16:56:23 -08:00
|
|
|
ALvoiceProps *next = vprops->next.load(std::memory_order_relaxed);
|
|
|
|
delete vprops;
|
2017-09-27 11:13:18 -07:00
|
|
|
vprops = next;
|
|
|
|
}
|
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
auto voices = context->mVoices.get();
|
|
|
|
auto voices_end = voices->begin() + context->mVoiceCount.load(std::memory_order_relaxed);
|
2019-06-09 18:13:54 -07:00
|
|
|
if(device->NumAuxSends < old_sends)
|
|
|
|
{
|
|
|
|
const ALsizei num_sends{device->NumAuxSends};
|
|
|
|
/* Clear extraneous property set sends. */
|
|
|
|
auto clear_sends = [num_sends](ALvoice &voice) -> void
|
|
|
|
{
|
|
|
|
std::fill(std::begin(voice.mProps.Send)+num_sends, std::end(voice.mProps.Send),
|
|
|
|
ALvoiceProps::SendData{});
|
|
|
|
|
|
|
|
std::fill(voice.mSend.begin()+num_sends, voice.mSend.end(), ALvoice::SendData{});
|
|
|
|
auto clear_chan_sends = [num_sends](ALvoice::ChannelData &chandata) -> void
|
|
|
|
{
|
|
|
|
std::fill(chandata.mWetParams.begin()+num_sends, chandata.mWetParams.end(),
|
|
|
|
SendParams{});
|
|
|
|
};
|
|
|
|
std::for_each(voice.mChans.begin(), voice.mChans.end(), clear_chan_sends);
|
|
|
|
};
|
|
|
|
std::for_each(voices->begin(), voices_end, clear_sends);
|
|
|
|
}
|
|
|
|
std::for_each(voices->begin(), voices_end,
|
|
|
|
[device](ALvoice &voice) -> void
|
2018-11-23 16:16:31 -08:00
|
|
|
{
|
2019-06-09 18:13:54 -07:00
|
|
|
delete voice.mUpdate.exchange(nullptr, std::memory_order_acq_rel);
|
2017-04-17 21:16:01 -07:00
|
|
|
|
2019-03-09 16:48:07 -08:00
|
|
|
/* Force the voice to stopped if it was stopping. */
|
|
|
|
ALvoice::State vstate{ALvoice::Stopping};
|
2019-06-09 18:13:54 -07:00
|
|
|
voice.mPlayState.compare_exchange_strong(vstate, ALvoice::Stopped,
|
2019-03-09 16:48:07 -08:00
|
|
|
std::memory_order_acquire, std::memory_order_acquire);
|
2019-06-09 18:13:54 -07:00
|
|
|
if(voice.mSourceID.load(std::memory_order_relaxed) == 0u)
|
2018-11-23 16:16:31 -08:00
|
|
|
return;
|
2017-03-10 04:35:32 -08:00
|
|
|
|
2018-11-23 16:16:31 -08:00
|
|
|
if(device->AvgSpeakerDist > 0.0f)
|
|
|
|
{
|
|
|
|
/* Reinitialize the NFC filters for new parameters. */
|
2019-06-03 22:24:26 -07:00
|
|
|
const ALfloat w1{SPEEDOFSOUNDMETRESPERSEC /
|
|
|
|
(device->AvgSpeakerDist * device->Frequency)};
|
|
|
|
auto init_nfc = [w1](ALvoice::ChannelData &chandata) -> void
|
|
|
|
{ chandata.mDryParams.NFCtrlFilter.init(w1); };
|
2019-06-09 18:13:54 -07:00
|
|
|
std::for_each(voice.mChans.begin(), voice.mChans.begin()+voice.mNumChannels,
|
2019-06-03 22:24:26 -07:00
|
|
|
init_nfc);
|
2018-11-23 16:16:31 -08:00
|
|
|
}
|
2017-03-10 04:35:32 -08:00
|
|
|
}
|
2018-11-23 16:16:31 -08:00
|
|
|
);
|
2018-11-21 06:41:49 -08:00
|
|
|
srclock.unlock();
|
2011-08-28 19:28:41 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
context->mPropsClean.test_and_set(std::memory_order_release);
|
2017-09-27 09:36:34 -07:00
|
|
|
UpdateContextProps(context);
|
2019-07-30 09:05:54 -07:00
|
|
|
context->mListener.PropsClean.test_and_set(std::memory_order_release);
|
2016-11-23 01:31:13 -08:00
|
|
|
UpdateListenerProps(context);
|
2017-02-14 19:59:39 -08:00
|
|
|
UpdateAllSourceProps(context);
|
2010-08-09 00:28:48 -07:00
|
|
|
}
|
2018-11-21 09:07:02 -08:00
|
|
|
mixer_mode.leave();
|
2017-02-21 16:31:59 -08:00
|
|
|
if(update_failed)
|
|
|
|
return ALC_INVALID_DEVICE;
|
2012-03-05 07:11:09 -08:00
|
|
|
|
2019-06-09 02:20:30 -07:00
|
|
|
if(!device->Flags.get<DevicePaused>())
|
2014-01-15 16:44:12 -08:00
|
|
|
{
|
2018-12-28 22:56:20 -08:00
|
|
|
if(device->Backend->start() == ALC_FALSE)
|
2014-01-15 16:44:12 -08:00
|
|
|
return ALC_INVALID_DEVICE;
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.set<DeviceRunning>();
|
2014-01-15 16:44:12 -08:00
|
|
|
}
|
2010-08-09 00:28:48 -07:00
|
|
|
|
2012-01-25 20:00:34 -08:00
|
|
|
return ALC_NO_ERROR;
|
2010-08-09 00:28:48 -07:00
|
|
|
}
|
|
|
|
|
2018-01-28 18:03:54 -08:00
|
|
|
|
2019-06-29 21:32:36 -07:00
|
|
|
ALCdevice::ALCdevice(DeviceType type) : Type{type}, mContexts{&EmptyContextArray}
|
2018-01-28 18:03:54 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2019-01-01 18:13:33 -08:00
|
|
|
/* ALCdevice::~ALCdevice
|
2011-09-10 09:00:01 -07:00
|
|
|
*
|
|
|
|
* Frees the device structure, and destroys any objects the app failed to
|
2011-09-10 20:52:19 -07:00
|
|
|
* delete. Called once there's no more references on the device.
|
2011-09-10 09:00:01 -07:00
|
|
|
*/
|
2019-01-01 18:13:33 -08:00
|
|
|
ALCdevice::~ALCdevice()
|
2011-09-10 02:43:07 -07:00
|
|
|
{
|
2019-06-04 01:37:36 -07:00
|
|
|
TRACE("Freeing device %p\n", this);
|
2011-09-10 03:01:24 -07:00
|
|
|
|
2018-11-18 07:33:42 -08:00
|
|
|
Backend = nullptr;
|
2012-08-18 14:49:42 -07:00
|
|
|
|
2018-11-28 11:30:44 -08:00
|
|
|
size_t count{std::accumulate(BufferList.cbegin(), BufferList.cend(), size_t{0u},
|
|
|
|
[](size_t cur, const BufferSubList &sublist) noexcept -> size_t
|
|
|
|
{ return cur + POPCNT64(~sublist.FreeMask); }
|
|
|
|
)};
|
2018-11-25 15:30:32 -08:00
|
|
|
if(count > 0)
|
2019-04-11 16:01:11 -07:00
|
|
|
WARN("%zu Buffer%s not deleted\n", count, (count==1)?"":"s");
|
2011-09-10 02:43:07 -07:00
|
|
|
|
2018-11-28 11:30:44 -08:00
|
|
|
count = std::accumulate(EffectList.cbegin(), EffectList.cend(), size_t{0u},
|
|
|
|
[](size_t cur, const EffectSubList &sublist) noexcept -> size_t
|
|
|
|
{ return cur + POPCNT64(~sublist.FreeMask); }
|
|
|
|
);
|
2018-11-25 16:13:07 -08:00
|
|
|
if(count > 0)
|
2019-04-11 16:01:11 -07:00
|
|
|
WARN("%zu Effect%s not deleted\n", count, (count==1)?"":"s");
|
2011-09-10 02:43:07 -07:00
|
|
|
|
2018-11-28 11:30:44 -08:00
|
|
|
count = std::accumulate(FilterList.cbegin(), FilterList.cend(), size_t{0u},
|
|
|
|
[](size_t cur, const FilterSubList &sublist) noexcept -> size_t
|
|
|
|
{ return cur + POPCNT64(~sublist.FreeMask); }
|
|
|
|
);
|
2018-11-25 16:13:07 -08:00
|
|
|
if(count > 0)
|
2019-04-11 16:01:11 -07:00
|
|
|
WARN("%zu Filter%s not deleted\n", count, (count==1)?"":"s");
|
2018-11-25 17:51:39 -08:00
|
|
|
|
2018-12-22 09:20:50 -08:00
|
|
|
if(mHrtf)
|
2019-01-24 10:05:37 -08:00
|
|
|
mHrtf->DecRef();
|
2018-12-22 09:20:50 -08:00
|
|
|
mHrtf = nullptr;
|
2019-06-29 21:32:36 -07:00
|
|
|
|
|
|
|
auto *oldarray = mContexts.exchange(nullptr, std::memory_order_relaxed);
|
|
|
|
if(oldarray != &EmptyContextArray) delete oldarray;
|
2011-09-10 02:43:07 -07:00
|
|
|
}
|
|
|
|
|
2011-09-10 09:00:01 -07:00
|
|
|
|
2011-09-10 05:19:08 -07:00
|
|
|
/* VerifyDevice
|
|
|
|
*
|
2018-11-23 17:54:12 -08:00
|
|
|
* Checks if the device handle is valid, and returns a new reference if so.
|
2011-09-10 05:19:08 -07:00
|
|
|
*/
|
2018-11-23 17:54:12 -08:00
|
|
|
static DeviceRef VerifyDevice(ALCdevice *device)
|
2011-09-10 05:19:08 -07:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
std::lock_guard<std::recursive_mutex> _{ListLock};
|
2019-03-19 15:41:01 -07:00
|
|
|
auto iter = std::lower_bound(DeviceList.cbegin(), DeviceList.cend(), device);
|
|
|
|
if(iter != DeviceList.cend() && *iter == device)
|
2019-08-01 15:19:37 -07:00
|
|
|
return *iter;
|
|
|
|
return nullptr;
|
2011-09-10 05:19:08 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-01 19:44:09 -07:00
|
|
|
ALCcontext::ALCcontext(al::intrusive_ptr<ALCdevice> device) : mDevice{std::move(device)}
|
2018-11-20 05:01:08 -08:00
|
|
|
{
|
2019-07-30 09:05:54 -07:00
|
|
|
mPropsClean.test_and_set(std::memory_order_relaxed);
|
2018-11-20 05:01:08 -08:00
|
|
|
}
|
|
|
|
|
2019-01-01 18:13:33 -08:00
|
|
|
ALCcontext::~ALCcontext()
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2019-06-04 01:37:36 -07:00
|
|
|
TRACE("Freeing context %p\n", this);
|
2011-09-02 02:00:37 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
ALcontextProps *cprops{mUpdate.exchange(nullptr, std::memory_order_relaxed)};
|
2018-11-18 05:40:00 -08:00
|
|
|
if(cprops)
|
2017-09-27 08:55:42 -07:00
|
|
|
{
|
|
|
|
TRACE("Freed unapplied context update %p\n", cprops);
|
|
|
|
al_free(cprops);
|
|
|
|
}
|
2018-11-18 05:40:00 -08:00
|
|
|
size_t count{0};
|
2019-07-30 09:05:54 -07:00
|
|
|
cprops = mFreeContextProps.exchange(nullptr, std::memory_order_acquire);
|
2017-09-27 08:55:42 -07:00
|
|
|
while(cprops)
|
|
|
|
{
|
2018-11-27 21:19:30 -08:00
|
|
|
ALcontextProps *next{cprops->next.load(std::memory_order_relaxed)};
|
2017-09-27 08:55:42 -07:00
|
|
|
al_free(cprops);
|
|
|
|
cprops = next;
|
|
|
|
++count;
|
|
|
|
}
|
2019-04-11 16:01:11 -07:00
|
|
|
TRACE("Freed %zu context property object%s\n", count, (count==1)?"":"s");
|
2017-09-27 08:55:42 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
count = std::accumulate(mSourceList.cbegin(), mSourceList.cend(), size_t{0u},
|
2018-11-28 11:30:44 -08:00
|
|
|
[](size_t cur, const SourceSubList &sublist) noexcept -> size_t
|
|
|
|
{ return cur + POPCNT64(~sublist.FreeMask); }
|
|
|
|
);
|
2018-11-25 08:42:43 -08:00
|
|
|
if(count > 0)
|
2019-04-11 16:01:11 -07:00
|
|
|
WARN("%zu Source%s not deleted\n", count, (count==1)?"":"s");
|
2019-07-30 09:05:54 -07:00
|
|
|
mSourceList.clear();
|
|
|
|
mNumSources = 0;
|
2011-08-28 15:44:03 -07:00
|
|
|
|
2017-09-27 11:13:18 -07:00
|
|
|
count = 0;
|
2019-07-30 09:05:54 -07:00
|
|
|
ALeffectslotProps *eprops{mFreeEffectslotProps.exchange(nullptr, std::memory_order_acquire)};
|
2017-09-27 11:13:18 -07:00
|
|
|
while(eprops)
|
|
|
|
{
|
2018-11-27 21:19:30 -08:00
|
|
|
ALeffectslotProps *next{eprops->next.load(std::memory_order_relaxed)};
|
2019-08-01 13:28:53 -07:00
|
|
|
if(eprops->State) eprops->State->release();
|
2017-09-27 11:13:18 -07:00
|
|
|
al_free(eprops);
|
|
|
|
eprops = next;
|
|
|
|
++count;
|
|
|
|
}
|
2019-04-11 16:01:11 -07:00
|
|
|
TRACE("Freed %zu AuxiliaryEffectSlot property object%s\n", count, (count==1)?"":"s");
|
2018-01-27 17:24:18 -08:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
delete mActiveAuxSlots.exchange(nullptr, std::memory_order_relaxed);
|
|
|
|
mDefaultSlot = nullptr;
|
2018-11-27 21:19:30 -08:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
count = std::accumulate(mEffectSlotList.cbegin(), mEffectSlotList.cend(), size_t{0u},
|
2019-02-20 22:00:26 -08:00
|
|
|
[](size_t cur, const EffectSlotSubList &sublist) noexcept -> size_t
|
|
|
|
{ return cur + POPCNT64(~sublist.FreeMask); }
|
2018-11-27 21:19:30 -08:00
|
|
|
);
|
2018-11-25 09:23:01 -08:00
|
|
|
if(count > 0)
|
2019-04-11 16:01:11 -07:00
|
|
|
WARN("%zu AuxiliaryEffectSlot%s not deleted\n", count, (count==1)?"":"s");
|
2019-07-30 09:05:54 -07:00
|
|
|
mEffectSlotList.clear();
|
|
|
|
mNumEffectSlots = 0;
|
2011-08-28 15:44:03 -07:00
|
|
|
|
2017-09-27 11:13:18 -07:00
|
|
|
count = 0;
|
2019-07-30 09:05:54 -07:00
|
|
|
ALvoiceProps *vprops{mFreeVoiceProps.exchange(nullptr, std::memory_order_acquire)};
|
2017-09-27 11:13:18 -07:00
|
|
|
while(vprops)
|
|
|
|
{
|
2018-11-27 21:19:30 -08:00
|
|
|
ALvoiceProps *next{vprops->next.load(std::memory_order_relaxed)};
|
2018-11-30 16:56:23 -08:00
|
|
|
delete vprops;
|
2017-09-27 11:13:18 -07:00
|
|
|
vprops = next;
|
|
|
|
++count;
|
|
|
|
}
|
2019-04-11 16:01:11 -07:00
|
|
|
TRACE("Freed %zu voice property object%s\n", count, (count==1)?"":"s");
|
2017-09-27 11:13:18 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
mVoices = nullptr;
|
|
|
|
mVoiceCount.store(0, std::memory_order_relaxed);
|
2011-08-30 20:13:42 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
ALlistenerProps *lprops{mListener.Update.exchange(nullptr, std::memory_order_relaxed)};
|
2018-11-18 05:40:00 -08:00
|
|
|
if(lprops)
|
2016-05-11 18:40:17 -07:00
|
|
|
{
|
|
|
|
TRACE("Freed unapplied listener update %p\n", lprops);
|
2019-08-13 20:33:44 -07:00
|
|
|
delete lprops;
|
2016-05-11 18:40:17 -07:00
|
|
|
}
|
|
|
|
count = 0;
|
2019-07-30 09:05:54 -07:00
|
|
|
lprops = mFreeListenerProps.exchange(nullptr, std::memory_order_acquire);
|
2016-05-11 18:40:17 -07:00
|
|
|
while(lprops)
|
|
|
|
{
|
2018-11-27 21:19:30 -08:00
|
|
|
ALlistenerProps *next{lprops->next.load(std::memory_order_relaxed)};
|
2019-08-13 20:33:44 -07:00
|
|
|
delete lprops;
|
2016-05-11 18:40:17 -07:00
|
|
|
lprops = next;
|
|
|
|
++count;
|
|
|
|
}
|
2019-04-11 16:01:11 -07:00
|
|
|
TRACE("Freed %zu listener property object%s\n", count, (count==1)?"":"s");
|
2016-05-11 18:40:17 -07:00
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
if(mAsyncEvents)
|
2018-12-25 09:32:38 -08:00
|
|
|
{
|
2019-01-26 19:29:26 -08:00
|
|
|
count = 0;
|
2019-07-30 09:05:54 -07:00
|
|
|
auto evt_vec = mAsyncEvents->getReadVector();
|
2019-06-16 18:58:56 -07:00
|
|
|
if(evt_vec.first.len > 0)
|
2019-01-26 19:29:26 -08:00
|
|
|
{
|
2019-06-16 18:58:56 -07:00
|
|
|
al::destroy_n(reinterpret_cast<AsyncEvent*>(evt_vec.first.buf), evt_vec.first.len);
|
|
|
|
count += evt_vec.first.len;
|
2019-01-26 19:29:26 -08:00
|
|
|
}
|
2019-06-16 18:58:56 -07:00
|
|
|
if(evt_vec.second.len > 0)
|
2019-01-26 19:29:26 -08:00
|
|
|
{
|
2019-06-16 18:58:56 -07:00
|
|
|
al::destroy_n(reinterpret_cast<AsyncEvent*>(evt_vec.second.buf), evt_vec.second.len);
|
|
|
|
count += evt_vec.second.len;
|
2019-01-26 19:29:26 -08:00
|
|
|
}
|
|
|
|
if(count > 0)
|
2019-04-11 16:01:11 -07:00
|
|
|
TRACE("Destructed %zu orphaned event%s\n", count, (count==1)?"":"s");
|
2019-07-30 09:05:54 -07:00
|
|
|
mAsyncEvents->readAdvance(count);
|
2018-12-25 09:32:38 -08:00
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
|
2019-08-02 18:30:22 -07:00
|
|
|
void ALCcontext::init()
|
|
|
|
{
|
|
|
|
if(DefaultEffect.type != AL_EFFECT_NULL && mDevice->Type == Playback)
|
|
|
|
{
|
|
|
|
void *ptr{al_calloc(16, sizeof(ALeffectslot))};
|
|
|
|
mDefaultSlot = std::unique_ptr<ALeffectslot>{new (ptr) ALeffectslot{}};
|
|
|
|
if(InitEffectSlot(mDefaultSlot.get()) == AL_NO_ERROR)
|
|
|
|
aluInitEffectPanning(mDefaultSlot.get(), mDevice.get());
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mDefaultSlot = nullptr;
|
|
|
|
ERR("Failed to initialize the default effect slot\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ALeffectslotArray *auxslots;
|
|
|
|
if(!mDefaultSlot)
|
|
|
|
auxslots = ALeffectslot::CreatePtrArray(0);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
auxslots = ALeffectslot::CreatePtrArray(1);
|
|
|
|
(*auxslots)[0] = mDefaultSlot.get();
|
|
|
|
}
|
|
|
|
mActiveAuxSlots.store(auxslots, std::memory_order_relaxed);
|
|
|
|
|
|
|
|
mExtensionList = alExtList;
|
|
|
|
|
|
|
|
|
|
|
|
mListener.Params.Matrix = alu::Matrix::Identity();
|
|
|
|
mListener.Params.Velocity = alu::Vector{};
|
|
|
|
mListener.Params.Gain = mListener.Gain;
|
2019-08-05 12:15:14 -07:00
|
|
|
mListener.Params.MetersPerUnit = mListener.mMetersPerUnit;
|
2019-08-02 18:30:22 -07:00
|
|
|
mListener.Params.DopplerFactor = mDopplerFactor;
|
|
|
|
mListener.Params.SpeedOfSound = mSpeedOfSound * mDopplerVelocity;
|
|
|
|
mListener.Params.SourceDistanceModel = mSourceDistanceModel;
|
|
|
|
mListener.Params.mDistanceModel = mDistanceModel;
|
|
|
|
|
|
|
|
|
|
|
|
mAsyncEvents = CreateRingBuffer(511, sizeof(AsyncEvent), false);
|
|
|
|
StartEventThrd(this);
|
|
|
|
|
|
|
|
|
|
|
|
allocVoices(256);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool ALCcontext::deinit()
|
2011-09-10 07:35:48 -07:00
|
|
|
{
|
2019-08-02 18:30:22 -07:00
|
|
|
if(LocalContext.get() == this)
|
2011-09-12 03:35:21 -07:00
|
|
|
{
|
2019-08-02 18:30:22 -07:00
|
|
|
WARN("%p released while current on thread\n", this);
|
2018-11-16 21:55:11 -08:00
|
|
|
LocalContext.set(nullptr);
|
2019-08-02 18:30:22 -07:00
|
|
|
release();
|
2011-09-12 03:35:21 -07:00
|
|
|
}
|
|
|
|
|
2019-08-02 18:30:22 -07:00
|
|
|
ALCcontext *origctx{this};
|
2018-11-14 06:17:47 -08:00
|
|
|
if(GlobalContext.compare_exchange_strong(origctx, nullptr))
|
2019-08-02 18:30:22 -07:00
|
|
|
release();
|
2011-09-12 03:35:21 -07:00
|
|
|
|
2019-06-29 21:32:36 -07:00
|
|
|
bool ret{};
|
2019-08-02 18:30:22 -07:00
|
|
|
/* First make sure this context exists in the device's list. */
|
|
|
|
auto *oldarray = mDevice->mContexts.load(std::memory_order_acquire);
|
|
|
|
if(auto toremove = std::count(oldarray->begin(), oldarray->end(), this))
|
2019-06-29 21:32:36 -07:00
|
|
|
{
|
|
|
|
using ContextArray = al::FlexArray<ALCcontext*>;
|
2019-08-02 18:30:22 -07:00
|
|
|
auto alloc_ctx_array = [](const size_t count) -> ContextArray*
|
2019-01-01 16:38:54 -08:00
|
|
|
{
|
2019-08-02 18:30:22 -07:00
|
|
|
if(count == 0) return &EmptyContextArray;
|
2019-08-03 14:59:01 -07:00
|
|
|
return ContextArray::Create(count).release();
|
2019-08-02 18:30:22 -07:00
|
|
|
};
|
|
|
|
auto *newarray = alloc_ctx_array(oldarray->size() - toremove);
|
|
|
|
|
2019-08-03 14:59:01 -07:00
|
|
|
/* Copy the current/old context handles to the new array, excluding the
|
|
|
|
* given context.
|
|
|
|
*/
|
2019-08-02 18:30:22 -07:00
|
|
|
std::copy_if(oldarray->begin(), oldarray->end(), newarray->begin(),
|
|
|
|
std::bind(std::not_equal_to<ALCcontext*>{}, _1, this));
|
|
|
|
|
2019-08-03 14:59:01 -07:00
|
|
|
/* Store the new context array in the device. Wait for any current mix
|
|
|
|
* to finish before deleting the old array.
|
|
|
|
*/
|
2019-08-02 18:30:22 -07:00
|
|
|
mDevice->mContexts.store(newarray);
|
|
|
|
if(oldarray != &EmptyContextArray)
|
|
|
|
{
|
|
|
|
while((mDevice->MixCount.load(std::memory_order_acquire)&1))
|
|
|
|
std::this_thread::yield();
|
|
|
|
delete oldarray;
|
2019-01-01 16:38:54 -08:00
|
|
|
}
|
2019-08-02 18:30:22 -07:00
|
|
|
|
|
|
|
ret = !newarray->empty();
|
2011-09-10 07:35:48 -07:00
|
|
|
}
|
2019-08-02 18:30:22 -07:00
|
|
|
else
|
|
|
|
ret = !oldarray->empty();
|
2011-09-10 07:35:48 -07:00
|
|
|
|
2019-08-02 18:30:22 -07:00
|
|
|
StopEventThrd(this);
|
2018-09-20 22:44:58 -07:00
|
|
|
|
2017-03-28 05:33:43 -07:00
|
|
|
return ret;
|
2011-09-10 07:35:48 -07:00
|
|
|
}
|
|
|
|
|
2011-09-10 05:19:08 -07:00
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/* VerifyContext
|
|
|
|
*
|
2018-11-21 02:02:53 -08:00
|
|
|
* Checks if the given context is valid, returning a new reference to it if so.
|
2012-04-20 01:18:38 -07:00
|
|
|
*/
|
2018-11-21 02:02:53 -08:00
|
|
|
static ContextRef VerifyContext(ALCcontext *context)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
std::lock_guard<std::recursive_mutex> _{ListLock};
|
2019-03-19 18:53:32 -07:00
|
|
|
auto iter = std::lower_bound(ContextList.cbegin(), ContextList.cend(), context);
|
|
|
|
if(iter != ContextList.cend() && *iter == context)
|
2019-08-01 15:19:37 -07:00
|
|
|
return *iter;
|
|
|
|
return nullptr;
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/* GetContextRef
|
|
|
|
*
|
2018-11-24 14:07:32 -08:00
|
|
|
* Returns a new reference to the currently active context for this thread.
|
2012-04-20 01:18:38 -07:00
|
|
|
*/
|
2018-11-24 14:07:32 -08:00
|
|
|
ContextRef GetContextRef(void)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-16 21:55:11 -08:00
|
|
|
ALCcontext *context{LocalContext.get()};
|
2012-04-20 01:18:38 -07:00
|
|
|
if(context)
|
2019-08-01 13:28:53 -07:00
|
|
|
context->add_ref();
|
2012-04-20 01:18:38 -07:00
|
|
|
else
|
2011-07-13 01:21:30 -07:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
std::lock_guard<std::recursive_mutex> _{ListLock};
|
|
|
|
context = GlobalContext.load(std::memory_order_acquire);
|
2019-08-01 13:28:53 -07:00
|
|
|
if(context) context->add_ref();
|
2011-07-13 01:21:30 -07:00
|
|
|
}
|
2018-11-24 14:07:32 -08:00
|
|
|
return ContextRef{context};
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-07-30 14:13:05 -07:00
|
|
|
void ALCcontext::allocVoices(size_t num_voices)
|
2017-02-14 19:59:39 -08:00
|
|
|
{
|
2019-07-30 14:13:05 -07:00
|
|
|
const ALsizei num_sends{mDevice->NumAuxSends};
|
2017-02-14 19:59:39 -08:00
|
|
|
|
2019-07-30 14:13:05 -07:00
|
|
|
if(mVoices && num_voices == mVoices->size())
|
2017-02-14 19:59:39 -08:00
|
|
|
return;
|
|
|
|
|
2019-08-03 14:59:01 -07:00
|
|
|
using ALvoiceArray = al::FlexArray<ALvoice>;
|
|
|
|
std::unique_ptr<ALvoiceArray> voices{ALvoiceArray::Create(num_voices)};
|
2017-02-14 19:59:39 -08:00
|
|
|
|
2019-07-30 14:13:05 -07:00
|
|
|
const size_t v_count{minz(mVoiceCount.load(std::memory_order_relaxed), num_voices)};
|
|
|
|
if(mVoices)
|
2017-02-14 19:59:39 -08:00
|
|
|
{
|
2018-12-04 19:45:11 -08:00
|
|
|
/* Copy the old voice data to the new storage. */
|
2019-07-30 14:13:05 -07:00
|
|
|
auto viter = std::move(mVoices->begin(), mVoices->begin()+v_count, voices->begin());
|
2018-11-30 19:04:38 -08:00
|
|
|
|
2019-06-09 18:13:54 -07:00
|
|
|
/* Clear extraneous property set sends. */
|
|
|
|
auto clear_sends = [num_sends](ALvoice &voice) -> void
|
|
|
|
{
|
|
|
|
std::fill(std::begin(voice.mProps.Send)+num_sends, std::end(voice.mProps.Send),
|
2018-11-30 19:04:38 -08:00
|
|
|
ALvoiceProps::SendData{});
|
|
|
|
|
2019-06-09 18:13:54 -07:00
|
|
|
std::fill(voice.mSend.begin()+num_sends, voice.mSend.end(), ALvoice::SendData{});
|
|
|
|
auto clear_chan_sends = [num_sends](ALvoice::ChannelData &chandata) -> void
|
2019-06-03 22:24:26 -07:00
|
|
|
{
|
2019-06-09 18:13:54 -07:00
|
|
|
std::fill(chandata.mWetParams.begin()+num_sends, chandata.mWetParams.end(),
|
2019-06-03 22:24:26 -07:00
|
|
|
SendParams{});
|
|
|
|
};
|
2019-06-09 18:13:54 -07:00
|
|
|
std::for_each(voice.mChans.begin(), voice.mChans.end(), clear_chan_sends);
|
2018-12-04 19:45:11 -08:00
|
|
|
};
|
2019-06-09 18:13:54 -07:00
|
|
|
std::for_each(voices->begin(), viter, clear_sends);
|
2017-02-14 19:59:39 -08:00
|
|
|
}
|
|
|
|
|
2019-07-30 14:13:05 -07:00
|
|
|
mVoices = std::move(voices);
|
|
|
|
mVoiceCount.store(static_cast<ALuint>(v_count), std::memory_order_relaxed);
|
2017-02-14 19:59:39 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/************************************************
|
|
|
|
* Standard ALC functions
|
|
|
|
************************************************/
|
|
|
|
|
|
|
|
/* alcGetError
|
|
|
|
*
|
|
|
|
* Return last ALC generated error code for the given device
|
2018-11-23 17:54:12 -08:00
|
|
|
*/
|
2010-03-19 14:34:18 -07:00
|
|
|
ALC_API ALCenum ALC_APIENTRY alcGetError(ALCdevice *device)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(dev) return dev->LastError.exchange(ALC_NO_ERROR);
|
|
|
|
return LastNullDeviceError.exchange(ALC_NO_ERROR);
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcSuspendContext
|
|
|
|
*
|
2014-10-12 09:03:08 -07:00
|
|
|
* Suspends updates for the given context
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2014-10-12 09:03:08 -07:00
|
|
|
ALC_API ALCvoid ALC_APIENTRY alcSuspendContext(ALCcontext *context)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2014-10-12 09:03:08 -07:00
|
|
|
if(!SuspendDefers)
|
|
|
|
return;
|
|
|
|
|
2018-11-21 02:02:53 -08:00
|
|
|
ContextRef ctx{VerifyContext(context)};
|
|
|
|
if(!ctx)
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_CONTEXT);
|
2014-10-12 09:03:08 -07:00
|
|
|
else
|
2019-07-30 14:13:05 -07:00
|
|
|
ctx->deferUpdates();
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcProcessContext
|
|
|
|
*
|
2014-10-12 09:03:08 -07:00
|
|
|
* Resumes processing updates for the given context
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2014-10-12 09:03:08 -07:00
|
|
|
ALC_API ALCvoid ALC_APIENTRY alcProcessContext(ALCcontext *context)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2014-10-12 09:03:08 -07:00
|
|
|
if(!SuspendDefers)
|
|
|
|
return;
|
|
|
|
|
2018-11-21 02:02:53 -08:00
|
|
|
ContextRef ctx{VerifyContext(context)};
|
|
|
|
if(!ctx)
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_CONTEXT);
|
2014-10-12 09:03:08 -07:00
|
|
|
else
|
2019-07-30 14:13:05 -07:00
|
|
|
ctx->processUpdates();
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcGetString
|
|
|
|
*
|
2012-04-19 23:28:34 -07:00
|
|
|
* Returns information about the device, and error strings
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2012-04-19 23:28:34 -07:00
|
|
|
ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *Device, ALCenum param)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
const ALCchar *value = nullptr;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-06-14 09:43:33 -07:00
|
|
|
switch(param)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
|
|
|
case ALC_NO_ERROR:
|
|
|
|
value = alcNoError;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_INVALID_ENUM:
|
|
|
|
value = alcErrInvalidEnum;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_INVALID_VALUE:
|
|
|
|
value = alcErrInvalidValue;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_INVALID_DEVICE:
|
|
|
|
value = alcErrInvalidDevice;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_INVALID_CONTEXT:
|
|
|
|
value = alcErrInvalidContext;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_OUT_OF_MEMORY:
|
|
|
|
value = alcErrOutOfMemory;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_DEVICE_SPECIFIER:
|
2012-02-28 03:36:16 -08:00
|
|
|
value = alcDefaultName;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_ALL_DEVICES_SPECIFIER:
|
2019-06-29 15:04:20 -07:00
|
|
|
if(DeviceRef dev{VerifyDevice(Device)})
|
2018-11-23 17:54:12 -08:00
|
|
|
value = dev->DeviceName.c_str();
|
2012-02-28 03:36:16 -08:00
|
|
|
else
|
|
|
|
{
|
2012-05-09 16:28:16 -07:00
|
|
|
ProbeAllDevicesList();
|
2018-11-15 04:24:33 -08:00
|
|
|
value = alcAllDevicesList.c_str();
|
2012-02-28 03:36:16 -08:00
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_CAPTURE_DEVICE_SPECIFIER:
|
2019-06-29 15:04:20 -07:00
|
|
|
if(DeviceRef dev{VerifyDevice(Device)})
|
2018-11-23 17:54:12 -08:00
|
|
|
value = dev->DeviceName.c_str();
|
2007-11-13 18:02:18 -08:00
|
|
|
else
|
2009-08-27 06:09:33 -07:00
|
|
|
{
|
|
|
|
ProbeCaptureDeviceList();
|
2018-11-15 04:24:33 -08:00
|
|
|
value = alcCaptureDeviceList.c_str();
|
2009-08-27 06:09:33 -07:00
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
break;
|
|
|
|
|
2009-08-27 20:13:35 -07:00
|
|
|
/* Default devices are always first in the list */
|
|
|
|
case ALC_DEFAULT_DEVICE_SPECIFIER:
|
2012-02-20 20:45:22 -08:00
|
|
|
value = alcDefaultName;
|
2009-08-27 20:13:35 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_DEFAULT_ALL_DEVICES_SPECIFIER:
|
2018-11-15 04:24:33 -08:00
|
|
|
if(alcAllDevicesList.empty())
|
2012-05-09 16:28:16 -07:00
|
|
|
ProbeAllDevicesList();
|
2010-02-10 16:34:43 -08:00
|
|
|
|
2018-11-15 04:24:33 -08:00
|
|
|
/* Copy first entry as default. */
|
|
|
|
alcDefaultAllDevicesSpecifier = alcAllDevicesList.c_str();
|
2018-11-14 06:17:47 -08:00
|
|
|
value = alcDefaultAllDevicesSpecifier.c_str();
|
2009-08-27 20:13:35 -07:00
|
|
|
break;
|
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
case ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER:
|
2018-11-15 04:24:33 -08:00
|
|
|
if(alcCaptureDeviceList.empty())
|
2010-02-10 16:34:43 -08:00
|
|
|
ProbeCaptureDeviceList();
|
|
|
|
|
2018-11-15 04:24:33 -08:00
|
|
|
/* Copy first entry as default. */
|
|
|
|
alcCaptureDefaultDeviceSpecifier = alcCaptureDeviceList.c_str();
|
2018-11-14 06:17:47 -08:00
|
|
|
value = alcCaptureDefaultDeviceSpecifier.c_str();
|
2007-11-13 18:02:18 -08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_EXTENSIONS:
|
2019-06-29 15:04:20 -07:00
|
|
|
if(VerifyDevice(Device))
|
|
|
|
value = alcExtensionList;
|
|
|
|
else
|
|
|
|
value = alcNoDeviceExtList;
|
2007-11-13 18:02:18 -08:00
|
|
|
break;
|
|
|
|
|
2015-10-02 23:54:30 -07:00
|
|
|
case ALC_HRTF_SPECIFIER_SOFT:
|
2019-06-29 15:04:20 -07:00
|
|
|
if(DeviceRef dev{VerifyDevice(Device)})
|
2015-10-02 23:54:30 -07:00
|
|
|
{
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
2018-12-22 09:20:50 -08:00
|
|
|
value = (dev->mHrtf ? dev->HrtfName.c_str() : "");
|
2015-10-02 23:54:30 -07:00
|
|
|
}
|
2019-06-29 15:04:20 -07:00
|
|
|
else
|
|
|
|
alcSetError(nullptr, ALC_INVALID_DEVICE);
|
2015-10-02 23:54:30 -07:00
|
|
|
break;
|
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
default:
|
2019-06-29 15:04:20 -07:00
|
|
|
alcSetError(VerifyDevice(Device).get(), ALC_INVALID_ENUM);
|
2007-11-13 18:02:18 -08:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
static inline ALCsizei NumAttrsForDevice(ALCdevice *device)
|
|
|
|
{
|
2017-12-21 11:46:01 -08:00
|
|
|
if(device->Type == Capture) return 9;
|
2018-01-12 11:34:23 -08:00
|
|
|
if(device->Type != Loopback) return 29;
|
|
|
|
if(device->FmtChans == DevFmtAmbi3D)
|
2017-12-21 11:46:01 -08:00
|
|
|
return 35;
|
|
|
|
return 29;
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
}
|
|
|
|
|
2019-06-17 20:05:38 -07:00
|
|
|
static ALCsizei GetIntegerv(ALCdevice *device, ALCenum param, const al::span<ALCint> values)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2014-02-01 18:40:36 -08:00
|
|
|
ALCsizei i;
|
2011-09-10 05:19:08 -07:00
|
|
|
|
2019-06-17 20:05:38 -07:00
|
|
|
if(values.empty())
|
2010-01-08 01:21:57 -08:00
|
|
|
{
|
|
|
|
alcSetError(device, ALC_INVALID_VALUE);
|
2014-02-01 18:40:36 -08:00
|
|
|
return 0;
|
2010-01-08 01:21:57 -08:00
|
|
|
}
|
|
|
|
|
2011-09-10 05:19:08 -07:00
|
|
|
if(!device)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2011-05-29 23:20:33 -07:00
|
|
|
switch(param)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2011-05-29 23:20:33 -07:00
|
|
|
case ALC_MAJOR_VERSION:
|
2014-02-01 18:40:36 -08:00
|
|
|
values[0] = alcMajorVersion;
|
|
|
|
return 1;
|
2011-05-29 23:20:33 -07:00
|
|
|
case ALC_MINOR_VERSION:
|
2014-02-01 18:40:36 -08:00
|
|
|
values[0] = alcMinorVersion;
|
|
|
|
return 1;
|
2011-05-29 23:20:33 -07:00
|
|
|
|
|
|
|
case ALC_ATTRIBUTES_SIZE:
|
|
|
|
case ALC_ALL_ATTRIBUTES:
|
|
|
|
case ALC_FREQUENCY:
|
|
|
|
case ALC_REFRESH:
|
|
|
|
case ALC_SYNC:
|
|
|
|
case ALC_MONO_SOURCES:
|
|
|
|
case ALC_STEREO_SOURCES:
|
|
|
|
case ALC_CAPTURE_SAMPLES:
|
|
|
|
case ALC_FORMAT_CHANNELS_SOFT:
|
|
|
|
case ALC_FORMAT_TYPE_SOFT:
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
case ALC_AMBISONIC_LAYOUT_SOFT:
|
|
|
|
case ALC_AMBISONIC_SCALING_SOFT:
|
|
|
|
case ALC_AMBISONIC_ORDER_SOFT:
|
2017-09-27 11:58:36 -07:00
|
|
|
case ALC_MAX_AMBISONIC_ORDER_SOFT:
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_DEVICE);
|
2014-02-01 18:40:36 -08:00
|
|
|
return 0;
|
2011-05-29 23:20:33 -07:00
|
|
|
|
|
|
|
default:
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_ENUM);
|
2014-02-01 18:40:36 -08:00
|
|
|
return 0;
|
2011-05-29 23:20:33 -07:00
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
return 0;
|
2011-05-29 23:20:33 -07:00
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
|
|
|
|
if(device->Type == Capture)
|
2011-05-29 23:20:33 -07:00
|
|
|
{
|
|
|
|
switch(param)
|
|
|
|
{
|
2017-12-21 11:46:01 -08:00
|
|
|
case ALC_ATTRIBUTES_SIZE:
|
|
|
|
values[0] = NumAttrsForDevice(device);
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case ALC_ALL_ATTRIBUTES:
|
2018-11-20 23:42:21 -08:00
|
|
|
i = 0;
|
2019-06-17 20:05:38 -07:00
|
|
|
if(values.size() < static_cast<size_t>(NumAttrsForDevice(device)))
|
2017-12-21 11:46:01 -08:00
|
|
|
alcSetError(device, ALC_INVALID_VALUE);
|
2018-11-20 23:42:21 -08:00
|
|
|
else
|
|
|
|
{
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{device->StateLock};
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_MAJOR_VERSION;
|
|
|
|
values[i++] = alcMajorVersion;
|
|
|
|
values[i++] = ALC_MINOR_VERSION;
|
|
|
|
values[i++] = alcMinorVersion;
|
|
|
|
values[i++] = ALC_CAPTURE_SAMPLES;
|
2018-12-28 22:56:20 -08:00
|
|
|
values[i++] = device->Backend->availableSamples();
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_CONNECTED;
|
2018-11-21 07:52:17 -08:00
|
|
|
values[i++] = device->Connected.load(std::memory_order_relaxed);
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = 0;
|
2017-12-21 11:46:01 -08:00
|
|
|
}
|
|
|
|
return i;
|
|
|
|
|
|
|
|
case ALC_MAJOR_VERSION:
|
|
|
|
values[0] = alcMajorVersion;
|
|
|
|
return 1;
|
|
|
|
case ALC_MINOR_VERSION:
|
|
|
|
values[0] = alcMinorVersion;
|
|
|
|
return 1;
|
|
|
|
|
2011-05-29 23:20:33 -07:00
|
|
|
case ALC_CAPTURE_SAMPLES:
|
2018-12-30 21:38:42 -08:00
|
|
|
{ std::lock_guard<std::mutex> _{device->StateLock};
|
2018-12-28 22:56:20 -08:00
|
|
|
values[0] = device->Backend->availableSamples();
|
2018-11-20 23:42:21 -08:00
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
return 1;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-05-29 23:20:33 -07:00
|
|
|
case ALC_CONNECTED:
|
2018-12-30 21:38:42 -08:00
|
|
|
{ std::lock_guard<std::mutex> _{device->StateLock};
|
2018-11-28 12:24:12 -08:00
|
|
|
values[0] = device->Connected.load(std::memory_order_acquire);
|
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
return 1;
|
2009-08-26 19:15:17 -07:00
|
|
|
|
2011-05-29 23:20:33 -07:00
|
|
|
default:
|
|
|
|
alcSetError(device, ALC_INVALID_ENUM);
|
2014-02-01 18:40:36 -08:00
|
|
|
return 0;
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
return 0;
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
|
|
|
|
/* render device */
|
|
|
|
switch(param)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_ATTRIBUTES_SIZE:
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
values[0] = NumAttrsForDevice(device);
|
2014-02-01 18:40:36 -08:00
|
|
|
return 1;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_ALL_ATTRIBUTES:
|
2018-11-20 23:42:21 -08:00
|
|
|
i = 0;
|
2019-06-17 20:05:38 -07:00
|
|
|
if(values.size() < static_cast<size_t>(NumAttrsForDevice(device)))
|
2014-02-01 18:40:36 -08:00
|
|
|
alcSetError(device, ALC_INVALID_VALUE);
|
|
|
|
else
|
|
|
|
{
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{device->StateLock};
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_MAJOR_VERSION;
|
|
|
|
values[i++] = alcMajorVersion;
|
|
|
|
values[i++] = ALC_MINOR_VERSION;
|
|
|
|
values[i++] = alcMinorVersion;
|
|
|
|
values[i++] = ALC_EFX_MAJOR_VERSION;
|
|
|
|
values[i++] = alcEFXMajorVersion;
|
|
|
|
values[i++] = ALC_EFX_MINOR_VERSION;
|
|
|
|
values[i++] = alcEFXMinorVersion;
|
|
|
|
|
|
|
|
values[i++] = ALC_FREQUENCY;
|
|
|
|
values[i++] = device->Frequency;
|
|
|
|
if(device->Type != Loopback)
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
{
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_REFRESH;
|
|
|
|
values[i++] = device->Frequency / device->UpdateSize;
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_SYNC;
|
|
|
|
values[i++] = ALC_FALSE;
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
}
|
2018-11-20 23:42:21 -08:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if(device->FmtChans == DevFmtAmbi3D)
|
|
|
|
{
|
|
|
|
values[i++] = ALC_AMBISONIC_LAYOUT_SOFT;
|
|
|
|
values[i++] = static_cast<ALCint>(device->mAmbiLayout);
|
2011-03-11 00:13:44 -08:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_AMBISONIC_SCALING_SOFT;
|
|
|
|
values[i++] = static_cast<ALCint>(device->mAmbiScale);
|
2017-04-12 18:26:07 -07:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_AMBISONIC_ORDER_SOFT;
|
|
|
|
values[i++] = device->mAmbiOrder;
|
|
|
|
}
|
|
|
|
|
|
|
|
values[i++] = ALC_FORMAT_CHANNELS_SOFT;
|
|
|
|
values[i++] = device->FmtChans;
|
|
|
|
|
|
|
|
values[i++] = ALC_FORMAT_TYPE_SOFT;
|
|
|
|
values[i++] = device->FmtType;
|
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_MONO_SOURCES;
|
|
|
|
values[i++] = device->NumMonoSources;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_STEREO_SOURCES;
|
|
|
|
values[i++] = device->NumStereoSources;
|
2007-12-17 16:55:07 -08:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_MAX_AUXILIARY_SENDS;
|
|
|
|
values[i++] = device->NumAuxSends;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_HRTF_SOFT;
|
2018-12-22 09:20:50 -08:00
|
|
|
values[i++] = (device->mHrtf ? ALC_TRUE : ALC_FALSE);
|
2013-05-31 15:49:56 -07:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_HRTF_STATUS_SOFT;
|
|
|
|
values[i++] = device->HrtfStatus;
|
2017-04-30 08:54:49 -07:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_OUTPUT_LIMITER_SOFT;
|
|
|
|
values[i++] = device->Limiter ? ALC_TRUE : ALC_FALSE;
|
2017-09-27 11:58:36 -07:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = ALC_MAX_AMBISONIC_ORDER_SOFT;
|
|
|
|
values[i++] = MAX_AMBI_ORDER;
|
2015-05-15 23:28:03 -07:00
|
|
|
|
2018-11-20 23:42:21 -08:00
|
|
|
values[i++] = 0;
|
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
return i;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2017-12-21 11:46:01 -08:00
|
|
|
case ALC_MAJOR_VERSION:
|
|
|
|
values[0] = alcMajorVersion;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case ALC_MINOR_VERSION:
|
|
|
|
values[0] = alcMinorVersion;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case ALC_EFX_MAJOR_VERSION:
|
|
|
|
values[0] = alcEFXMajorVersion;
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
case ALC_EFX_MINOR_VERSION:
|
|
|
|
values[0] = alcEFXMinorVersion;
|
|
|
|
return 1;
|
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_FREQUENCY:
|
|
|
|
values[0] = device->Frequency;
|
|
|
|
return 1;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_REFRESH:
|
|
|
|
if(device->Type == Loopback)
|
|
|
|
{
|
|
|
|
alcSetError(device, ALC_INVALID_DEVICE);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-12-30 21:38:42 -08:00
|
|
|
{ std::lock_guard<std::mutex> _{device->StateLock};
|
2018-11-20 23:42:21 -08:00
|
|
|
values[0] = device->Frequency / device->UpdateSize;
|
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
return 1;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_SYNC:
|
|
|
|
if(device->Type == Loopback)
|
|
|
|
{
|
|
|
|
alcSetError(device, ALC_INVALID_DEVICE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
values[0] = ALC_FALSE;
|
|
|
|
return 1;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_FORMAT_CHANNELS_SOFT:
|
|
|
|
if(device->Type != Loopback)
|
|
|
|
{
|
|
|
|
alcSetError(device, ALC_INVALID_DEVICE);
|
|
|
|
return 0;
|
|
|
|
}
|
2017-04-12 18:26:07 -07:00
|
|
|
values[0] = device->FmtChans;
|
2014-02-01 18:40:36 -08:00
|
|
|
return 1;
|
2011-03-11 00:13:44 -08:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_FORMAT_TYPE_SOFT:
|
|
|
|
if(device->Type != Loopback)
|
|
|
|
{
|
|
|
|
alcSetError(device, ALC_INVALID_DEVICE);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
values[0] = device->FmtType;
|
|
|
|
return 1;
|
2011-03-11 00:13:44 -08:00
|
|
|
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
case ALC_AMBISONIC_LAYOUT_SOFT:
|
2017-04-12 18:26:07 -07:00
|
|
|
if(device->Type != Loopback || device->FmtChans != DevFmtAmbi3D)
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
{
|
|
|
|
alcSetError(device, ALC_INVALID_DEVICE);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-20 22:47:24 -08:00
|
|
|
values[0] = static_cast<ALCint>(device->mAmbiLayout);
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
case ALC_AMBISONIC_SCALING_SOFT:
|
2017-04-12 18:26:07 -07:00
|
|
|
if(device->Type != Loopback || device->FmtChans != DevFmtAmbi3D)
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
{
|
|
|
|
alcSetError(device, ALC_INVALID_DEVICE);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-20 22:47:24 -08:00
|
|
|
values[0] = static_cast<ALCint>(device->mAmbiScale);
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
return 1;
|
|
|
|
|
|
|
|
case ALC_AMBISONIC_ORDER_SOFT:
|
2017-04-12 18:26:07 -07:00
|
|
|
if(device->Type != Loopback || device->FmtChans != DevFmtAmbi3D)
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
{
|
|
|
|
alcSetError(device, ALC_INVALID_DEVICE);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-11-18 08:01:50 -08:00
|
|
|
values[0] = device->mAmbiOrder;
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
return 1;
|
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_MONO_SOURCES:
|
|
|
|
values[0] = device->NumMonoSources;
|
|
|
|
return 1;
|
2008-01-10 08:24:23 -08:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_STEREO_SOURCES:
|
|
|
|
values[0] = device->NumStereoSources;
|
|
|
|
return 1;
|
2008-01-10 08:24:23 -08:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_MAX_AUXILIARY_SENDS:
|
|
|
|
values[0] = device->NumAuxSends;
|
|
|
|
return 1;
|
2011-05-29 23:20:33 -07:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_CONNECTED:
|
2018-12-30 21:38:42 -08:00
|
|
|
{ std::lock_guard<std::mutex> _{device->StateLock};
|
2018-11-28 12:24:12 -08:00
|
|
|
values[0] = device->Connected.load(std::memory_order_acquire);
|
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
return 1;
|
2010-07-30 20:23:55 -07:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
case ALC_HRTF_SOFT:
|
2018-12-22 09:20:50 -08:00
|
|
|
values[0] = (device->mHrtf ? ALC_TRUE : ALC_FALSE);
|
2014-02-01 18:40:36 -08:00
|
|
|
return 1;
|
2013-05-31 15:49:56 -07:00
|
|
|
|
2015-05-15 23:28:03 -07:00
|
|
|
case ALC_HRTF_STATUS_SOFT:
|
2017-03-10 10:47:43 -08:00
|
|
|
values[0] = device->HrtfStatus;
|
2015-09-24 10:45:34 -07:00
|
|
|
return 1;
|
2015-05-15 23:28:03 -07:00
|
|
|
|
2015-10-26 22:34:02 -07:00
|
|
|
case ALC_NUM_HRTF_SPECIFIERS_SOFT:
|
2018-12-30 21:38:42 -08:00
|
|
|
{ std::lock_guard<std::mutex> _{device->StateLock};
|
2018-11-20 23:42:21 -08:00
|
|
|
device->HrtfList.clear();
|
|
|
|
device->HrtfList = EnumerateHrtf(device->DeviceName.c_str());
|
2019-06-17 20:05:38 -07:00
|
|
|
values[0] = static_cast<ALCint>(minz(device->HrtfList.size(),
|
|
|
|
std::numeric_limits<ALCint>::max()));
|
2018-11-20 23:42:21 -08:00
|
|
|
}
|
2015-10-02 23:54:30 -07:00
|
|
|
return 1;
|
|
|
|
|
2017-04-30 08:54:49 -07:00
|
|
|
case ALC_OUTPUT_LIMITER_SOFT:
|
2017-05-05 07:38:26 -07:00
|
|
|
values[0] = device->Limiter ? ALC_TRUE : ALC_FALSE;
|
2017-04-30 08:54:49 -07:00
|
|
|
return 1;
|
|
|
|
|
2017-12-21 11:46:01 -08:00
|
|
|
case ALC_MAX_AMBISONIC_ORDER_SOFT:
|
|
|
|
values[0] = MAX_AMBI_ORDER;
|
|
|
|
return 1;
|
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
default:
|
|
|
|
alcSetError(device, ALC_INVALID_ENUM);
|
|
|
|
return 0;
|
2014-02-01 17:55:42 -08:00
|
|
|
}
|
2014-02-01 18:40:36 -08:00
|
|
|
return 0;
|
2014-02-01 17:55:42 -08:00
|
|
|
}
|
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
/* alcGetIntegerv
|
|
|
|
*
|
|
|
|
* Returns information about the device and the version of OpenAL
|
|
|
|
*/
|
|
|
|
ALC_API void ALC_APIENTRY alcGetIntegerv(ALCdevice *device, ALCenum param, ALCsizei size, ALCint *values)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2014-02-01 17:55:42 -08:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
2018-11-14 04:15:44 -08:00
|
|
|
if(size <= 0 || values == nullptr)
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
2014-02-01 18:40:36 -08:00
|
|
|
else
|
2019-06-17 20:05:38 -07:00
|
|
|
GetIntegerv(dev.get(), param, {values, values+size});
|
2014-02-01 18:40:36 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2014-02-01 17:55:42 -08:00
|
|
|
|
2014-02-01 18:40:36 -08:00
|
|
|
ALC_API void ALC_APIENTRY alcGetInteger64vSOFT(ALCdevice *device, ALCenum pname, ALCsizei size, ALCint64SOFT *values)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2014-02-01 18:40:36 -08:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
2018-11-14 04:15:44 -08:00
|
|
|
if(size <= 0 || values == nullptr)
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
|
|
|
else if(!dev || dev->Type == Capture)
|
2014-02-01 17:55:42 -08:00
|
|
|
{
|
2019-06-17 20:05:38 -07:00
|
|
|
auto ivals = al::vector<ALCint>(size);
|
|
|
|
size = GetIntegerv(dev.get(), pname, {ivals.data(), ivals.size()});
|
2018-11-20 23:42:21 -08:00
|
|
|
std::copy(ivals.begin(), ivals.begin()+size, values);
|
2014-02-01 17:55:42 -08:00
|
|
|
}
|
|
|
|
else /* render device */
|
|
|
|
{
|
|
|
|
switch(pname)
|
|
|
|
{
|
|
|
|
case ALC_ATTRIBUTES_SIZE:
|
2018-11-23 17:54:12 -08:00
|
|
|
*values = NumAttrsForDevice(dev.get())+4;
|
2014-02-01 17:55:42 -08:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_ALL_ATTRIBUTES:
|
2018-11-23 17:54:12 -08:00
|
|
|
if(size < NumAttrsForDevice(dev.get())+4)
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
2014-02-01 17:55:42 -08:00
|
|
|
else
|
|
|
|
{
|
2018-11-20 23:42:21 -08:00
|
|
|
ALsizei i{0};
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
2014-02-01 17:55:42 -08:00
|
|
|
values[i++] = ALC_FREQUENCY;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->Frequency;
|
2014-02-01 17:55:42 -08:00
|
|
|
|
2018-11-23 17:54:12 -08:00
|
|
|
if(dev->Type != Loopback)
|
2014-02-01 17:55:42 -08:00
|
|
|
{
|
|
|
|
values[i++] = ALC_REFRESH;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->Frequency / dev->UpdateSize;
|
2014-02-01 17:55:42 -08:00
|
|
|
|
|
|
|
values[i++] = ALC_SYNC;
|
|
|
|
values[i++] = ALC_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
if(dev->FmtChans == DevFmtAmbi3D)
|
2017-03-18 14:33:40 -07:00
|
|
|
{
|
|
|
|
values[i++] = ALC_AMBISONIC_LAYOUT_SOFT;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = static_cast<ALCint64SOFT>(dev->mAmbiLayout);
|
2017-03-18 14:33:40 -07:00
|
|
|
|
|
|
|
values[i++] = ALC_AMBISONIC_SCALING_SOFT;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = static_cast<ALCint64SOFT>(dev->mAmbiScale);
|
2017-03-18 14:33:40 -07:00
|
|
|
|
|
|
|
values[i++] = ALC_AMBISONIC_ORDER_SOFT;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->mAmbiOrder;
|
2017-03-18 14:33:40 -07:00
|
|
|
}
|
2014-02-01 17:55:42 -08:00
|
|
|
|
2017-04-12 18:26:07 -07:00
|
|
|
values[i++] = ALC_FORMAT_CHANNELS_SOFT;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->FmtChans;
|
2017-04-12 18:26:07 -07:00
|
|
|
|
2014-02-01 17:55:42 -08:00
|
|
|
values[i++] = ALC_FORMAT_TYPE_SOFT;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->FmtType;
|
2014-02-01 17:55:42 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
values[i++] = ALC_MONO_SOURCES;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->NumMonoSources;
|
2014-02-01 17:55:42 -08:00
|
|
|
|
|
|
|
values[i++] = ALC_STEREO_SOURCES;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->NumStereoSources;
|
2014-02-01 17:55:42 -08:00
|
|
|
|
|
|
|
values[i++] = ALC_MAX_AUXILIARY_SENDS;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->NumAuxSends;
|
2014-02-01 17:55:42 -08:00
|
|
|
|
|
|
|
values[i++] = ALC_HRTF_SOFT;
|
2018-12-22 09:20:50 -08:00
|
|
|
values[i++] = (dev->mHrtf ? ALC_TRUE : ALC_FALSE);
|
2014-02-01 17:55:42 -08:00
|
|
|
|
2015-05-15 23:28:03 -07:00
|
|
|
values[i++] = ALC_HRTF_STATUS_SOFT;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->HrtfStatus;
|
2015-05-15 23:28:03 -07:00
|
|
|
|
2017-04-30 08:54:49 -07:00
|
|
|
values[i++] = ALC_OUTPUT_LIMITER_SOFT;
|
2018-11-23 17:54:12 -08:00
|
|
|
values[i++] = dev->Limiter ? ALC_TRUE : ALC_FALSE;
|
2017-04-30 08:54:49 -07:00
|
|
|
|
2018-11-23 17:54:12 -08:00
|
|
|
ClockLatency clock{GetClockLatency(dev.get())};
|
2014-02-01 17:55:42 -08:00
|
|
|
values[i++] = ALC_DEVICE_CLOCK_SOFT;
|
2018-11-22 14:32:48 -08:00
|
|
|
values[i++] = clock.ClockTime.count();
|
2016-06-03 09:40:30 -07:00
|
|
|
|
|
|
|
values[i++] = ALC_DEVICE_LATENCY_SOFT;
|
2018-11-22 14:32:48 -08:00
|
|
|
values[i++] = clock.Latency.count();
|
2014-02-01 17:55:42 -08:00
|
|
|
|
|
|
|
values[i++] = 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_DEVICE_CLOCK_SOFT:
|
2018-12-30 21:38:42 -08:00
|
|
|
{ std::lock_guard<std::mutex> _{dev->StateLock};
|
2018-11-23 17:54:12 -08:00
|
|
|
nanoseconds basecount;
|
2018-11-20 23:42:21 -08:00
|
|
|
ALuint samplecount;
|
|
|
|
ALuint refcount;
|
|
|
|
do {
|
2019-08-01 13:28:53 -07:00
|
|
|
while(((refcount=ReadRef(dev->MixCount))&1) != 0)
|
2018-11-26 23:06:49 -08:00
|
|
|
std::this_thread::yield();
|
2018-11-23 17:54:12 -08:00
|
|
|
basecount = dev->ClockBase;
|
|
|
|
samplecount = dev->SamplesDone;
|
2019-08-01 13:28:53 -07:00
|
|
|
} while(refcount != ReadRef(dev->MixCount));
|
2019-03-26 10:18:02 -07:00
|
|
|
basecount += nanoseconds{seconds{samplecount}} / dev->Frequency;
|
|
|
|
*values = basecount.count();
|
2018-11-20 23:42:21 -08:00
|
|
|
}
|
2014-02-01 17:55:42 -08:00
|
|
|
break;
|
|
|
|
|
2016-06-03 09:40:30 -07:00
|
|
|
case ALC_DEVICE_LATENCY_SOFT:
|
2018-12-30 21:38:42 -08:00
|
|
|
{ std::lock_guard<std::mutex> _{dev->StateLock};
|
2018-11-23 17:54:12 -08:00
|
|
|
ClockLatency clock{GetClockLatency(dev.get())};
|
2018-11-22 14:32:48 -08:00
|
|
|
*values = clock.Latency.count();
|
2018-11-20 23:42:21 -08:00
|
|
|
}
|
2016-06-03 09:40:30 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
case ALC_DEVICE_CLOCK_LATENCY_SOFT:
|
|
|
|
if(size < 2)
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
2016-06-03 09:40:30 -07:00
|
|
|
else
|
|
|
|
{
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
2018-11-23 17:54:12 -08:00
|
|
|
ClockLatency clock{GetClockLatency(dev.get())};
|
2018-11-22 14:32:48 -08:00
|
|
|
values[0] = clock.ClockTime.count();
|
|
|
|
values[1] = clock.Latency.count();
|
2016-06-03 09:40:30 -07:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2014-02-01 17:55:42 -08:00
|
|
|
default:
|
2019-06-17 20:05:38 -07:00
|
|
|
auto ivals = al::vector<ALCint>(size);
|
|
|
|
size = GetIntegerv(dev.get(), pname, {ivals.data(), ivals.size()});
|
2018-11-20 23:42:21 -08:00
|
|
|
std::copy(ivals.begin(), ivals.begin()+size, values);
|
2014-02-01 17:55:42 -08:00
|
|
|
break;
|
2011-05-29 23:20:33 -07:00
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcIsExtensionPresent
|
|
|
|
*
|
|
|
|
* Determines if there is support for a particular extension
|
|
|
|
*/
|
2010-03-19 14:34:18 -07:00
|
|
|
ALC_API ALCboolean ALC_APIENTRY alcIsExtensionPresent(ALCdevice *device, const ALCchar *extName)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
2010-03-19 20:49:23 -07:00
|
|
|
if(!extName)
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
2011-09-10 05:19:08 -07:00
|
|
|
else
|
2010-03-19 20:49:23 -07:00
|
|
|
{
|
2011-09-10 05:19:08 -07:00
|
|
|
size_t len = strlen(extName);
|
2018-11-23 17:54:12 -08:00
|
|
|
const char *ptr = (dev ? alcExtensionList : alcNoDeviceExtList);
|
2011-09-10 05:19:08 -07:00
|
|
|
while(ptr && *ptr)
|
2008-01-19 20:02:40 -08:00
|
|
|
{
|
2011-09-10 05:19:08 -07:00
|
|
|
if(strncasecmp(ptr, extName, len) == 0 &&
|
|
|
|
(ptr[len] == '\0' || isspace(ptr[len])))
|
2018-11-23 17:54:12 -08:00
|
|
|
return ALC_TRUE;
|
|
|
|
|
2018-11-14 04:15:44 -08:00
|
|
|
if((ptr=strchr(ptr, ' ')) != nullptr)
|
2011-09-10 05:19:08 -07:00
|
|
|
{
|
|
|
|
do {
|
|
|
|
++ptr;
|
|
|
|
} while(isspace(*ptr));
|
|
|
|
}
|
2008-01-19 20:02:40 -08:00
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2018-11-23 17:54:12 -08:00
|
|
|
return ALC_FALSE;
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcGetProcAddress
|
|
|
|
*
|
|
|
|
* Retrieves the function address for a particular extension function
|
|
|
|
*/
|
2010-03-19 14:34:18 -07:00
|
|
|
ALC_API ALCvoid* ALC_APIENTRY alcGetProcAddress(ALCdevice *device, const ALCchar *funcName)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2010-03-19 20:49:23 -07:00
|
|
|
if(!funcName)
|
2012-06-19 00:25:45 -07:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
2012-06-19 00:25:45 -07:00
|
|
|
}
|
2011-09-10 05:19:08 -07:00
|
|
|
else
|
|
|
|
{
|
2018-11-24 19:16:21 -08:00
|
|
|
for(const auto &func : alcFunctions)
|
2017-03-14 08:37:50 -07:00
|
|
|
{
|
2018-11-24 19:16:21 -08:00
|
|
|
if(strcmp(func.funcName, funcName) == 0)
|
|
|
|
return func.address;
|
2017-03-14 08:37:50 -07:00
|
|
|
}
|
2010-03-19 20:49:23 -07:00
|
|
|
}
|
2018-11-23 17:54:12 -08:00
|
|
|
return nullptr;
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcGetEnumValue
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Get the value for a particular ALC enumeration name
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2010-03-19 14:34:18 -07:00
|
|
|
ALC_API ALCenum ALC_APIENTRY alcGetEnumValue(ALCdevice *device, const ALCchar *enumName)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2010-03-24 22:57:35 -07:00
|
|
|
if(!enumName)
|
2012-04-20 01:24:58 -07:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
2012-04-20 01:24:58 -07:00
|
|
|
}
|
2011-09-10 05:19:08 -07:00
|
|
|
else
|
|
|
|
{
|
2018-11-24 19:16:21 -08:00
|
|
|
for(const auto &enm : alcEnumerations)
|
2017-03-14 08:37:50 -07:00
|
|
|
{
|
2018-11-24 19:16:21 -08:00
|
|
|
if(strcmp(enm.enumName, enumName) == 0)
|
|
|
|
return enm.value;
|
2017-03-14 08:37:50 -07:00
|
|
|
}
|
2010-03-24 22:57:35 -07:00
|
|
|
}
|
2018-11-23 17:54:12 -08:00
|
|
|
return 0;
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcCreateContext
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Create and attach a context to the given device.
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2010-03-19 14:34:18 -07:00
|
|
|
ALC_API ALCcontext* ALC_APIENTRY alcCreateContext(ALCdevice *device, const ALCint *attrList)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-12-30 21:38:42 -08:00
|
|
|
/* Explicitly hold the list lock while taking the StateLock in case the
|
|
|
|
* device is asynchronously destroyed, to ensure this new context is
|
2017-03-28 05:33:43 -07:00
|
|
|
* properly cleaned up after being made.
|
|
|
|
*/
|
2018-11-14 06:17:47 -08:00
|
|
|
std::unique_lock<std::recursive_mutex> listlock{ListLock};
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(!dev || dev->Type == Capture || !dev->Connected.load(std::memory_order_relaxed))
|
2009-09-24 11:31:01 -07:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
listlock.unlock();
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2018-11-14 04:15:44 -08:00
|
|
|
return nullptr;
|
2009-09-24 11:31:01 -07:00
|
|
|
}
|
2018-12-30 21:38:42 -08:00
|
|
|
std::unique_lock<std::mutex> statelock{dev->StateLock};
|
2018-11-14 06:17:47 -08:00
|
|
|
listlock.unlock();
|
2009-09-24 11:31:01 -07:00
|
|
|
|
2018-11-23 17:54:12 -08:00
|
|
|
dev->LastError.store(ALC_NO_ERROR);
|
2009-09-24 11:31:01 -07:00
|
|
|
|
2019-01-01 22:44:46 -08:00
|
|
|
ALCenum err{UpdateDeviceParams(dev.get(), attrList)};
|
|
|
|
if(err != ALC_NO_ERROR)
|
2016-05-15 14:12:56 -07:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), err);
|
2016-05-15 14:12:56 -07:00
|
|
|
if(err == ALC_INVALID_DEVICE)
|
2018-11-23 17:54:12 -08:00
|
|
|
aluHandleDisconnect(dev.get(), "Device update failure");
|
2018-11-14 04:15:44 -08:00
|
|
|
return nullptr;
|
2016-05-15 14:12:56 -07:00
|
|
|
}
|
2019-08-01 19:44:09 -07:00
|
|
|
|
|
|
|
ContextRef context{new ALCcontext{dev}};
|
2019-08-02 18:30:22 -07:00
|
|
|
context->init();
|
2009-09-24 11:31:01 -07:00
|
|
|
|
2019-06-30 16:38:25 -07:00
|
|
|
if(auto volopt = ConfigValueFloat(dev->DeviceName.c_str(), nullptr, "volume-adjust"))
|
2016-09-24 18:46:41 -07:00
|
|
|
{
|
2019-06-30 16:38:25 -07:00
|
|
|
const ALfloat valf{*volopt};
|
2018-11-15 06:48:52 -08:00
|
|
|
if(!std::isfinite(valf))
|
2016-09-24 18:46:41 -07:00
|
|
|
ERR("volume-adjust must be finite: %f\n", valf);
|
|
|
|
else
|
|
|
|
{
|
2019-06-30 16:38:25 -07:00
|
|
|
const ALfloat db{clampf(valf, -24.0f, 24.0f)};
|
2016-09-24 18:46:41 -07:00
|
|
|
if(db != valf)
|
|
|
|
WARN("volume-adjust clamped: %f, range: +/-%f\n", valf, 24.0f);
|
2019-07-30 09:05:54 -07:00
|
|
|
context->mGainBoost = std::pow(10.0f, db/20.0f);
|
|
|
|
TRACE("volume-adjust gain: %f\n", context->mGainBoost);
|
2016-09-24 18:46:41 -07:00
|
|
|
}
|
|
|
|
}
|
2019-03-19 18:53:32 -07:00
|
|
|
UpdateListenerProps(context.get());
|
2016-09-24 18:46:41 -07:00
|
|
|
|
2014-08-01 02:04:40 -07:00
|
|
|
{
|
2019-06-29 21:32:36 -07:00
|
|
|
using ContextArray = al::FlexArray<ALCcontext*>;
|
|
|
|
|
|
|
|
/* Allocate a new context array, which holds 1 more than the current/
|
|
|
|
* old array.
|
|
|
|
*/
|
|
|
|
auto *oldarray = device->mContexts.load();
|
|
|
|
const size_t newcount{oldarray->size()+1};
|
2019-08-03 14:59:01 -07:00
|
|
|
std::unique_ptr<ContextArray> newarray{ContextArray::Create(newcount)};
|
2019-06-29 21:32:36 -07:00
|
|
|
|
|
|
|
/* Copy the current/old context handles to the new array, appending the
|
|
|
|
* new context.
|
|
|
|
*/
|
|
|
|
auto iter = std::copy(oldarray->begin(), oldarray->end(), newarray->begin());
|
|
|
|
*iter = context.get();
|
|
|
|
|
|
|
|
/* Store the new context array in the device. Wait for any current mix
|
|
|
|
* to finish before deleting the old array.
|
|
|
|
*/
|
2019-08-02 18:30:22 -07:00
|
|
|
dev->mContexts.store(newarray.release());
|
2019-06-29 21:32:36 -07:00
|
|
|
if(oldarray != &EmptyContextArray)
|
2019-03-19 18:53:32 -07:00
|
|
|
{
|
2019-06-29 21:32:36 -07:00
|
|
|
while((dev->MixCount.load(std::memory_order_acquire)&1))
|
|
|
|
std::this_thread::yield();
|
|
|
|
delete oldarray;
|
2019-03-19 18:53:32 -07:00
|
|
|
}
|
2014-08-01 02:04:40 -07:00
|
|
|
}
|
2018-12-30 21:38:42 -08:00
|
|
|
statelock.unlock();
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-06-29 21:32:36 -07:00
|
|
|
{
|
|
|
|
std::lock_guard<std::recursive_mutex> _{ListLock};
|
|
|
|
auto iter = std::lower_bound(ContextList.cbegin(), ContextList.cend(), context.get());
|
2019-08-03 12:14:50 -07:00
|
|
|
ContextList.emplace(iter, context);
|
2019-06-29 21:32:36 -07:00
|
|
|
}
|
|
|
|
|
2019-07-30 09:05:54 -07:00
|
|
|
if(context->mDefaultSlot)
|
2017-07-19 18:26:46 -07:00
|
|
|
{
|
2019-07-30 09:05:54 -07:00
|
|
|
if(InitializeEffect(context.get(), context->mDefaultSlot.get(), &DefaultEffect) == AL_NO_ERROR)
|
|
|
|
UpdateEffectSlotProps(context->mDefaultSlot.get(), context.get());
|
2017-07-19 18:26:46 -07:00
|
|
|
else
|
|
|
|
ERR("Failed to initialize the default effect\n");
|
|
|
|
}
|
|
|
|
|
2019-03-19 18:53:32 -07:00
|
|
|
TRACE("Created context %p\n", context.get());
|
|
|
|
return context.get();
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcDestroyContext
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Remove a context from its device
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2010-03-19 14:34:18 -07:00
|
|
|
ALC_API ALCvoid ALC_APIENTRY alcDestroyContext(ALCcontext *context)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
std::unique_lock<std::recursive_mutex> listlock{ListLock};
|
2019-06-29 22:38:38 -07:00
|
|
|
auto iter = std::lower_bound(ContextList.begin(), ContextList.end(), context);
|
|
|
|
if(iter == ContextList.end() || *iter != context)
|
2017-03-28 05:33:43 -07:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
listlock.unlock();
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_CONTEXT);
|
2017-03-28 05:33:43 -07:00
|
|
|
return;
|
|
|
|
}
|
2019-03-19 18:53:32 -07:00
|
|
|
/* Hold an extra reference to this context so it remains valid until the
|
|
|
|
* ListLock is released.
|
|
|
|
*/
|
2019-06-29 22:38:38 -07:00
|
|
|
ContextRef ctx{std::move(*iter)};
|
2019-03-19 18:53:32 -07:00
|
|
|
ContextList.erase(iter);
|
2017-03-28 05:33:43 -07:00
|
|
|
|
2019-08-01 19:44:09 -07:00
|
|
|
ALCdevice *Device{ctx->mDevice.get()};
|
2019-06-29 22:38:38 -07:00
|
|
|
|
|
|
|
std::lock_guard<std::mutex> _{Device->StateLock};
|
2019-08-02 18:30:22 -07:00
|
|
|
if(!ctx->deinit() && Device->Flags.get<DeviceRunning>())
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2019-06-29 22:38:38 -07:00
|
|
|
Device->Backend->stop();
|
|
|
|
Device->Flags.unset<DeviceRunning>();
|
2011-06-15 01:59:07 -07:00
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcGetCurrentContext
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Returns the currently active context on the calling thread
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2012-04-20 01:18:38 -07:00
|
|
|
ALC_API ALCcontext* ALC_APIENTRY alcGetCurrentContext(void)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2009-09-12 16:45:46 -07:00
|
|
|
{
|
2018-11-16 21:55:11 -08:00
|
|
|
ALCcontext *Context{LocalContext.get()};
|
2018-11-14 06:17:47 -08:00
|
|
|
if(!Context) Context = GlobalContext.load();
|
2011-06-15 23:22:34 -07:00
|
|
|
return Context;
|
2009-09-12 16:45:46 -07:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2009-09-12 16:45:46 -07:00
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcGetThreadContext
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Returns the currently active thread-local context
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2010-03-23 17:44:01 -07:00
|
|
|
ALC_API ALCcontext* ALC_APIENTRY alcGetThreadContext(void)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
|
|
|
{ return LocalContext.get(); }
|
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcMakeContextCurrent
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Makes the given context the active process-wide context, and removes the
|
|
|
|
* thread-local context for the calling thread.
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2010-03-19 14:34:18 -07:00
|
|
|
ALC_API ALCboolean ALC_APIENTRY alcMakeContextCurrent(ALCcontext *context)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
/* context must be valid or nullptr */
|
2018-11-21 02:02:53 -08:00
|
|
|
ContextRef ctx;
|
|
|
|
if(context)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-21 02:02:53 -08:00
|
|
|
ctx = VerifyContext(context);
|
|
|
|
if(!ctx)
|
|
|
|
{
|
|
|
|
alcSetError(nullptr, ALC_INVALID_CONTEXT);
|
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2018-11-21 02:02:53 -08:00
|
|
|
/* Release this reference (if any) to store it in the GlobalContext
|
|
|
|
* pointer. Take ownership of the reference (if any) that was previously
|
|
|
|
* stored there.
|
|
|
|
*/
|
|
|
|
ctx = ContextRef{GlobalContext.exchange(ctx.release())};
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-21 02:02:53 -08:00
|
|
|
/* Reset (decrement) the previous global reference by replacing it with the
|
|
|
|
* thread-local context. Take ownership of the thread-local context
|
|
|
|
* reference (if any), clearing the storage to null.
|
|
|
|
*/
|
|
|
|
ctx = ContextRef{LocalContext.get()};
|
|
|
|
if(ctx) LocalContext.set(nullptr);
|
|
|
|
/* Reset (decrement) the previous thread-local reference. */
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-09-12 03:18:27 -07:00
|
|
|
return ALC_TRUE;
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcSetThreadContext
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Makes the given context the active context for the current thread
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2010-03-23 19:49:31 -07:00
|
|
|
ALC_API ALCboolean ALC_APIENTRY alcSetThreadContext(ALCcontext *context)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2009-09-12 16:45:46 -07:00
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
/* context must be valid or nullptr */
|
2018-11-21 02:02:53 -08:00
|
|
|
ContextRef ctx;
|
|
|
|
if(context)
|
2011-08-28 18:08:48 -07:00
|
|
|
{
|
2018-11-21 02:02:53 -08:00
|
|
|
ctx = VerifyContext(context);
|
|
|
|
if(!ctx)
|
|
|
|
{
|
|
|
|
alcSetError(nullptr, ALC_INVALID_CONTEXT);
|
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
2011-08-28 18:08:48 -07:00
|
|
|
}
|
2011-09-12 03:18:27 -07:00
|
|
|
/* context's reference count is already incremented */
|
2018-11-21 02:02:53 -08:00
|
|
|
ContextRef old{LocalContext.get()};
|
|
|
|
LocalContext.set(ctx.release());
|
2009-09-12 16:45:46 -07:00
|
|
|
|
2011-09-12 03:18:27 -07:00
|
|
|
return ALC_TRUE;
|
2009-09-12 16:45:46 -07:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2009-09-12 16:45:46 -07:00
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcGetContextsDevice
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Returns the device that a particular context is attached to
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2011-09-12 03:18:27 -07:00
|
|
|
ALC_API ALCdevice* ALC_APIENTRY alcGetContextsDevice(ALCcontext *Context)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2011-09-10 19:14:14 -07:00
|
|
|
{
|
2018-11-21 02:02:53 -08:00
|
|
|
ContextRef ctx{VerifyContext(Context)};
|
|
|
|
if(!ctx)
|
2011-09-12 03:18:27 -07:00
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_CONTEXT);
|
|
|
|
return nullptr;
|
2011-09-12 03:18:27 -07:00
|
|
|
}
|
2019-08-01 19:44:09 -07:00
|
|
|
return ctx->mDevice.get();
|
2011-09-10 19:14:14 -07:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2011-09-10 19:14:14 -07:00
|
|
|
|
|
|
|
|
|
|
|
/* alcOpenDevice
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Opens the named device.
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2010-03-19 14:34:18 -07:00
|
|
|
ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2011-06-14 09:43:33 -07:00
|
|
|
DO_INITCONFIG();
|
|
|
|
|
2019-06-28 18:54:31 -07:00
|
|
|
if(!PlaybackFactory)
|
2011-08-19 02:55:36 -07:00
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_VALUE);
|
|
|
|
return nullptr;
|
2011-08-19 02:55:36 -07:00
|
|
|
}
|
|
|
|
|
2015-08-13 21:18:39 -07:00
|
|
|
if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0
|
|
|
|
#ifdef _WIN32
|
2015-08-14 17:02:11 -07:00
|
|
|
/* Some old Windows apps hardcode these expecting OpenAL to use a
|
|
|
|
* specific audio API, even when they're not enumerated. Creative's
|
|
|
|
* router effectively ignores them too.
|
2015-08-13 21:18:39 -07:00
|
|
|
*/
|
2015-08-14 17:02:11 -07:00
|
|
|
|| strcasecmp(deviceName, "DirectSound3D") == 0 || strcasecmp(deviceName, "DirectSound") == 0
|
|
|
|
|| strcasecmp(deviceName, "MMSYSTEM") == 0
|
2015-08-13 21:18:39 -07:00
|
|
|
#endif
|
|
|
|
))
|
2018-11-14 04:15:44 -08:00
|
|
|
deviceName = nullptr;
|
2007-12-26 17:38:42 -08:00
|
|
|
|
2019-01-01 22:44:46 -08:00
|
|
|
DeviceRef device{new ALCdevice{Playback}};
|
2017-02-28 21:01:13 -08:00
|
|
|
|
2019-04-20 19:29:33 -07:00
|
|
|
/* Set output format */
|
2012-03-13 15:32:44 -07:00
|
|
|
device->FmtChans = DevFmtChannelsDefault;
|
|
|
|
device->FmtType = DevFmtTypeDefault;
|
2012-02-15 15:22:44 -08:00
|
|
|
device->Frequency = DEFAULT_OUTPUT_RATE;
|
2018-12-18 09:27:00 -08:00
|
|
|
device->UpdateSize = DEFAULT_UPDATE_SIZE;
|
2019-04-26 15:58:25 -07:00
|
|
|
device->BufferSize = DEFAULT_UPDATE_SIZE * DEFAULT_NUM_UPDATES;
|
2011-09-18 16:16:55 -07:00
|
|
|
|
2018-01-28 18:03:54 -08:00
|
|
|
device->SourcesMax = 256;
|
|
|
|
device->AuxiliaryEffectSlotMax = 64;
|
|
|
|
device->NumAuxSends = DEFAULT_SENDS;
|
2013-10-27 14:24:55 -07:00
|
|
|
|
2019-05-04 18:03:25 -07:00
|
|
|
try {
|
|
|
|
/* Create the device backend. */
|
2019-06-28 18:54:31 -07:00
|
|
|
device->Backend = PlaybackFactory->createBackend(device.get(), BackendType::Playback);
|
2019-05-04 18:03:25 -07:00
|
|
|
|
|
|
|
/* Find a playback device to open */
|
|
|
|
ALCenum err{device->Backend->open(deviceName)};
|
|
|
|
if(err != ALC_NO_ERROR)
|
|
|
|
{
|
|
|
|
alcSetError(nullptr, err);
|
|
|
|
return nullptr;
|
|
|
|
}
|
2019-04-20 19:29:33 -07:00
|
|
|
}
|
2019-05-04 18:03:25 -07:00
|
|
|
catch(al::backend_exception &e) {
|
|
|
|
WARN("Failed to open playback device: %s\n", e.what());
|
|
|
|
alcSetError(nullptr, e.errorCode());
|
2019-04-20 19:29:33 -07:00
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
deviceName = device->DeviceName.c_str();
|
2019-06-30 16:15:15 -07:00
|
|
|
if(auto chanopt = ConfigValueStr(deviceName, nullptr, "channels"))
|
2012-02-15 15:22:44 -08:00
|
|
|
{
|
2018-11-16 05:23:42 -08:00
|
|
|
static constexpr struct ChannelMap {
|
2012-02-15 15:22:44 -08:00
|
|
|
const char name[16];
|
2018-12-24 19:29:01 -08:00
|
|
|
DevFmtChannels chans;
|
2017-04-12 18:26:07 -07:00
|
|
|
ALsizei order;
|
2012-02-15 15:22:44 -08:00
|
|
|
} chanlist[] = {
|
2017-04-12 18:26:07 -07:00
|
|
|
{ "mono", DevFmtMono, 0 },
|
|
|
|
{ "stereo", DevFmtStereo, 0 },
|
|
|
|
{ "quad", DevFmtQuad, 0 },
|
|
|
|
{ "surround51", DevFmtX51, 0 },
|
|
|
|
{ "surround61", DevFmtX61, 0 },
|
|
|
|
{ "surround71", DevFmtX71, 0 },
|
|
|
|
{ "surround51rear", DevFmtX51Rear, 0 },
|
|
|
|
{ "ambi1", DevFmtAmbi3D, 1 },
|
|
|
|
{ "ambi2", DevFmtAmbi3D, 2 },
|
|
|
|
{ "ambi3", DevFmtAmbi3D, 3 },
|
2012-02-15 15:22:44 -08:00
|
|
|
};
|
|
|
|
|
2019-06-30 16:15:15 -07:00
|
|
|
const ALCchar *fmt{chanopt->c_str()};
|
2018-11-16 05:23:42 -08:00
|
|
|
auto iter = std::find_if(std::begin(chanlist), std::end(chanlist),
|
|
|
|
[fmt](const ChannelMap &entry) -> bool
|
|
|
|
{ return strcasecmp(entry.name, fmt) == 0; }
|
|
|
|
);
|
|
|
|
if(iter == std::end(chanlist))
|
|
|
|
ERR("Unsupported channels: %s\n", fmt);
|
|
|
|
else
|
2012-02-15 15:22:44 -08:00
|
|
|
{
|
2018-11-16 05:23:42 -08:00
|
|
|
device->FmtChans = iter->chans;
|
2018-11-18 08:01:50 -08:00
|
|
|
device->mAmbiOrder = iter->order;
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.set<ChannelsRequest>();
|
2012-02-15 15:22:44 -08:00
|
|
|
}
|
|
|
|
}
|
2019-06-30 16:15:15 -07:00
|
|
|
if(auto typeopt = ConfigValueStr(deviceName, nullptr, "sample-type"))
|
2012-02-15 15:22:44 -08:00
|
|
|
{
|
2018-11-16 05:23:42 -08:00
|
|
|
static constexpr struct TypeMap {
|
2012-02-15 15:22:44 -08:00
|
|
|
const char name[16];
|
2018-12-24 19:29:01 -08:00
|
|
|
DevFmtType type;
|
2012-02-19 11:56:01 -08:00
|
|
|
} typelist[] = {
|
2012-02-15 15:22:44 -08:00
|
|
|
{ "int8", DevFmtByte },
|
|
|
|
{ "uint8", DevFmtUByte },
|
|
|
|
{ "int16", DevFmtShort },
|
|
|
|
{ "uint16", DevFmtUShort },
|
|
|
|
{ "int32", DevFmtInt },
|
|
|
|
{ "uint32", DevFmtUInt },
|
|
|
|
{ "float32", DevFmtFloat },
|
|
|
|
};
|
|
|
|
|
2019-06-30 16:15:15 -07:00
|
|
|
const ALCchar *fmt{typeopt->c_str()};
|
2018-11-16 05:23:42 -08:00
|
|
|
auto iter = std::find_if(std::begin(typelist), std::end(typelist),
|
|
|
|
[fmt](const TypeMap &entry) -> bool
|
|
|
|
{ return strcasecmp(entry.name, fmt) == 0; }
|
|
|
|
);
|
|
|
|
if(iter == std::end(typelist))
|
|
|
|
ERR("Unsupported sample-type: %s\n", fmt);
|
|
|
|
else
|
2012-02-15 15:22:44 -08:00
|
|
|
{
|
2018-11-16 05:23:42 -08:00
|
|
|
device->FmtType = iter->type;
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.set<SampleTypeRequest>();
|
2012-02-15 15:22:44 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
if(ALuint freq{ConfigValueUInt(deviceName, nullptr, "frequency").value_or(0)})
|
2012-02-15 12:26:19 -08:00
|
|
|
{
|
2018-12-18 09:27:00 -08:00
|
|
|
if(freq < MIN_OUTPUT_RATE)
|
|
|
|
{
|
|
|
|
ERR("%uhz request clamped to %uhz minimum\n", freq, MIN_OUTPUT_RATE);
|
|
|
|
freq = MIN_OUTPUT_RATE;
|
|
|
|
}
|
2019-04-26 18:04:22 -07:00
|
|
|
device->UpdateSize = (device->UpdateSize*freq + device->Frequency/2) / device->Frequency;
|
2019-04-26 15:58:25 -07:00
|
|
|
device->BufferSize = (device->BufferSize*freq + device->Frequency/2) / device->Frequency;
|
2018-12-18 09:27:00 -08:00
|
|
|
device->Frequency = freq;
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.set<FrequencyRequest>();
|
2012-02-15 12:26:19 -08:00
|
|
|
}
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
if(auto persizeopt = ConfigValueUInt(deviceName, nullptr, "period_size"))
|
|
|
|
device->UpdateSize = clampu(*persizeopt, 64, 8192);
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
if(auto peropt = ConfigValueUInt(deviceName, nullptr, "periods"))
|
|
|
|
device->BufferSize = device->UpdateSize * clampu(*peropt, 2, 16);
|
2019-04-26 15:58:25 -07:00
|
|
|
else
|
|
|
|
device->BufferSize = maxu(device->BufferSize, device->UpdateSize*2);
|
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
if(auto srcsopt = ConfigValueUInt(deviceName, nullptr, "sources"))
|
|
|
|
{
|
|
|
|
if(*srcsopt > 0) device->SourcesMax = *srcsopt;
|
|
|
|
}
|
2008-01-19 19:28:34 -08:00
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
if(auto slotsopt = ConfigValueUInt(deviceName, nullptr, "slots"))
|
|
|
|
{
|
|
|
|
if(*slotsopt > 0)
|
|
|
|
device->AuxiliaryEffectSlotMax = minu(*slotsopt, INT_MAX);
|
|
|
|
}
|
2009-06-07 14:53:22 -07:00
|
|
|
|
2019-06-30 12:00:10 -07:00
|
|
|
if(auto sendsopt = ConfigValueInt(deviceName, nullptr, "sends"))
|
|
|
|
device->NumAuxSends = clampi(DEFAULT_SENDS, 0, clampi(*sendsopt, 0, MAX_SENDS));
|
2009-07-06 03:09:01 -07:00
|
|
|
|
2011-09-18 16:16:55 -07:00
|
|
|
device->NumStereoSources = 1;
|
2016-06-08 11:19:33 -07:00
|
|
|
device->NumMonoSources = device->SourcesMax - device->NumStereoSources;
|
2009-09-15 19:06:47 -07:00
|
|
|
|
2019-06-30 16:15:15 -07:00
|
|
|
if(auto ambiopt = ConfigValueStr(deviceName, nullptr, "ambi-format"))
|
2016-07-31 07:46:38 -07:00
|
|
|
{
|
2019-06-30 16:15:15 -07:00
|
|
|
const ALCchar *fmt{ambiopt->c_str()};
|
2016-07-31 07:46:38 -07:00
|
|
|
if(strcasecmp(fmt, "fuma") == 0)
|
2017-02-27 16:11:45 -08:00
|
|
|
{
|
2018-12-19 02:55:21 -08:00
|
|
|
if(device->mAmbiOrder > 3)
|
|
|
|
ERR("FuMa is incompatible with %d%s order ambisonics (up to third-order only)\n",
|
|
|
|
device->mAmbiOrder,
|
|
|
|
(((device->mAmbiOrder%100)/10) == 1) ? "th" :
|
|
|
|
((device->mAmbiOrder%10) == 1) ? "st" :
|
|
|
|
((device->mAmbiOrder%10) == 2) ? "nd" :
|
|
|
|
((device->mAmbiOrder%10) == 3) ? "rd" : "th");
|
|
|
|
else
|
|
|
|
{
|
|
|
|
device->mAmbiLayout = AmbiLayout::FuMa;
|
|
|
|
device->mAmbiScale = AmbiNorm::FuMa;
|
|
|
|
}
|
2017-02-27 16:11:45 -08:00
|
|
|
}
|
2018-12-27 01:18:10 -08:00
|
|
|
else if(strcasecmp(fmt, "ambix") == 0 || strcasecmp(fmt, "acn+sn3d") == 0)
|
2017-02-27 16:11:45 -08:00
|
|
|
{
|
2018-11-20 22:47:24 -08:00
|
|
|
device->mAmbiLayout = AmbiLayout::ACN;
|
|
|
|
device->mAmbiScale = AmbiNorm::SN3D;
|
2017-02-27 16:11:45 -08:00
|
|
|
}
|
2016-07-31 07:46:38 -07:00
|
|
|
else if(strcasecmp(fmt, "acn+n3d") == 0)
|
2017-02-27 16:11:45 -08:00
|
|
|
{
|
2018-11-20 22:47:24 -08:00
|
|
|
device->mAmbiLayout = AmbiLayout::ACN;
|
|
|
|
device->mAmbiScale = AmbiNorm::N3D;
|
2017-02-27 16:11:45 -08:00
|
|
|
}
|
2016-07-31 07:46:38 -07:00
|
|
|
else
|
|
|
|
ERR("Unsupported ambi-format: %s\n", fmt);
|
|
|
|
}
|
|
|
|
|
2014-08-01 02:04:40 -07:00
|
|
|
{
|
2019-03-19 15:41:01 -07:00
|
|
|
std::lock_guard<std::recursive_mutex> _{ListLock};
|
|
|
|
auto iter = std::lower_bound(DeviceList.cbegin(), DeviceList.cend(), device.get());
|
2019-08-03 12:14:50 -07:00
|
|
|
DeviceList.emplace(iter, device);
|
2014-08-01 02:04:40 -07:00
|
|
|
}
|
2011-09-12 03:57:53 -07:00
|
|
|
|
2018-11-23 20:16:34 -08:00
|
|
|
TRACE("Created device %p, \"%s\"\n", device.get(), device->DeviceName.c_str());
|
2019-01-01 22:44:46 -08:00
|
|
|
return device.get();
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcCloseDevice
|
|
|
|
*
|
2012-04-20 01:18:38 -07:00
|
|
|
* Closes the given device.
|
2011-09-10 19:14:14 -07:00
|
|
|
*/
|
2014-08-01 02:04:40 -07:00
|
|
|
ALC_API ALCboolean ALC_APIENTRY alcCloseDevice(ALCdevice *device)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
std::unique_lock<std::recursive_mutex> listlock{ListLock};
|
2019-06-29 22:38:38 -07:00
|
|
|
auto iter = std::lower_bound(DeviceList.begin(), DeviceList.end(), device);
|
|
|
|
if(iter == DeviceList.end() || *iter != device)
|
2007-11-13 18:02:18 -08:00
|
|
|
{
|
2019-03-19 15:41:01 -07:00
|
|
|
alcSetError(nullptr, ALC_INVALID_DEVICE);
|
2010-03-19 20:49:23 -07:00
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
2019-03-19 15:41:01 -07:00
|
|
|
if((*iter)->Type == Capture)
|
2014-08-01 02:04:40 -07:00
|
|
|
{
|
2019-06-29 22:38:38 -07:00
|
|
|
alcSetError(iter->get(), ALC_INVALID_DEVICE);
|
2019-03-19 15:41:01 -07:00
|
|
|
return ALC_FALSE;
|
2014-08-01 02:04:40 -07:00
|
|
|
}
|
2019-03-19 15:41:01 -07:00
|
|
|
|
2019-03-19 18:53:32 -07:00
|
|
|
/* Erase the device, and any remaining contexts left on it, from their
|
|
|
|
* respective lists.
|
|
|
|
*/
|
2019-06-29 22:38:38 -07:00
|
|
|
DeviceRef dev{std::move(*iter)};
|
2019-03-19 15:41:01 -07:00
|
|
|
DeviceList.erase(iter);
|
2019-06-29 22:38:38 -07:00
|
|
|
|
|
|
|
std::unique_lock<std::mutex> statelock{dev->StateLock};
|
|
|
|
al::vector<ContextRef> orphanctxs;
|
|
|
|
for(ALCcontext *ctx : *dev->mContexts.load())
|
2019-03-19 18:53:32 -07:00
|
|
|
{
|
2019-06-29 22:38:38 -07:00
|
|
|
auto iter = std::lower_bound(ContextList.begin(), ContextList.end(), ctx);
|
|
|
|
if(iter != ContextList.end() && *iter == ctx)
|
|
|
|
{
|
|
|
|
orphanctxs.emplace_back(std::move(*iter));
|
2019-03-19 18:53:32 -07:00
|
|
|
ContextList.erase(iter);
|
2019-06-29 22:38:38 -07:00
|
|
|
}
|
2019-03-19 18:53:32 -07:00
|
|
|
}
|
2018-11-14 06:17:47 -08:00
|
|
|
listlock.unlock();
|
2010-03-19 20:49:23 -07:00
|
|
|
|
2019-06-29 22:38:38 -07:00
|
|
|
for(ContextRef &context : orphanctxs)
|
2010-03-19 20:49:23 -07:00
|
|
|
{
|
2019-08-02 18:30:22 -07:00
|
|
|
WARN("Releasing orphaned context %p\n", context.get());
|
|
|
|
context->deinit();
|
2011-09-10 19:14:14 -07:00
|
|
|
}
|
2019-06-29 22:38:38 -07:00
|
|
|
orphanctxs.clear();
|
2012-03-02 00:10:24 -08:00
|
|
|
|
2019-06-29 22:38:38 -07:00
|
|
|
if(dev->Flags.get<DeviceRunning>())
|
|
|
|
dev->Backend->stop();
|
|
|
|
dev->Flags.unset<DeviceRunning>();
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2010-03-19 20:49:23 -07:00
|
|
|
return ALC_TRUE;
|
2007-11-13 18:02:18 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2008-01-14 10:54:33 -08:00
|
|
|
|
|
|
|
|
2012-04-20 01:18:38 -07:00
|
|
|
/************************************************
|
|
|
|
* ALC capture functions
|
|
|
|
************************************************/
|
|
|
|
ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, ALCuint frequency, ALCenum format, ALCsizei samples)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
|
|
|
DO_INITCONFIG();
|
|
|
|
|
2019-06-28 18:54:31 -07:00
|
|
|
if(!CaptureFactory)
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_VALUE);
|
|
|
|
return nullptr;
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if(samples <= 0)
|
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_VALUE);
|
|
|
|
return nullptr;
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0))
|
2018-11-14 04:15:44 -08:00
|
|
|
deviceName = nullptr;
|
2012-04-20 01:18:38 -07:00
|
|
|
|
2019-01-01 22:44:46 -08:00
|
|
|
DeviceRef device{new ALCdevice{Capture}};
|
2015-10-06 00:23:11 -07:00
|
|
|
|
2019-06-30 16:57:10 -07:00
|
|
|
auto decompfmt = DecomposeDevFormat(format);
|
|
|
|
if(!decompfmt)
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_ENUM);
|
|
|
|
return nullptr;
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
2019-06-30 16:57:10 -07:00
|
|
|
|
|
|
|
device->Frequency = frequency;
|
|
|
|
device->FmtChans = decompfmt->chans;
|
|
|
|
device->FmtType = decompfmt->type;
|
2019-06-09 02:20:30 -07:00
|
|
|
device->Flags.set<FrequencyRequest, ChannelsRequest, SampleTypeRequest>();
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
device->UpdateSize = samples;
|
2019-04-26 15:58:25 -07:00
|
|
|
device->BufferSize = samples;
|
2012-04-20 01:18:38 -07:00
|
|
|
|
2019-05-04 18:03:25 -07:00
|
|
|
try {
|
2019-06-28 18:54:31 -07:00
|
|
|
device->Backend = CaptureFactory->createBackend(device.get(), BackendType::Capture);
|
2018-01-28 18:03:54 -08:00
|
|
|
|
2019-05-04 18:03:25 -07:00
|
|
|
TRACE("Capture format: %s, %s, %uhz, %u / %u buffer\n",
|
|
|
|
DevFmtChannelsString(device->FmtChans), DevFmtTypeString(device->FmtType),
|
|
|
|
device->Frequency, device->UpdateSize, device->BufferSize);
|
|
|
|
ALCenum err{device->Backend->open(deviceName)};
|
|
|
|
if(err != ALC_NO_ERROR)
|
|
|
|
{
|
|
|
|
alcSetError(nullptr, err);
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch(al::backend_exception &e) {
|
|
|
|
WARN("Failed to open capture device: %s\n", e.what());
|
|
|
|
alcSetError(nullptr, e.errorCode());
|
2018-11-14 04:15:44 -08:00
|
|
|
return nullptr;
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
|
|
|
|
2014-08-01 02:04:40 -07:00
|
|
|
{
|
2019-03-19 15:41:01 -07:00
|
|
|
std::lock_guard<std::recursive_mutex> _{ListLock};
|
|
|
|
auto iter = std::lower_bound(DeviceList.cbegin(), DeviceList.cend(), device.get());
|
2019-08-03 12:14:50 -07:00
|
|
|
DeviceList.emplace(iter, device);
|
2014-08-01 02:04:40 -07:00
|
|
|
}
|
2012-04-20 01:18:38 -07:00
|
|
|
|
2018-11-23 20:16:34 -08:00
|
|
|
TRACE("Created device %p, \"%s\"\n", device.get(), device->DeviceName.c_str());
|
2019-01-01 22:44:46 -08:00
|
|
|
return device.get();
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
|
2014-08-01 02:04:40 -07:00
|
|
|
ALC_API ALCboolean ALC_APIENTRY alcCaptureCloseDevice(ALCdevice *device)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
std::unique_lock<std::recursive_mutex> listlock{ListLock};
|
2019-06-29 22:38:38 -07:00
|
|
|
auto iter = std::lower_bound(DeviceList.begin(), DeviceList.end(), device);
|
|
|
|
if(iter == DeviceList.end() || *iter != device)
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
2019-03-19 15:41:01 -07:00
|
|
|
alcSetError(nullptr, ALC_INVALID_DEVICE);
|
2012-04-20 01:18:38 -07:00
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
2019-03-19 15:41:01 -07:00
|
|
|
if((*iter)->Type != Capture)
|
2014-08-01 02:04:40 -07:00
|
|
|
{
|
2019-06-29 22:38:38 -07:00
|
|
|
alcSetError(iter->get(), ALC_INVALID_DEVICE);
|
2019-03-19 15:41:01 -07:00
|
|
|
return ALC_FALSE;
|
2014-08-01 02:04:40 -07:00
|
|
|
}
|
2019-03-19 15:41:01 -07:00
|
|
|
|
2019-06-29 22:38:38 -07:00
|
|
|
DeviceRef dev{std::move(*iter)};
|
2019-03-19 15:41:01 -07:00
|
|
|
DeviceList.erase(iter);
|
2018-11-14 06:17:47 -08:00
|
|
|
listlock.unlock();
|
2012-04-20 01:18:38 -07:00
|
|
|
|
2019-06-29 22:38:38 -07:00
|
|
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
|
|
|
if(dev->Flags.get<DeviceRunning>())
|
|
|
|
dev->Backend->stop();
|
|
|
|
dev->Flags.unset<DeviceRunning>();
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
return ALC_TRUE;
|
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
ALC_API void ALC_APIENTRY alcCaptureStart(ALCdevice *device)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(!dev || dev->Type != Capture)
|
|
|
|
{
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
2018-11-23 17:54:12 -08:00
|
|
|
if(!dev->Connected.load(std::memory_order_acquire))
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2019-06-09 02:20:30 -07:00
|
|
|
else if(!dev->Flags.get<DeviceRunning>())
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
2018-12-28 22:56:20 -08:00
|
|
|
if(dev->Backend->start())
|
2019-06-09 02:20:30 -07:00
|
|
|
dev->Flags.set<DeviceRunning>();
|
2018-11-23 17:54:12 -08:00
|
|
|
else
|
2012-10-07 00:13:23 -07:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
aluHandleDisconnect(dev.get(), "Device start failure");
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2012-10-07 00:13:23 -07:00
|
|
|
}
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
ALC_API void ALC_APIENTRY alcCaptureStop(ALCdevice *device)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(!dev || dev->Type != Capture)
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2012-10-07 00:13:23 -07:00
|
|
|
else
|
|
|
|
{
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
2019-06-09 02:20:30 -07:00
|
|
|
if(dev->Flags.get<DeviceRunning>())
|
2018-12-28 22:56:20 -08:00
|
|
|
dev->Backend->stop();
|
2019-06-09 02:20:30 -07:00
|
|
|
dev->Flags.unset<DeviceRunning>();
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
ALC_API void ALC_APIENTRY alcCaptureSamples(ALCdevice *device, ALCvoid *buffer, ALCsizei samples)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(!dev || dev->Type != Capture)
|
2012-04-20 01:18:38 -07:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
|
|
|
return;
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
2018-11-23 17:54:12 -08:00
|
|
|
|
|
|
|
ALCenum err{ALC_INVALID_VALUE};
|
2018-12-30 21:38:42 -08:00
|
|
|
{ std::lock_guard<std::mutex> _{dev->StateLock};
|
2018-12-29 02:16:16 -08:00
|
|
|
BackendBase *backend{dev->Backend.get()};
|
2019-01-08 19:42:44 +01:00
|
|
|
if(samples >= 0 && backend->availableSamples() >= static_cast<ALCuint>(samples))
|
2018-12-28 22:56:20 -08:00
|
|
|
err = backend->captureSamples(buffer, samples);
|
2018-11-23 17:54:12 -08:00
|
|
|
}
|
|
|
|
if(err != ALC_NO_ERROR)
|
|
|
|
alcSetError(dev.get(), err);
|
2012-04-20 01:18:38 -07:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2012-04-20 01:18:38 -07:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************
|
|
|
|
* ALC loopback functions
|
|
|
|
************************************************/
|
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcLoopbackOpenDeviceSOFT
|
|
|
|
*
|
|
|
|
* Open a loopback device, for manual rendering.
|
|
|
|
*/
|
2012-03-01 08:30:21 -08:00
|
|
|
ALC_API ALCdevice* ALC_APIENTRY alcLoopbackOpenDeviceSOFT(const ALCchar *deviceName)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2011-03-11 00:13:44 -08:00
|
|
|
{
|
2011-06-14 09:43:33 -07:00
|
|
|
DO_INITCONFIG();
|
|
|
|
|
2012-03-01 08:30:21 -08:00
|
|
|
/* Make sure the device name, if specified, is us. */
|
|
|
|
if(deviceName && strcmp(deviceName, alcDefaultName) != 0)
|
2012-02-15 20:52:49 -08:00
|
|
|
{
|
2018-11-14 04:15:44 -08:00
|
|
|
alcSetError(nullptr, ALC_INVALID_VALUE);
|
|
|
|
return nullptr;
|
2012-02-15 20:52:49 -08:00
|
|
|
}
|
|
|
|
|
2019-01-01 22:44:46 -08:00
|
|
|
DeviceRef device{new ALCdevice{Loopback}};
|
2014-02-01 16:37:11 -08:00
|
|
|
|
2016-06-08 11:19:33 -07:00
|
|
|
device->SourcesMax = 256;
|
2017-02-21 16:54:55 -08:00
|
|
|
device->AuxiliaryEffectSlotMax = 64;
|
|
|
|
device->NumAuxSends = DEFAULT_SENDS;
|
2011-09-18 16:16:55 -07:00
|
|
|
|
2011-03-11 00:13:44 -08:00
|
|
|
//Set output format
|
2019-04-26 15:58:25 -07:00
|
|
|
device->BufferSize = 0;
|
2011-09-18 16:16:55 -07:00
|
|
|
device->UpdateSize = 0;
|
|
|
|
|
2012-03-13 15:32:44 -07:00
|
|
|
device->Frequency = DEFAULT_OUTPUT_RATE;
|
|
|
|
device->FmtChans = DevFmtChannelsDefault;
|
|
|
|
device->FmtType = DevFmtTypeDefault;
|
2011-03-11 00:13:44 -08:00
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
if(auto srcsopt = ConfigValueUInt(nullptr, nullptr, "sources"))
|
|
|
|
{
|
|
|
|
if(*srcsopt > 0) device->SourcesMax = *srcsopt;
|
|
|
|
}
|
2011-09-18 16:16:55 -07:00
|
|
|
|
2019-06-30 13:04:23 -07:00
|
|
|
if(auto slotsopt = ConfigValueUInt(nullptr, nullptr, "slots"))
|
|
|
|
{
|
|
|
|
if(*slotsopt > 0)
|
|
|
|
device->AuxiliaryEffectSlotMax = minu(*slotsopt, INT_MAX);
|
|
|
|
}
|
2011-03-11 00:13:44 -08:00
|
|
|
|
2019-06-30 12:00:10 -07:00
|
|
|
if(auto sendsopt = ConfigValueInt(nullptr, nullptr, "sends"))
|
|
|
|
device->NumAuxSends = clampi(DEFAULT_SENDS, 0, clampi(*sendsopt, 0, MAX_SENDS));
|
2011-03-11 00:13:44 -08:00
|
|
|
|
|
|
|
device->NumStereoSources = 1;
|
2016-06-08 11:19:33 -07:00
|
|
|
device->NumMonoSources = device->SourcesMax - device->NumStereoSources;
|
2011-03-11 00:13:44 -08:00
|
|
|
|
2019-05-04 18:03:25 -07:00
|
|
|
try {
|
|
|
|
device->Backend = LoopbackBackendFactory::getFactory().createBackend(device.get(),
|
|
|
|
BackendType::Playback);
|
|
|
|
|
|
|
|
// Open the "backend"
|
|
|
|
device->Backend->open("Loopback");
|
|
|
|
}
|
|
|
|
catch(al::backend_exception &e) {
|
|
|
|
WARN("Failed to open loopback device: %s\n", e.what());
|
|
|
|
alcSetError(nullptr, e.errorCode());
|
2018-11-14 04:15:44 -08:00
|
|
|
return nullptr;
|
2018-01-28 18:03:54 -08:00
|
|
|
}
|
|
|
|
|
2014-08-01 02:04:40 -07:00
|
|
|
{
|
2019-03-19 15:41:01 -07:00
|
|
|
std::lock_guard<std::recursive_mutex> _{ListLock};
|
|
|
|
auto iter = std::lower_bound(DeviceList.cbegin(), DeviceList.cend(), device.get());
|
2019-08-03 12:14:50 -07:00
|
|
|
DeviceList.emplace(iter, device);
|
2014-08-01 02:04:40 -07:00
|
|
|
}
|
2011-09-18 16:16:55 -07:00
|
|
|
|
2018-11-23 20:16:34 -08:00
|
|
|
TRACE("Created device %p\n", device.get());
|
2019-01-01 22:44:46 -08:00
|
|
|
return device.get();
|
2011-03-11 00:13:44 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2011-03-11 00:13:44 -08:00
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcIsRenderFormatSupportedSOFT
|
|
|
|
*
|
|
|
|
* Determines if the loopback device supports the given format for rendering.
|
|
|
|
*/
|
2011-07-02 02:51:33 -07:00
|
|
|
ALC_API ALCboolean ALC_APIENTRY alcIsRenderFormatSupportedSOFT(ALCdevice *device, ALCsizei freq, ALCenum channels, ALCenum type)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2011-03-11 00:13:44 -08:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(!dev || dev->Type != Loopback)
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2011-03-12 06:23:17 -08:00
|
|
|
else if(freq <= 0)
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
2011-03-12 06:23:17 -08:00
|
|
|
else
|
|
|
|
{
|
Start a ALC_SOFT_loopback2 extension
This extends the base ALC_SOFT_loopback extension with support for B-Format.
When ALC_FORMAT_CHANNELS_SOFT is set to ALC_BFORMAT3D_SOFT, then additional
attributes must be specified. ALC_AMBISONIC_LAYOUT_SOFT must be set to
ALC_ACN_SOFT or ALC_FUMA_SOFT for the desired channel layout,
ALC_AMBISONIC_SCALING_SOFT must be set to ALC_N3D_SOFT, ALC_SN3D_SOFT, or
ALC_FUMA_SOFT for the desired channel scaling/normalization scheme, and
ALC_AMBISONIC_ORDER_SOFT must be set to an integer value greater than 0 for the
ambisonic order (maximum allowed is implementation-dependent).
Note that the number of channels required for ALC_BFORMAT3D_SOFT is dependent
on the ambisonic order. The number of channels can be calculated by:
num_channels = (order+1) * (order+1); /* or pow(order+1, 2); */
In addition, a new alcIsAmbisonicFormatSupportedSOFT function allows apps to
determine which layout/scaling/order combinations are supported by the loopback
device. For example,
alcIsAmbisonicFormatSupported(device, ALC_ACN_SOFT, ALC_SN3D_SOFT, 2) will
check if 2nd order AmbiX (ACN layout and SN3D scaling) rendering is supported
for ALC_BFORMAT3D_SOFT output.
2017-02-28 18:34:23 -08:00
|
|
|
if(IsValidALCType(type) && IsValidALCChannels(channels) && freq >= MIN_OUTPUT_RATE)
|
2018-11-23 17:54:12 -08:00
|
|
|
return ALC_TRUE;
|
2011-03-11 00:13:44 -08:00
|
|
|
}
|
|
|
|
|
2018-11-23 17:54:12 -08:00
|
|
|
return ALC_FALSE;
|
2011-03-11 00:13:44 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2011-03-11 00:13:44 -08:00
|
|
|
|
2011-09-10 19:14:14 -07:00
|
|
|
/* alcRenderSamplesSOFT
|
|
|
|
*
|
|
|
|
* Renders some samples into a buffer, using the format last set by the
|
|
|
|
* attributes given to alcCreateContext.
|
|
|
|
*/
|
2013-11-25 17:29:39 -08:00
|
|
|
FORCE_ALIGN ALC_API void ALC_APIENTRY alcRenderSamplesSOFT(ALCdevice *device, ALCvoid *buffer, ALCsizei samples)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2011-03-11 00:13:44 -08:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(!dev || dev->Type != Loopback)
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2018-11-14 04:15:44 -08:00
|
|
|
else if(samples < 0 || (samples > 0 && buffer == nullptr))
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
2011-03-11 00:13:44 -08:00
|
|
|
else
|
2017-02-18 17:32:07 -08:00
|
|
|
{
|
2019-01-01 16:38:54 -08:00
|
|
|
BackendLockGuard _{*device->Backend};
|
2018-11-23 17:54:12 -08:00
|
|
|
aluMixData(dev.get(), buffer, samples);
|
2017-02-18 17:32:07 -08:00
|
|
|
}
|
2011-03-11 00:13:44 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2014-01-15 16:27:17 -08:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************
|
|
|
|
* ALC DSP pause/resume functions
|
|
|
|
************************************************/
|
|
|
|
|
|
|
|
/* alcDevicePauseSOFT
|
|
|
|
*
|
|
|
|
* Pause the DSP to stop audio processing.
|
|
|
|
*/
|
|
|
|
ALC_API void ALC_APIENTRY alcDevicePauseSOFT(ALCdevice *device)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2014-01-15 16:27:17 -08:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(!dev || dev->Type != Playback)
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2014-01-15 16:27:17 -08:00
|
|
|
else
|
|
|
|
{
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
2019-06-09 02:20:30 -07:00
|
|
|
if(dev->Flags.get<DeviceRunning>())
|
2018-12-28 22:56:20 -08:00
|
|
|
dev->Backend->stop();
|
2019-06-09 02:20:30 -07:00
|
|
|
dev->Flags.unset<DeviceRunning>();
|
|
|
|
dev->Flags.set<DevicePaused>();
|
2014-01-15 16:27:17 -08:00
|
|
|
}
|
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2014-01-15 16:27:17 -08:00
|
|
|
|
|
|
|
/* alcDeviceResumeSOFT
|
|
|
|
*
|
|
|
|
* Resume the DSP to restart audio processing.
|
|
|
|
*/
|
|
|
|
ALC_API void ALC_APIENTRY alcDeviceResumeSOFT(ALCdevice *device)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2014-01-15 16:27:17 -08:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(!dev || dev->Type != Playback)
|
2018-11-28 11:55:43 -08:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2018-11-28 11:55:43 -08:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
2019-06-09 02:20:30 -07:00
|
|
|
if(!dev->Flags.get<DevicePaused>())
|
2018-11-28 11:55:43 -08:00
|
|
|
return;
|
2019-06-09 02:20:30 -07:00
|
|
|
dev->Flags.unset<DevicePaused>();
|
2019-06-29 21:32:36 -07:00
|
|
|
if(dev->mContexts.load()->empty())
|
2018-11-28 11:55:43 -08:00
|
|
|
return;
|
|
|
|
|
2018-12-28 22:56:20 -08:00
|
|
|
if(dev->Backend->start() == ALC_FALSE)
|
2014-01-15 16:27:17 -08:00
|
|
|
{
|
2018-11-28 11:55:43 -08:00
|
|
|
aluHandleDisconnect(dev.get(), "Device start failure");
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
|
|
|
return;
|
2014-01-15 16:27:17 -08:00
|
|
|
}
|
2019-06-09 02:20:30 -07:00
|
|
|
dev->Flags.set<DeviceRunning>();
|
2014-01-15 16:27:17 -08:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2015-10-02 23:54:30 -07:00
|
|
|
|
|
|
|
|
|
|
|
/************************************************
|
|
|
|
* ALC HRTF functions
|
|
|
|
************************************************/
|
|
|
|
|
|
|
|
/* alcGetStringiSOFT
|
|
|
|
*
|
|
|
|
* Gets a string parameter at the given index.
|
|
|
|
*/
|
2015-10-07 03:29:53 -07:00
|
|
|
ALC_API const ALCchar* ALC_APIENTRY alcGetStringiSOFT(ALCdevice *device, ALCenum paramName, ALCsizei index)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2015-10-02 23:54:30 -07:00
|
|
|
{
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
|
|
|
if(!dev || dev->Type == Capture)
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2015-10-02 23:54:30 -07:00
|
|
|
else switch(paramName)
|
|
|
|
{
|
|
|
|
case ALC_HRTF_SPECIFIER_SOFT:
|
2019-01-08 19:42:44 +01:00
|
|
|
if(index >= 0 && static_cast<size_t>(index) < dev->HrtfList.size())
|
2018-11-23 17:54:12 -08:00
|
|
|
return dev->HrtfList[index].name.c_str();
|
|
|
|
alcSetError(dev.get(), ALC_INVALID_VALUE);
|
2015-10-02 23:54:30 -07:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_ENUM);
|
2015-10-02 23:54:30 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-11-23 17:54:12 -08:00
|
|
|
return nullptr;
|
2015-10-02 23:54:30 -07:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|
2015-10-02 23:54:30 -07:00
|
|
|
|
|
|
|
/* alcResetDeviceSOFT
|
|
|
|
*
|
|
|
|
* Resets the given device output, using the specified attribute list.
|
|
|
|
*/
|
|
|
|
ALC_API ALCboolean ALC_APIENTRY alcResetDeviceSOFT(ALCdevice *device, const ALCint *attribs)
|
2019-04-09 20:48:01 -07:00
|
|
|
START_API_FUNC
|
2015-10-02 23:54:30 -07:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
std::unique_lock<std::recursive_mutex> listlock{ListLock};
|
2018-11-23 17:54:12 -08:00
|
|
|
DeviceRef dev{VerifyDevice(device)};
|
2018-11-28 19:29:20 -08:00
|
|
|
if(!dev || dev->Type == Capture)
|
2015-10-02 23:54:30 -07:00
|
|
|
{
|
2018-11-14 06:17:47 -08:00
|
|
|
listlock.unlock();
|
2018-11-23 17:54:12 -08:00
|
|
|
alcSetError(dev.get(), ALC_INVALID_DEVICE);
|
2015-10-02 23:54:30 -07:00
|
|
|
return ALC_FALSE;
|
|
|
|
}
|
2018-12-30 21:38:42 -08:00
|
|
|
std::lock_guard<std::mutex> _{dev->StateLock};
|
2018-11-14 06:17:47 -08:00
|
|
|
listlock.unlock();
|
2015-10-02 23:54:30 -07:00
|
|
|
|
2018-11-28 12:24:12 -08:00
|
|
|
/* Force the backend to stop mixing first since we're resetting. Also reset
|
|
|
|
* the connected state so lost devices can attempt recover.
|
|
|
|
*/
|
2019-06-09 02:20:30 -07:00
|
|
|
if(dev->Flags.get<DeviceRunning>())
|
2018-12-28 22:56:20 -08:00
|
|
|
dev->Backend->stop();
|
2019-06-09 02:20:30 -07:00
|
|
|
dev->Flags.unset<DeviceRunning>();
|
2018-12-30 21:58:14 -08:00
|
|
|
device->Connected.store(true);
|
2018-11-28 12:24:12 -08:00
|
|
|
|
2018-11-23 17:54:12 -08:00
|
|
|
ALCenum err{UpdateDeviceParams(dev.get(), attribs)};
|
2019-08-04 11:59:14 -07:00
|
|
|
if LIKELY(err == ALC_NO_ERROR) return ALC_TRUE;
|
2016-05-27 19:23:39 -07:00
|
|
|
|
2018-11-28 11:55:43 -08:00
|
|
|
alcSetError(dev.get(), err);
|
|
|
|
if(err == ALC_INVALID_DEVICE)
|
|
|
|
aluHandleDisconnect(dev.get(), "Device start failure");
|
|
|
|
return ALC_FALSE;
|
2015-10-02 23:54:30 -07:00
|
|
|
}
|
2019-04-09 20:48:01 -07:00
|
|
|
END_API_FUNC
|