aboutsummaryrefslogtreecommitdiffstats
path: root/alc/alcontext.h
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2020-12-15 17:25:45 -0800
committerChris Robinson <[email protected]>2020-12-15 18:41:50 -0800
commitdaf9d464781280d01b50994f1b157448a46dc916 (patch)
tree4e26a50b748d62ddfec726cdcc27eee502f737f9 /alc/alcontext.h
parent03358a0d8092520788690b7f143a4af098472b3f (diff)
Use a separate structure for the context/listener params
Diffstat (limited to 'alc/alcontext.h')
-rw-r--r--alc/alcontext.h47
1 files changed, 40 insertions, 7 deletions
diff --git a/alc/alcontext.h b/alc/alcontext.h
index 3699b244..37cd010d 100644
--- a/alc/alcontext.h
+++ b/alc/alcontext.h
@@ -1,6 +1,7 @@
#ifndef ALCONTEXT_H
#define ALCONTEXT_H
+#include <array>
#include <atomic>
#include <cstddef>
#include <cstdint>
@@ -20,6 +21,7 @@
#include "inprogext.h"
#include "intrusive_ptr.h"
#include "threads.h"
+#include "vecmat.h"
#include "vector.h"
#include "voice.h"
@@ -54,16 +56,47 @@ struct WetBuffer {
using WetBufferPtr = std::unique_ptr<WetBuffer>;
-struct ALcontextProps {
+struct ContextProps {
float DopplerFactor;
float DopplerVelocity;
float SpeedOfSound;
bool SourceDistanceModel;
DistanceModel mDistanceModel;
- std::atomic<ALcontextProps*> next;
+ std::atomic<ContextProps*> next;
- DEF_NEWDEL(ALcontextProps)
+ DEF_NEWDEL(ContextProps)
+};
+
+struct ListenerProps {
+ std::array<float,3> Position;
+ std::array<float,3> Velocity;
+ std::array<float,3> OrientAt;
+ std::array<float,3> OrientUp;
+ float Gain;
+ float MetersPerUnit;
+
+ std::atomic<ListenerProps*> next;
+
+ DEF_NEWDEL(ListenerProps)
+};
+
+struct ContextParams {
+ /* Pointer to the most recent property values that are awaiting an update. */
+ std::atomic<ContextProps*> ContextUpdate{nullptr};
+ std::atomic<ListenerProps*> ListenerUpdate{nullptr};
+
+ alu::Matrix Matrix{alu::Matrix::Identity()};
+ alu::Vector Velocity{};
+
+ float Gain{1.0f};
+ float MetersPerUnit{1.0f};
+
+ float DopplerFactor{1.0f};
+ float SpeedOfSound{343.3f}; /* in units per sec! */
+
+ bool SourceDistanceModel{false};
+ DistanceModel mDistanceModel{};
};
@@ -141,13 +174,11 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext> {
float mGainBoost{1.0f};
- std::atomic<ALcontextProps*> mUpdate{nullptr};
-
/* Linked lists of unused property containers, free to use for future
* updates.
*/
- std::atomic<ALcontextProps*> mFreeContextProps{nullptr};
- std::atomic<ALlistenerProps*> mFreeListenerProps{nullptr};
+ std::atomic<ContextProps*> mFreeContextProps{nullptr};
+ std::atomic<ListenerProps*> mFreeListenerProps{nullptr};
std::atomic<VoicePropsItem*> mFreeVoiceProps{nullptr};
std::atomic<EffectSlotProps*> mFreeEffectslotProps{nullptr};
@@ -212,6 +243,8 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext> {
ALlistener mListener{};
+ ContextParams mParams;
+
ALCcontext(al::intrusive_ptr<ALCdevice> device);
ALCcontext(const ALCcontext&) = delete;