2019-07-28 18:33:29 -07:00
|
|
|
#ifndef ALC_MAIN_H
|
|
|
|
#define ALC_MAIN_H
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <algorithm>
|
2018-11-19 06:50:37 -08:00
|
|
|
#include <array>
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <atomic>
|
2021-01-22 00:00:10 -08:00
|
|
|
#include <bitset>
|
2018-11-22 12:53:16 -08:00
|
|
|
#include <chrono>
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <cstdint>
|
|
|
|
#include <cstddef>
|
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string>
|
2020-03-03 20:32:44 -08:00
|
|
|
#include <thread>
|
2019-07-28 11:28:36 -07:00
|
|
|
#include <utility>
|
2018-11-18 07:33:42 -08:00
|
|
|
|
2009-05-16 23:26:39 -07:00
|
|
|
#include "AL/al.h"
|
|
|
|
#include "AL/alc.h"
|
|
|
|
#include "AL/alext.h"
|
|
|
|
|
2016-03-29 00:44:58 -07:00
|
|
|
#include "almalloc.h"
|
2019-02-11 11:07:06 -08:00
|
|
|
#include "alnumeric.h"
|
2019-06-08 01:39:28 -07:00
|
|
|
#include "alspan.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "atomic.h"
|
2020-12-12 10:38:24 -08:00
|
|
|
#include "core/ambidefs.h"
|
2020-11-27 19:18:17 -08:00
|
|
|
#include "core/bufferline.h"
|
|
|
|
#include "core/devformat.h"
|
2020-12-04 09:42:13 -08:00
|
|
|
#include "core/filters/splitter.h"
|
2020-12-12 14:58:09 -08:00
|
|
|
#include "core/mixer/defs.h"
|
2019-03-28 09:29:20 -07:00
|
|
|
#include "hrtf.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "inprogext.h"
|
2019-08-01 13:28:53 -07:00
|
|
|
#include "intrusive_ptr.h"
|
2019-07-28 11:28:36 -07:00
|
|
|
#include "vector.h"
|
|
|
|
|
|
|
|
class BFormatDec;
|
|
|
|
struct ALbuffer;
|
|
|
|
struct ALeffect;
|
|
|
|
struct ALfilter;
|
|
|
|
struct BackendBase;
|
|
|
|
struct Compressor;
|
|
|
|
struct EffectState;
|
|
|
|
struct Uhj2Encoder;
|
|
|
|
struct bs2b;
|
2013-10-28 12:48:13 -07:00
|
|
|
|
2020-12-11 15:08:50 -08:00
|
|
|
using uint = unsigned int;
|
|
|
|
|
2010-07-30 20:23:55 -07:00
|
|
|
|
2019-04-26 18:56:54 -07:00
|
|
|
#define MIN_OUTPUT_RATE 8000
|
2020-04-28 16:30:11 -07:00
|
|
|
#define MAX_OUTPUT_RATE 192000
|
2019-04-26 18:56:54 -07:00
|
|
|
#define DEFAULT_OUTPUT_RATE 44100
|
2020-04-28 16:30:11 -07:00
|
|
|
|
2019-04-26 18:56:54 -07:00
|
|
|
#define DEFAULT_UPDATE_SIZE 882 /* 20ms */
|
|
|
|
#define DEFAULT_NUM_UPDATES 3
|
2011-09-18 09:52:40 -07:00
|
|
|
|
|
|
|
|
2020-12-27 10:09:39 -08:00
|
|
|
enum class DeviceType : unsigned char {
|
2012-02-23 15:25:30 -08:00
|
|
|
Playback,
|
|
|
|
Capture,
|
|
|
|
Loopback
|
|
|
|
};
|
|
|
|
|
2012-09-14 02:14:29 -07:00
|
|
|
|
2020-12-27 10:09:39 -08:00
|
|
|
enum class RenderMode : unsigned char {
|
2020-09-01 05:46:19 -07:00
|
|
|
Normal,
|
|
|
|
Pairwise,
|
|
|
|
Hrtf
|
2015-02-11 09:32:05 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2019-12-19 04:38:34 -08:00
|
|
|
struct InputRemixMap {
|
|
|
|
struct TargetMix { Channel channel; float mix; };
|
|
|
|
|
|
|
|
Channel channel;
|
|
|
|
std::array<TargetMix,2> targets;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-11-25 15:30:32 -08:00
|
|
|
struct BufferSubList {
|
2019-02-11 11:07:06 -08:00
|
|
|
uint64_t FreeMask{~0_u64};
|
2018-12-24 19:29:01 -08:00
|
|
|
ALbuffer *Buffers{nullptr}; /* 64 */
|
2018-11-25 15:30:32 -08:00
|
|
|
|
|
|
|
BufferSubList() noexcept = default;
|
|
|
|
BufferSubList(const BufferSubList&) = delete;
|
|
|
|
BufferSubList(BufferSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Buffers{rhs.Buffers}
|
2019-02-11 11:07:06 -08:00
|
|
|
{ rhs.FreeMask = ~0_u64; rhs.Buffers = nullptr; }
|
2018-11-25 15:30:32 -08:00
|
|
|
~BufferSubList();
|
|
|
|
|
|
|
|
BufferSubList& operator=(const BufferSubList&) = delete;
|
|
|
|
BufferSubList& operator=(BufferSubList&& rhs) noexcept
|
|
|
|
{ std::swap(FreeMask, rhs.FreeMask); std::swap(Buffers, rhs.Buffers); return *this; }
|
|
|
|
};
|
2018-01-27 01:51:01 -08:00
|
|
|
|
2018-11-25 16:13:07 -08:00
|
|
|
struct EffectSubList {
|
2019-02-11 11:07:06 -08:00
|
|
|
uint64_t FreeMask{~0_u64};
|
2018-12-24 19:29:01 -08:00
|
|
|
ALeffect *Effects{nullptr}; /* 64 */
|
2018-01-27 19:01:25 -08:00
|
|
|
|
2018-11-25 16:13:07 -08:00
|
|
|
EffectSubList() noexcept = default;
|
|
|
|
EffectSubList(const EffectSubList&) = delete;
|
|
|
|
EffectSubList(EffectSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Effects{rhs.Effects}
|
2019-02-11 11:07:06 -08:00
|
|
|
{ rhs.FreeMask = ~0_u64; rhs.Effects = nullptr; }
|
2018-11-25 16:13:07 -08:00
|
|
|
~EffectSubList();
|
|
|
|
|
|
|
|
EffectSubList& operator=(const EffectSubList&) = delete;
|
|
|
|
EffectSubList& operator=(EffectSubList&& rhs) noexcept
|
|
|
|
{ std::swap(FreeMask, rhs.FreeMask); std::swap(Effects, rhs.Effects); return *this; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct FilterSubList {
|
2019-02-11 11:07:06 -08:00
|
|
|
uint64_t FreeMask{~0_u64};
|
2018-12-24 19:29:01 -08:00
|
|
|
ALfilter *Filters{nullptr}; /* 64 */
|
2018-11-25 16:13:07 -08:00
|
|
|
|
|
|
|
FilterSubList() noexcept = default;
|
|
|
|
FilterSubList(const FilterSubList&) = delete;
|
|
|
|
FilterSubList(FilterSubList&& rhs) noexcept : FreeMask{rhs.FreeMask}, Filters{rhs.Filters}
|
2019-02-11 11:07:06 -08:00
|
|
|
{ rhs.FreeMask = ~0_u64; rhs.Filters = nullptr; }
|
2018-11-25 16:13:07 -08:00
|
|
|
~FilterSubList();
|
|
|
|
|
|
|
|
FilterSubList& operator=(const FilterSubList&) = delete;
|
|
|
|
FilterSubList& operator=(FilterSubList&& rhs) noexcept
|
|
|
|
{ std::swap(FreeMask, rhs.FreeMask); std::swap(Filters, rhs.Filters); return *this; }
|
|
|
|
};
|
2018-01-27 19:40:47 -08:00
|
|
|
|
2018-01-27 01:51:01 -08:00
|
|
|
|
2017-02-19 22:47:59 -08:00
|
|
|
/* Maximum delay in samples for speaker distance compensation. */
|
2017-02-28 21:01:13 -08:00
|
|
|
#define MAX_DELAY_LENGTH 1024
|
2017-02-19 22:47:59 -08:00
|
|
|
|
2020-12-27 11:30:45 -08:00
|
|
|
struct DistanceComp {
|
|
|
|
struct ChanData {
|
2020-03-30 13:43:49 -07:00
|
|
|
float Gain{1.0f};
|
2020-12-15 20:48:21 -08:00
|
|
|
uint Length{0u}; /* Valid range is [0...MAX_DELAY_LENGTH). */
|
2020-03-30 13:43:49 -07:00
|
|
|
float *Buffer{nullptr};
|
2018-12-10 14:49:57 -08:00
|
|
|
};
|
|
|
|
|
2020-12-27 11:30:45 -08:00
|
|
|
std::array<ChanData,MAX_OUTPUT_CHANNELS> mChannels;
|
|
|
|
al::FlexArray<float,16> mSamples;
|
2018-11-21 05:06:31 -08:00
|
|
|
|
2020-12-27 11:30:45 -08:00
|
|
|
DistanceComp(size_t count) : mSamples{count} { }
|
|
|
|
|
|
|
|
static std::unique_ptr<DistanceComp> Create(size_t numsamples)
|
2020-12-27 14:37:43 -08:00
|
|
|
{ return std::unique_ptr<DistanceComp>{new(FamCount(numsamples)) DistanceComp{numsamples}}; }
|
2018-11-21 05:06:31 -08:00
|
|
|
|
2020-12-28 02:50:15 -08:00
|
|
|
DEF_FAM_NEWDEL(DistanceComp, mSamples)
|
2018-11-21 05:06:31 -08:00
|
|
|
};
|
2017-02-19 22:47:59 -08:00
|
|
|
|
2020-11-02 04:24:36 -08:00
|
|
|
|
2019-01-05 21:55:14 -08:00
|
|
|
struct BFChannelConfig {
|
2020-03-30 13:43:49 -07:00
|
|
|
float Scale;
|
2020-12-15 20:48:21 -08:00
|
|
|
uint Index;
|
2019-01-05 21:55:14 -08:00
|
|
|
};
|
|
|
|
|
2012-09-14 02:14:29 -07:00
|
|
|
|
2018-12-24 19:29:01 -08:00
|
|
|
struct MixParams {
|
2019-01-05 21:55:14 -08:00
|
|
|
/* Coefficient channel mapping for mixing to the buffer. */
|
2019-07-04 15:02:12 -07:00
|
|
|
std::array<BFChannelConfig,MAX_OUTPUT_CHANNELS> AmbiMap{};
|
2018-01-11 03:45:23 -08:00
|
|
|
|
2019-07-04 15:02:12 -07:00
|
|
|
al::span<FloatBufferLine> Buffer;
|
2018-12-24 19:29:01 -08:00
|
|
|
};
|
2018-01-11 03:45:23 -08:00
|
|
|
|
2018-12-24 19:29:01 -08:00
|
|
|
struct RealMixParams {
|
2019-12-19 04:38:34 -08:00
|
|
|
al::span<const InputRemixMap> RemixMap;
|
2020-12-15 20:48:21 -08:00
|
|
|
std::array<uint,MaxChannels> ChannelIndex{};
|
2018-01-11 03:45:23 -08:00
|
|
|
|
2019-07-03 23:26:33 -07:00
|
|
|
al::span<FloatBufferLine> Buffer;
|
2018-12-24 19:29:01 -08:00
|
|
|
};
|
2018-01-11 03:45:23 -08:00
|
|
|
|
2019-06-08 23:49:15 -07:00
|
|
|
enum {
|
|
|
|
// Frequency was requested by the app or config file
|
|
|
|
FrequencyRequest,
|
|
|
|
// Channel configuration was requested by the config file
|
|
|
|
ChannelsRequest,
|
|
|
|
// Sample type was requested by the config file
|
|
|
|
SampleTypeRequest,
|
|
|
|
|
|
|
|
// Specifies if the DSP is paused at user request
|
|
|
|
DevicePaused,
|
|
|
|
// Specifies if the device is currently running
|
|
|
|
DeviceRunning,
|
|
|
|
|
|
|
|
DeviceFlagsCount
|
|
|
|
};
|
|
|
|
|
2019-08-01 13:28:53 -07:00
|
|
|
struct ALCdevice : public al::intrusive_ref<ALCdevice> {
|
2018-12-30 21:58:14 -08:00
|
|
|
std::atomic<bool> Connected{true};
|
2018-12-27 10:25:09 -08:00
|
|
|
const DeviceType Type{};
|
2018-11-18 07:33:42 -08:00
|
|
|
|
2020-12-15 20:48:21 -08:00
|
|
|
uint Frequency{};
|
|
|
|
uint UpdateSize{};
|
|
|
|
uint BufferSize{};
|
2019-04-26 15:58:25 -07:00
|
|
|
|
2018-11-18 07:33:42 -08:00
|
|
|
DevFmtChannels FmtChans{};
|
2019-09-13 20:04:22 -07:00
|
|
|
DevFmtType FmtType{};
|
2020-03-28 15:37:34 -07:00
|
|
|
bool IsHeadphones{false};
|
2020-12-15 20:48:21 -08:00
|
|
|
uint mAmbiOrder{0};
|
2020-12-27 12:23:35 -08:00
|
|
|
float mXOverFreq{400.0f};
|
2016-07-31 07:46:38 -07:00
|
|
|
/* For DevFmtAmbi* output only, specifies the channel order and
|
|
|
|
* normalization.
|
|
|
|
*/
|
2020-08-28 00:09:46 -07:00
|
|
|
DevAmbiLayout mAmbiLayout{DevAmbiLayout::Default};
|
|
|
|
DevAmbiScaling mAmbiScale{DevAmbiScaling::Default};
|
2018-10-03 13:48:04 -07:00
|
|
|
|
2018-11-18 18:45:45 -08:00
|
|
|
std::string DeviceName;
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-11-29 13:08:03 -08:00
|
|
|
// Device flags
|
2021-01-22 00:00:10 -08:00
|
|
|
std::bitset<DeviceFlagsCount> Flags{};
|
2018-11-29 13:08:03 -08:00
|
|
|
|
2007-11-13 18:02:18 -08:00
|
|
|
// Maximum number of sources that can be created
|
2020-12-15 20:48:21 -08:00
|
|
|
uint SourcesMax{};
|
2009-06-07 14:53:22 -07:00
|
|
|
// Maximum number of slots that can be created
|
2020-12-15 20:48:21 -08:00
|
|
|
uint AuxiliaryEffectSlotMax{};
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2016-02-26 21:48:03 -08:00
|
|
|
/* Rendering mode. */
|
2020-09-01 05:46:19 -07:00
|
|
|
RenderMode mRenderMode{RenderMode::Normal};
|
2016-02-26 21:48:03 -08:00
|
|
|
|
2019-07-06 18:39:26 -07:00
|
|
|
/* The average speaker distance as determined by the ambdec configuration,
|
|
|
|
* HRTF data set, or the NFC-HOA reference delay. Only used for NFC.
|
2018-11-29 13:08:03 -08:00
|
|
|
*/
|
2020-03-30 13:43:49 -07:00
|
|
|
float AvgSpeakerDist{0.0f};
|
2011-05-01 13:19:23 -07:00
|
|
|
|
2020-12-15 20:48:21 -08:00
|
|
|
uint SamplesDone{0u};
|
2018-11-22 12:53:16 -08:00
|
|
|
std::chrono::nanoseconds ClockBase{0};
|
|
|
|
std::chrono::nanoseconds FixedLatency{0};
|
2014-02-01 16:37:11 -08:00
|
|
|
|
2018-01-09 22:01:46 -08:00
|
|
|
/* Temp storage used for mixer processing. */
|
2020-11-28 03:38:20 -08:00
|
|
|
alignas(16) float SourceData[BufferLineSize + MaxResamplerPadding];
|
|
|
|
alignas(16) float ResampledData[BufferLineSize];
|
|
|
|
alignas(16) float FilteredData[BufferLineSize];
|
2019-03-28 09:29:20 -07:00
|
|
|
union {
|
2020-12-25 20:52:18 -08:00
|
|
|
alignas(16) float HrtfSourceData[BufferLineSize + HrtfHistoryLength];
|
2020-11-28 03:38:20 -08:00
|
|
|
alignas(16) float NfcSampleData[BufferLineSize];
|
2019-03-28 09:29:20 -07:00
|
|
|
};
|
2019-11-03 00:30:33 -07:00
|
|
|
|
|
|
|
/* Persistent storage for HRTF mixing. */
|
2020-12-25 20:52:18 -08:00
|
|
|
alignas(16) float2 HrtfAccumData[BufferLineSize + HrirLength + HrtfDirectDelay];
|
2012-10-05 06:42:26 -07:00
|
|
|
|
2019-03-22 18:37:47 -07:00
|
|
|
/* Mixing buffer used by the Dry mix and Real output. */
|
2019-05-28 16:22:36 -07:00
|
|
|
al::vector<FloatBufferLine, 16> MixBuffer;
|
2018-11-19 06:22:09 -08:00
|
|
|
|
2016-03-09 23:43:57 -08:00
|
|
|
/* The "dry" path corresponds to the main output. */
|
2018-09-19 21:31:46 -07:00
|
|
|
MixParams Dry;
|
2020-12-15 20:48:21 -08:00
|
|
|
uint NumChannelsPerOrder[MaxAmbiOrder+1]{};
|
2012-08-29 01:40:42 -07:00
|
|
|
|
2016-07-05 14:18:17 -07:00
|
|
|
/* "Real" output, which will be written to the device buffer. May alias the
|
|
|
|
* dry buffer.
|
|
|
|
*/
|
2018-01-11 03:45:23 -08:00
|
|
|
RealMixParams RealOut;
|
2016-03-09 22:57:38 -08:00
|
|
|
|
2018-11-29 13:08:03 -08:00
|
|
|
/* HRTF state and info */
|
|
|
|
std::unique_ptr<DirectHrtfState> mHrtfState;
|
2020-03-01 17:16:09 -08:00
|
|
|
al::intrusive_ptr<HrtfStore> mHrtf;
|
2020-12-11 15:08:50 -08:00
|
|
|
uint mIrSize{0};
|
2017-07-31 23:49:48 -07:00
|
|
|
|
2019-02-22 22:35:37 -08:00
|
|
|
/* Ambisonic-to-UHJ encoder */
|
2018-11-29 13:08:03 -08:00
|
|
|
std::unique_ptr<Uhj2Encoder> Uhj_Encoder;
|
2017-04-26 18:38:09 -07:00
|
|
|
|
2019-02-22 22:35:37 -08:00
|
|
|
/* Ambisonic decoder for speakers */
|
2018-11-29 13:08:03 -08:00
|
|
|
std::unique_ptr<BFormatDec> AmbiDecoder;
|
|
|
|
|
|
|
|
/* Stereo-to-binaural filter */
|
|
|
|
std::unique_ptr<bs2b> Bs2b;
|
|
|
|
|
2019-08-25 15:36:40 -07:00
|
|
|
using PostProc = void(ALCdevice::*)(const size_t SamplesToDo);
|
2019-08-07 11:43:53 -07:00
|
|
|
PostProc PostProcess{nullptr};
|
2018-11-29 13:08:03 -08:00
|
|
|
|
2018-12-24 07:30:01 -08:00
|
|
|
std::unique_ptr<Compressor> Limiter;
|
|
|
|
|
2017-02-19 22:47:59 -08:00
|
|
|
/* Delay buffers used to compensate for speaker distances. */
|
2020-12-27 11:30:45 -08:00
|
|
|
std::unique_ptr<DistanceComp> ChannelDelays;
|
2017-02-19 22:47:59 -08:00
|
|
|
|
2017-05-23 00:02:04 -07:00
|
|
|
/* Dithering control. */
|
2020-03-30 13:43:49 -07:00
|
|
|
float DitherDepth{0.0f};
|
2020-12-15 20:48:21 -08:00
|
|
|
uint DitherSeed{0u};
|
2017-05-23 00:02:04 -07:00
|
|
|
|
Keep track of the mix count
The purpose of this is to provide a safe way to be able to "swap" resources
used by the mixer from other threads without the need to block the mixer, as
well as a way to track when mixes have occurred. The idea is two-fold:
It provides a way to safely swap resources. If the mixer were to (atomically)
get a reference to an object to access it from, another thread would be able
allocate and prepare a new object then swap the reference to it with the stored
one. The other thread would then be able to wait until (count&1) is clear,
indicating the mixer is not running, before safely freeing the old object for
the mixer to use the new one.
It also provides a way to tell if the mixer has run. With this, a thread would
be able to read multiple values, which could be altered by the mixer, without
requiring a mixer lock. Comparing the before and after counts for inequality
would signify if the mixer has (started to) run, indicating the values may be
out of sync and should try getting them again. Of course, it will still need
something like a RWLock to ensure another (non-mixer) thread doesn't try to
write to the values at the same time.
Note that because of the possibility of overflow, the counter is not reliable
as an absolute count.
2014-03-19 19:00:54 -07:00
|
|
|
/* Running count of the mixer invocations, in 31.1 fixed point. This
|
|
|
|
* actually increments *twice* when mixing, first at the start and then at
|
|
|
|
* the end, so the bottom bit indicates if the device is currently mixing
|
|
|
|
* and the upper bits indicates how many mixes have been done.
|
|
|
|
*/
|
2018-11-18 07:33:42 -08:00
|
|
|
RefCount MixCount{0u};
|
Keep track of the mix count
The purpose of this is to provide a safe way to be able to "swap" resources
used by the mixer from other threads without the need to block the mixer, as
well as a way to track when mixes have occurred. The idea is two-fold:
It provides a way to safely swap resources. If the mixer were to (atomically)
get a reference to an object to access it from, another thread would be able
allocate and prepare a new object then swap the reference to it with the stored
one. The other thread would then be able to wait until (count&1) is clear,
indicating the mixer is not running, before safely freeing the old object for
the mixer to use the new one.
It also provides a way to tell if the mixer has run. With this, a thread would
be able to read multiple values, which could be altered by the mixer, without
requiring a mixer lock. Comparing the before and after counts for inequality
would signify if the mixer has (started to) run, indicating the values may be
out of sync and should try getting them again. Of course, it will still need
something like a RWLock to ensure another (non-mixer) thread doesn't try to
write to the values at the same time.
Note that because of the possibility of overflow, the counter is not reliable
as an absolute count.
2014-03-19 19:00:54 -07:00
|
|
|
|
2009-10-20 11:54:04 -07:00
|
|
|
// Contexts created on this device
|
2019-06-29 21:32:36 -07:00
|
|
|
std::atomic<al::FlexArray<ALCcontext*>*> mContexts{nullptr};
|
2007-11-13 18:02:18 -08:00
|
|
|
|
2018-12-30 21:38:42 -08:00
|
|
|
/* This lock protects the device state (format, update size, etc) from
|
|
|
|
* being from being changed in multiple threads, or being accessed while
|
|
|
|
* being changed. It's also used to serialize calls to the backend.
|
|
|
|
*/
|
|
|
|
std::mutex StateLock;
|
2018-12-29 02:16:16 -08:00
|
|
|
std::unique_ptr<BackendBase> Backend;
|
2018-11-18 07:33:42 -08:00
|
|
|
|
|
|
|
|
2020-12-27 12:23:35 -08:00
|
|
|
ALCuint NumMonoSources{};
|
|
|
|
ALCuint NumStereoSources{};
|
|
|
|
ALCuint NumAuxSends{};
|
|
|
|
|
|
|
|
std::string HrtfName;
|
|
|
|
al::vector<std::string> HrtfList;
|
|
|
|
ALCenum HrtfStatus{ALC_FALSE};
|
|
|
|
|
|
|
|
ALCenum LimiterState{ALC_DONT_CARE_SOFT};
|
|
|
|
|
|
|
|
std::atomic<ALCenum> LastError{ALC_NO_ERROR};
|
|
|
|
|
|
|
|
// Map of Buffers for this device
|
|
|
|
std::mutex BufferLock;
|
|
|
|
al::vector<BufferSubList> BufferList;
|
|
|
|
|
|
|
|
// Map of Effects for this device
|
|
|
|
std::mutex EffectLock;
|
|
|
|
al::vector<EffectSubList> EffectList;
|
|
|
|
|
|
|
|
// Map of Filters for this device
|
|
|
|
std::mutex FilterLock;
|
|
|
|
al::vector<FilterSubList> FilterList;
|
|
|
|
|
|
|
|
|
2019-01-01 18:13:33 -08:00
|
|
|
ALCdevice(DeviceType type);
|
|
|
|
ALCdevice(const ALCdevice&) = delete;
|
|
|
|
ALCdevice& operator=(const ALCdevice&) = delete;
|
|
|
|
~ALCdevice();
|
2018-11-18 07:33:42 -08:00
|
|
|
|
2020-12-15 20:48:21 -08:00
|
|
|
uint bytesFromFmt() const noexcept { return BytesFromDevFmt(FmtType); }
|
|
|
|
uint channelsFromFmt() const noexcept { return ChannelsFromDevFmt(FmtChans, mAmbiOrder); }
|
|
|
|
uint frameSizeFromFmt() const noexcept { return bytesFromFmt() * channelsFromFmt(); }
|
2018-12-19 03:13:15 -08:00
|
|
|
|
2020-12-15 20:48:21 -08:00
|
|
|
uint waitForMix() const noexcept
|
2020-03-03 20:32:44 -08:00
|
|
|
{
|
2020-12-15 20:48:21 -08:00
|
|
|
uint refcount;
|
2020-03-16 01:05:14 -07:00
|
|
|
while((refcount=MixCount.load(std::memory_order_acquire))&1) {
|
|
|
|
}
|
2020-03-03 20:32:44 -08:00
|
|
|
return refcount;
|
|
|
|
}
|
|
|
|
|
2019-08-25 15:36:40 -07:00
|
|
|
void ProcessHrtf(const size_t SamplesToDo);
|
|
|
|
void ProcessAmbiDec(const size_t SamplesToDo);
|
2020-06-15 02:05:10 -07:00
|
|
|
void ProcessAmbiDecStablized(const size_t SamplesToDo);
|
2019-08-25 15:36:40 -07:00
|
|
|
void ProcessUhj(const size_t SamplesToDo);
|
|
|
|
void ProcessBs2b(const size_t SamplesToDo);
|
2019-08-07 11:43:53 -07:00
|
|
|
|
2019-08-25 15:36:40 -07:00
|
|
|
inline void postProcess(const size_t SamplesToDo)
|
2019-08-07 11:43:53 -07:00
|
|
|
{ if LIKELY(PostProcess) (this->*PostProcess)(SamplesToDo); }
|
|
|
|
|
2020-12-15 20:48:21 -08:00
|
|
|
void renderSamples(void *outBuffer, const uint numSamples, const size_t frameStep);
|
2020-08-07 06:17:12 -07:00
|
|
|
|
|
|
|
/* Caller must lock the device state, and the mixer must not be running. */
|
|
|
|
[[gnu::format(printf,2,3)]] void handleDisconnect(const char *msg, ...);
|
|
|
|
|
2018-11-18 07:33:42 -08:00
|
|
|
DEF_NEWDEL(ALCdevice)
|
2007-11-13 18:02:18 -08:00
|
|
|
};
|
|
|
|
|
2013-10-27 07:00:44 -07:00
|
|
|
/* Must be less than 15 characters (16 including terminating null) for
|
|
|
|
* compatibility with pthread_setname_np limitations. */
|
|
|
|
#define MIXER_THREAD_NAME "alsoft-mixer"
|
|
|
|
|
2014-12-21 10:38:40 -08:00
|
|
|
#define RECORD_THREAD_NAME "alsoft-record"
|
|
|
|
|
2013-10-27 07:00:44 -07:00
|
|
|
|
2020-04-08 10:15:43 -07:00
|
|
|
extern int RTPrioLevel;
|
2010-05-12 07:27:12 -07:00
|
|
|
void SetRTPriority(void);
|
2009-12-01 23:15:09 -08:00
|
|
|
|
2018-01-11 03:45:23 -08:00
|
|
|
/**
|
2019-09-12 04:17:21 -07:00
|
|
|
* Returns the index for the given channel name (e.g. FrontCenter), or
|
|
|
|
* INVALID_CHANNEL_INDEX if it doesn't exist.
|
2018-01-11 03:45:23 -08:00
|
|
|
*/
|
2020-12-15 20:48:21 -08:00
|
|
|
inline uint GetChannelIdxByName(const RealMixParams &real, Channel chan) noexcept
|
2019-04-02 15:53:27 -07:00
|
|
|
{ return real.ChannelIndex[chan]; }
|
2019-09-12 04:17:21 -07:00
|
|
|
#define INVALID_CHANNEL_INDEX ~0u
|
2010-01-12 09:05:57 -08:00
|
|
|
|
2012-08-13 08:53:36 -07:00
|
|
|
|
2018-11-24 16:58:49 -08:00
|
|
|
al::vector<std::string> SearchDataFiles(const char *match, const char *subdir);
|
2007-11-13 18:02:18 -08:00
|
|
|
|
|
|
|
#endif
|