diff options
author | Sven Gothel <[email protected]> | 2019-04-07 23:39:04 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2019-04-07 23:39:04 +0200 |
commit | 73233ce69919fc19c53ce8663c5b8cc05227f07e (patch) | |
tree | f2b6ccc1a14d7c387f33398a44ea4511d7ecb212 /OpenAL32/Include/alSource.h | |
parent | 8efa4c7ba5ee8eb399d31a9884e45f743d4625ad (diff) | |
parent | 99a55c445211fea77af6ab61cbc6a6ec4fbdc9b9 (diff) |
Merge branch 'v1.19' of git://repo.or.cz/openal-soft into v1.19v1.19
Diffstat (limited to 'OpenAL32/Include/alSource.h')
-rw-r--r-- | OpenAL32/Include/alSource.h | 162 |
1 files changed, 67 insertions, 95 deletions
diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index 13596161..5f07c09d 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -1,11 +1,14 @@ #ifndef _AL_SOURCE_H_ #define _AL_SOURCE_H_ -#define MAX_SENDS 4 - +#include "bool.h" #include "alMain.h" #include "alu.h" #include "hrtf.h" +#include "atomic.h" + +#define MAX_SENDS 16 +#define DEFAULT_SENDS 2 #ifdef __cplusplus extern "C" { @@ -16,96 +19,51 @@ struct ALsource; typedef struct ALbufferlistitem { - struct ALbuffer *buffer; - struct ALbufferlistitem *volatile next; - struct ALbufferlistitem *volatile prev; + ATOMIC(struct ALbufferlistitem*) next; + ALsizei max_samples; + ALsizei num_buffers; + struct ALbuffer *buffers[]; } ALbufferlistitem; -typedef struct ALvoice { - struct ALsource *volatile Source; - - /** Method to update mixing parameters. */ - ALvoid (*Update)(struct ALvoice *self, const struct ALsource *source, const ALCcontext *context); - - /** Current target parameters used for mixing. */ - ALint Step; - - ALboolean IsHrtf; - - ALuint Offset; /* Number of output samples mixed since starting. */ - - alignas(16) ALfloat PrevSamples[MAX_INPUT_CHANNELS][MAX_PRE_SAMPLES]; - - BsincState SincState; - - DirectParams Direct; - SendParams Send[MAX_SENDS]; -} ALvoice; - - typedef struct ALsource { /** Source properties. */ - volatile ALfloat Pitch; - volatile ALfloat Gain; - volatile ALfloat OuterGain; - volatile ALfloat MinGain; - volatile ALfloat MaxGain; - volatile ALfloat InnerAngle; - volatile ALfloat OuterAngle; - volatile ALfloat RefDistance; - volatile ALfloat MaxDistance; - volatile ALfloat RollOffFactor; - aluVector Position; - aluVector Velocity; - aluVector Direction; - volatile ALfloat Orientation[2][3]; - volatile ALboolean HeadRelative; - volatile ALboolean Looping; - volatile enum DistanceModel DistanceModel; - volatile ALboolean DirectChannels; - - volatile ALboolean DryGainHFAuto; - volatile ALboolean WetGainAuto; - volatile ALboolean WetGainHFAuto; - volatile ALfloat OuterGainHF; - - volatile ALfloat AirAbsorptionFactor; - volatile ALfloat RoomRolloffFactor; - volatile ALfloat DopplerFactor; - - volatile ALfloat Radius; - - /** - * Last user-specified offset, and the offset type (bytes, samples, or - * seconds). - */ - ALdouble Offset; - ALenum OffsetType; - - /** Source type (static, streaming, or undetermined) */ - volatile ALint SourceType; - - /** Source state (initial, playing, paused, or stopped) */ - volatile ALenum state; - ALenum new_state; - - /** - * Source offset in samples, relative to the currently playing buffer, NOT - * the whole queue, and the fractional (fixed-point) offset to the next - * sample. + ALfloat Pitch; + ALfloat Gain; + ALfloat OuterGain; + ALfloat MinGain; + ALfloat MaxGain; + ALfloat InnerAngle; + ALfloat OuterAngle; + ALfloat RefDistance; + ALfloat MaxDistance; + ALfloat RolloffFactor; + ALfloat Position[3]; + ALfloat Velocity[3]; + ALfloat Direction[3]; + ALfloat Orientation[2][3]; + ALboolean HeadRelative; + ALboolean Looping; + enum DistanceModel DistanceModel; + enum Resampler Resampler; + ALboolean DirectChannels; + enum SpatializeMode Spatialize; + + ALboolean DryGainHFAuto; + ALboolean WetGainAuto; + ALboolean WetGainHFAuto; + ALfloat OuterGainHF; + + ALfloat AirAbsorptionFactor; + ALfloat RoomRolloffFactor; + ALfloat DopplerFactor; + + /* NOTE: Stereo pan angles are specified in radians, counter-clockwise + * rather than clockwise. */ - ALuint position; - ALuint position_fraction; - - /** Source Buffer Queue info. */ - ATOMIC(ALbufferlistitem*) queue; - ATOMIC(ALbufferlistitem*) current_buffer; - RWLock queue_lock; + ALfloat StereoPan[2]; - /** Current buffer sample info. */ - ALuint NumChannels; - ALuint SampleSize; + ALfloat Radius; /** Direct filter and auxiliary send info. */ struct { @@ -122,22 +80,36 @@ typedef struct ALsource { ALfloat HFReference; ALfloat GainLF; ALfloat LFReference; - } Send[MAX_SENDS]; + } *Send; + + /** + * Last user-specified offset, and the offset type (bytes, samples, or + * seconds). + */ + ALdouble Offset; + ALenum OffsetType; + + /** Source type (static, streaming, or undetermined) */ + ALint SourceType; + + /** Source state (initial, playing, paused, or stopped) */ + ALenum state; + + /** Source Buffer Queue head. */ + ALbufferlistitem *queue; - /** Source needs to update its mixing parameters. */ - ATOMIC(ALenum) NeedsUpdate; + ATOMIC_FLAG PropsClean; + + /* Index into the context's Voices array. Lazily updated, only checked and + * reset when looking up the voice. + */ + ALint VoiceIdx; /** Self ID */ ALuint id; } ALsource; -inline struct ALsource *LookupSource(ALCcontext *context, ALuint id) -{ return (struct ALsource*)LookupUIntMapKey(&context->SourceMap, id); } -inline struct ALsource *RemoveSource(ALCcontext *context, ALuint id) -{ return (struct ALsource*)RemoveUIntMapKey(&context->SourceMap, id); } - -ALvoid SetSourceState(ALsource *Source, ALCcontext *Context, ALenum state); -ALboolean ApplyOffset(ALsource *Source); +void UpdateAllSourceProps(ALCcontext *context); ALvoid ReleaseALSources(ALCcontext *Context); |