408 Commits

Author SHA1 Message Date
Chris Robinson
cb9fb31214 Store filters in an array of lists 2018-01-27 19:40:47 -08:00
Chris Robinson
6a839600b9 Use a vector to store the effect slot pointers
And make the ID a simple index into it (1-base, to avoid ID 0).
2018-01-27 19:04:32 -08:00
Chris Robinson
031cf24880 Use an array lookup for source IDs
This is now similar to buffers, being stored in groups of 64 in a vector with
the ID providing the array indices.
2018-01-27 14:34:05 -08:00
Chris Robinson
38261a0f2a Make some more functions static where they're used 2018-01-27 14:34:05 -08:00
Chris Robinson
9613b4bfe2 Use a different method for storing and looking up buffers
Rather than each buffer being individually allocated with a generated 'thunk'
ID that's used with a uint:ptr map, buffers are allocated in arrays of 64
within a vector. Each group of 64 has an associated 64-bit mask indicating
which are free to use, and the buffer ID is comprised of the two array indices
which directly locate the buffer (no searching, binary or otherwise).

Currently no buffers are actually deallocated after being allocated, though
they are reused. So an app that creates a ton of buffers once, then deletes
them all and uses only a couple from then on, will have a bit of waste, while
an app that's more consistent with the number of used buffers won't be a
problem. This can be improved by removing elements of the containing vector
that contain all-free buffers while there are plenty of other free buffers.

Also, this method can easily be applied to other resources, like sources.
2018-01-27 01:51:01 -08:00
Chris Robinson
99f0377ae3 Construct error messages using parameterized values 2018-01-25 15:59:59 -08:00
Chris Robinson
2ded5547ba Provide messages for the remaining AL errors 2018-01-24 17:07:01 -08:00
Chris Robinson
786a05876e Call the event callback when an error is generated
Most errors don't yet provide correct object IDs or text messages for the AL
error.
2018-01-24 12:10:48 -08:00
Chris Robinson
4f9a0460c4 Add a flag for persistent mapping
And a function to "flush" a mapped buffer
2018-01-23 10:38:27 -08:00
Chris Robinson
5f3ae527c9 More cleanup for buffer loading
Don't bother with unnecessary and unused converters, and remove some
unsupported queries.
2018-01-21 23:35:28 -08:00
Chris Robinson
03d4e4acc4 Add methods to "map" a buffer's storage
Requires the MAP_READ_BIT or MAP_WRITE_BIT flags to be OR'd with the format
upon a call to alBufferData, to enable mappable storage for the given access
types. This will fail if the format requires internal conversion and doesn't
resemble the original input data, so the app can be guaranteed the size, type,
and layout of the original data is the same as what's in storage.

Then alMapBufferSOFT may be called with appropriate bit flags to get a readable
and/or writable pointer to the buffer's sample storage. alUnmapBufferSOFT must
be called when access is finished. It is currently invalid to map a buffer that
is attached to a source, or to attach a buffer to a source that is currently
mapped. This restriction may be eased in the future, at least to allow read-
only access while in use (perhaps also to allow writing, if coherency can be
achieved).

Currently the access flags occupy the upper 8 bits of a 32-bit bitfield to
avoid clashing with format enum values, which don't use more than 16 or 17
bits. This means any future formats are limited to 24-bit enum values, and also
means only 8 flags are possible when declaring storage. The alternative would
be to add a new function (alBufferStorage?) with a separate flags parameter.
2018-01-20 11:49:01 -08:00
Chris Robinson
248832b266 Use a voice flag to indicate it being static 2018-01-16 18:07:59 -08:00
Chris Robinson
30007263e5 Allow storing multiple buffers in a ALbufferlistitem
This will be to allow buffer layering, multiple buffers of the same format and
sample rate that are mixed together prior to resampling, filtering, and
panning. This will allow composing sounds from individual components that can
be swapped around on different invocations (e.g. layer SoundA and SoundB on one
instance and SoundA and SoundC on a different instance for a slightly different
sound, then just SoundA for a third instance, and so on). The longest buffer
within the list item determines the length of the list item.

