Update OpenAL-soft to 1.23.1-bc7cb17.

This commit is contained in:
Miku AuahDark
2024-03-20 11:06:03 +08:00
parent 4a512be715
commit 73a6fc9196
294 changed files with 44342 additions and 40077 deletions
+39 -34
View File
@@ -3,17 +3,20 @@
#include <array>
#include <atomic>
#include <bitset>
#include <cstddef>
#include <memory>
#include <thread>
#include <vector>
#include "almalloc.h"
#include "alsem.h"
#include "alspan.h"
#include "async_event.h"
#include "atomic.h"
#include "bufferline.h"
#include "threads.h"
#include "flexarray.h"
#include "opthelpers.h"
#include "vecmat.h"
#include "vector.h"
struct DeviceBase;
struct EffectSlot;
@@ -23,12 +26,10 @@ struct Voice;
struct VoiceChange;
struct VoicePropsItem;
using uint = unsigned int;
inline constexpr float SpeedOfSoundMetersPerSec{343.3f};
constexpr float SpeedOfSoundMetersPerSec{343.3f};
constexpr float AirAbsorbGainHF{0.99426f}; /* -0.05dB */
inline constexpr float AirAbsorbGainHF{0.99426f}; /* -0.05dB */
enum class DistanceModel : unsigned char {
Disable,
@@ -40,17 +41,6 @@ enum class DistanceModel : unsigned char {
};
struct WetBuffer {
bool mInUse;
al::FlexArray<FloatBufferLine, 16> mBuffer;
WetBuffer(size_t count) : mBuffer{count} { }
DEF_FAM_NEWDEL(WetBuffer, mBuffer)
};
using WetBufferPtr = std::unique_ptr<WetBuffer>;
struct ContextProps {
std::array<float,3> Position;
std::array<float,3> Velocity;
@@ -67,8 +57,6 @@ struct ContextProps {
DistanceModel mDistanceModel;
std::atomic<ContextProps*> next;
DEF_NEWDEL(ContextProps)
};
struct ContextParams {
@@ -96,7 +84,7 @@ struct ContextBase {
/* Counter for the pre-mixing updates, in 31.1 fixed point (lowest bit
* indicates if updates are currently happening).
*/
RefCount mUpdateCount{0u};
std::atomic<unsigned int> mUpdateCount{0u};
std::atomic<bool> mHoldUpdates{false};
std::atomic<bool> mStopVoicesOnDisconnect{true};
@@ -107,7 +95,7 @@ struct ContextBase {
*/
std::atomic<ContextProps*> mFreeContextProps{nullptr};
std::atomic<VoicePropsItem*> mFreeVoiceProps{nullptr};
std::atomic<EffectSlotProps*> mFreeEffectslotProps{nullptr};
std::atomic<EffectSlotProps*> mFreeEffectSlotProps{nullptr};
/* The voice change tail is the beginning of the "free" elements, up to and
* *excluding* the current. If tail==current, there's no free elements and
@@ -119,21 +107,22 @@ struct ContextBase {
void allocVoiceChanges();
void allocVoiceProps();
void allocEffectSlotProps();
void allocContextProps();
ContextParams mParams;
using VoiceArray = al::FlexArray<Voice*>;
std::atomic<VoiceArray*> mVoices{};
al::atomic_unique_ptr<VoiceArray> mVoices{};
std::atomic<size_t> mActiveVoiceCount{};
void allocVoices(size_t addcount);
al::span<Voice*> getVoicesSpan() const noexcept
[[nodiscard]] auto getVoicesSpan() const noexcept -> al::span<Voice*>
{
return {mVoices.load(std::memory_order_relaxed)->data(),
mActiveVoiceCount.load(std::memory_order_relaxed)};
}
al::span<Voice*> getVoicesSpanAcquired() const noexcept
[[nodiscard]] auto getVoicesSpanAcquired() const noexcept -> al::span<Voice*>
{
return {mVoices.load(std::memory_order_acquire)->data(),
mActiveVoiceCount.load(std::memory_order_acquire)};
@@ -141,26 +130,42 @@ struct ContextBase {
using EffectSlotArray = al::FlexArray<EffectSlot*>;
std::atomic<EffectSlotArray*> mActiveAuxSlots{nullptr};
al::atomic_unique_ptr<EffectSlotArray> mActiveAuxSlots;
std::thread mEventThread;
al::semaphore mEventSem;
std::unique_ptr<RingBuffer> mAsyncEvents;
std::atomic<uint> mEnabledEvts{0u};
using AsyncEventBitset = std::bitset<al::to_underlying(AsyncEnableBits::Count)>;
std::atomic<AsyncEventBitset> mEnabledEvts{0u};
/* Asynchronous voice change actions are processed as a linked list of
* VoiceChange objects by the mixer, which is atomically appended to.
* However, to avoid allocating each object individually, they're allocated
* in clusters that are stored in a vector for easy automatic cleanup.
*/
using VoiceChangeCluster = std::unique_ptr<VoiceChange[]>;
al::vector<VoiceChangeCluster> mVoiceChangeClusters;
using VoiceChangeCluster = std::unique_ptr<std::array<VoiceChange,128>>;
std::vector<VoiceChangeCluster> mVoiceChangeClusters;
using VoiceCluster = std::unique_ptr<Voice[]>;
al::vector<VoiceCluster> mVoiceClusters;
using VoiceCluster = std::unique_ptr<std::array<Voice,32>>;
std::vector<VoiceCluster> mVoiceClusters;
using VoicePropsCluster = std::unique_ptr<VoicePropsItem[]>;
al::vector<VoicePropsCluster> mVoicePropClusters;
using VoicePropsCluster = std::unique_ptr<std::array<VoicePropsItem,32>>;
std::vector<VoicePropsCluster> mVoicePropClusters;
EffectSlot *getEffectSlot();
using EffectSlotCluster = std::unique_ptr<std::array<EffectSlot,4>>;
std::vector<EffectSlotCluster> mEffectSlotClusters;
using EffectSlotPropsCluster = std::unique_ptr<std::array<EffectSlotProps,4>>;
std::vector<EffectSlotPropsCluster> mEffectSlotPropClusters;
/* This could be greater than 2, but there should be no way there can be
* more than two context property updates in use simultaneously.
*/
using ContextPropsCluster = std::unique_ptr<std::array<ContextProps,2>>;
std::vector<ContextPropsCluster> mContextPropClusters;
ContextBase(DeviceBase *device);