aboutsummaryrefslogtreecommitdiffstats
path: root/OpenAL32/alListener.h
blob: a71db9f887c961014dfdf1ba7972140a4eedc4a7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef AL_LISTENER_H
#define AL_LISTENER_H

#include <array>
#include <atomic>

#include "AL/al.h"
#include "AL/alc.h"

#include "vecmat.h"

enum class DistanceModel;


struct ALlistenerProps {
    std::array<ALfloat,3> Position;
    std::array<ALfloat,3> Velocity;
    std::array<ALfloat,3> OrientAt;
    std::array<ALfloat,3> OrientUp;
    ALfloat Gain;

    std::atomic<ALlistenerProps*> next;
};

struct ALlistener {
    std::array<ALfloat,3> Position{{0.0f, 0.0f, 0.0f}};
    std::array<ALfloat,3> Velocity{{0.0f, 0.0f, 0.0f}};
    std::array<ALfloat,3> OrientAt{{0.0f, 0.0f, -1.0f}};
    std::array<ALfloat,3> OrientUp{{0.0f, 1.0f, 0.0f}};
    ALfloat Gain{1.0f};

    std::atomic_flag PropsClean;

    /* Pointer to the most recent property values that are awaiting an update.
     */
    std::atomic<ALlistenerProps*> Update{nullptr};

    struct {
        alu::Matrix Matrix;
        alu::Vector Velocity;

        ALfloat Gain;
        ALfloat MetersPerUnit;

        ALfloat DopplerFactor;
        ALfloat SpeedOfSound; /* in units per sec! */
        ALfloat ReverbSpeedOfSound; /* in meters per sec! */

        ALboolean SourceDistanceModel;
        DistanceModel mDistanceModel;
    } Params;

    ALlistener() { PropsClean.test_and_set(std::memory_order_relaxed); }
};

void UpdateListenerProps(ALCcontext *context);

#endif