More work needs to be done to fully support it, namely the ability to specity
multiple buffers to layer for static and streaming sources. Also the behavior
of loop points for layered static sources should be worked out. Should also
consider allowing each layer to have a sample offset.
2017-12-15 22:59:51 -08:00
Chris Robinson
32f72c7471 Add queries to get the source offset with the device clock 2017-12-03 14:45:19 -08:00
Chris Robinson
1ab8902621 Re-update effect slots when context properties change
Also keep all free property update structs together in the context instead of
per-object.
2017-09-27 11:13:18 -07:00
Chris Robinson
a35b9bbd3e Don't force a fade-in when resuming a paused source
This needs to be handled more automatically by the mixer to work correctly.
Otherwise, requiring a property update on resume can put the source into a
playing state with the mixer never playing it, due to not having valid mixing
parameters and the mixing parameters not getting calculated because no updates
are specified by the app (and forcing an update can break deferred updates).
2017-06-09 13:32:34 -07:00
Chris Robinson
db6f14748c Rename RollOff to Rolloff 2017-05-05 04:54:07 -07:00
Chris Robinson
9c9ad2f60a Start an extension to change the source's spatialize property 2017-05-05 02:41:34 -07:00
Chris Robinson
b639bc9913 Add a property to force source spatialization on or off 2017-05-04 12:27:10 -07:00
Chris Robinson
2f8d597f4e Rename 'moving' flag to 'fading' 2017-05-02 04:09:01 -07:00
Chris Robinson
afe2065d60 Set a voice as 'moving' if it starts/resumes at an offset 2017-05-02 03:58:18 -07:00
Chris Robinson
a0a41921fc Remove const from _Atomic vars to make Clang happy
Clang does not allow using C11's atomic_load on const _Atomic variables.
Previously it just disabled use of C11 atomics if atomic_load didn't work on a
const _Atomic variable, but I think I'd prefer to have Clang use C11 atomics
for the added features (more explicit memory ordering) even if it means a few
instances of breaking const.
2017-04-21 16:58:55 -07:00
Chris Robinson
d2d5f1d7bd Add the ability to change the source resampler 2017-04-21 15:48:39 -07:00
Chris Robinson
26b49c54af Store the resampler as part of the source 2017-04-21 00:06:40 -07:00
Chris Robinson
63baa3b1c7 Missed a raw atomic variable access 2017-04-20 03:14:49 -07:00
Chris Robinson
5dcbb8db38 Make the buffer list next pointer atomic 2017-04-19 19:54:17 -07:00
Chris Robinson
55011d4bfd Use a different way to get the size of structs with flexible array members 2017-04-18 14:11:15 -07:00
Chris Robinson
de62ab97e9 Store the source queue head in the voice to signify looping
This removes the need to access a couple more source fields in the mixer, and
also makes the looping and queue fields non-atomic.
2017-04-18 00:58:33 -07:00
Chris Robinson
14bc7baeb7 Store the source prop updates with the mixer voice
Also move its declaration and rename it for consistency.
2017-04-17 21:16:01 -07:00
Chris Robinson
f94fa5d5cf Use separate atomic macros for pointers 2017-04-14 17:47:55 -07:00
Chris Robinson
aef774a7a0 Handle the source offset fraction as an ALsizei 2017-04-08 14:29:08 -07:00
Chris Robinson
b78ddc7ef7 Make sure the mix is done after setting the looping property 2017-04-02 06:40:56 -07:00
Chris Robinson
1aca344688 Fix handling of the PropsClean flags 2017-03-23 19:32:53 -07:00
Chris Robinson
5404b2225a Add some comments for ALsource functions 2017-03-23 01:16:13 -07:00
Chris Robinson
cdfe0d8f5a Use an atomic flag to test if a source needs to update 2017-03-20 21:25:39 -07:00
Chris Robinson
e06cf07ab0 Break up a function and move the code to where it's called 2017-03-19 16:49:23 -07:00
Chris Robinson
ecfa1dcb6f Don't defer source state or offset changes 2017-03-19 13:48:40 -07:00
Chris Robinson
cdf63b553f Avoid doing sequential load for the source state 2017-03-12 19:27:51 -07:00
Chris Robinson
feffe1e81a Make the voice's 'moving' state a bitflag 2017-03-11 06:26:05 -08:00
Chris Robinson
583d431947 Implement NFC filters for Ambisonic rendering
NFC filters currently only work when rendering to ambisonic buffers, which
includes HQ rendering and ambisonic output. There are two new config options:
'decoder/nfc' (default on) enables or disables use of NFC filters globally, and
'decoder/nfc-ref-delay' (default 0) specifies the reference delay parameter for
NFC-HOA rendering with ambisonic output (a value of 0 disables NFC).

Currently, NFC filters rely on having an appropriate value set for
AL_METERS_PER_UNIT to get the correct scaling. HQ rendering uses the averaged
speaker distances as a control/reference, and currently doesn't correct for
individual speaker distances (if the speakers are all equidistant, this is
fine, otherwise per-speaker correction should be done as well).
2017-03-10 04:35:32 -08:00
Chris Robinson
5ffb0842ac Remove unnecessary atomic members 2017-03-08 04:59:22 -08:00
Chris Robinson
b1b3a369ef Remove an unnecessary variable 2017-03-07 09:38:33 -08:00
Chris Robinson
b64da108a9 Check that a source is actually playing before setting paused
Also slightly refactor setting playing state when the device is disconnected or
there's no buffers to play.
2017-03-07 04:50:09 -08:00
Chris Robinson
190120dfd7 Store the channel count and sample size in the voice 2017-03-07 00:19:40 -08:00
Chris Robinson
bc0096365e Don't modify the source state in the mixer 2017-03-07 00:19:40 -08:00
Chris Robinson
1b3100ab9a Remove an unused function 2017-03-07 00:19:40 -08:00
Chris Robinson
073829f26a Make the voice's source pointer atomic 2017-03-05 04:50:27 -08:00
Chris Robinson
6d7a790183 Add a boolean to specify if a voice should be playing 2017-03-02 01:02:40 -08:00
Chris Robinson
45d6c34015 Avoid standard malloc for buffer queue entries 2017-02-27 20:43:16 -08:00
Chris Robinson
5c859af24e Move the current buffer queue entry and play position to the voice
This has a couple behavioral changes. First and biggest is that querying
AL_BUFFERS_PROCESSED from a source will always return all buffers processed
when in an AL_STOPPED state. Previously all buffers would be set as processed
when first becoming stopped, but newly queued buffers would *not* be indicated
as processed. That old behavior was not compliant with the spec, which
unequivocally states "On a source in the AL_STOPPED state, all buffers are
processed."

Secondly, querying AL_BUFFER on an AL_STREAMING source will now always return
0. Previously it would return the current "active" buffer in the queue, but
there's no basis for that in the spec.
2017-02-27 15:35:15 -08:00