143 Commits

Author SHA1 Message Date
Chris Robinson
3e62600ecc Replace some more macros with constexpr variables 2020-10-21 16:39:21 -07:00
Chris Robinson
b8f5e1f424 Change some more macros into constexpr variables 2020-10-21 10:39:00 -07:00
Chris Robinson
7b43cb8266 Declare variables closer to where they're used 2020-10-13 05:54:05 -07:00
Chris Robinson
303ca3af72 Use inline functions for popcnt and ctz instead of macros 2020-10-13 01:21:44 -07:00
Chris Robinson
1f486f820e Use a separate structure for buffer storage 2020-08-28 00:09:46 -07:00
Chris Robinson
4d9d406966 Clarify an error message 2020-05-25 02:02:50 -07:00
Chris Robinson
5bbbe8341e Use an enum class for SpatializeMode 2020-05-21 09:10:32 -07:00
Chris Robinson
cf64dc1103 Fix up some more uses of [AL[C]]void 2020-04-28 14:48:12 -07:00
Chris Robinson
a97e6e6a12 Fix the source ID for a source voice stopped from deletion 2020-04-21 01:01:18 -07:00
Chris Robinson
fc906c97f5 Track a buffer's ambisonic order 2020-04-04 01:52:29 -07:00
Chris Robinson
963d9b761b Rename ALvoice and related structs to Voice 2020-03-28 18:15:05 -07:00
Chris Robinson
d344c5a228 Avoid some extraneous uses of AL type aliases 2020-03-25 22:39:45 -07:00
Chris Robinson
a27096dd63 Dynamically allocate voice channel data
Rather than allocating for a full 8 channels for each voice, when the vast
majority will only need 1 or 2. The voice channel data is relatively big since
it needs to hold HRTF coefficients and history, and this will allow increasing
the maximum number of buffer channels without an obscene memory increase.
2020-03-25 21:06:24 -07:00
Chris Robinson
b53294e291 Use inline initialization more for sources 2020-03-23 15:04:26 -07:00
Chris Robinson
78251fd7e6 Fix voices being forced to update without valid properties
When starting a voice, the source ID was set before its first update struct was
provided, creating a small window where a listener or effect slot update could
force a voice to update without it having any valid properties to update with.
Supplying the update struct first would create a different race, where the
mixer could see a voice without a source but with an update struct, causing the
update struct to be 'freed' without being applied.

The fix here is to provide the update struct before setting the source ID, and
change the mixer to ignore update structs for voices without a source ID. This
can pseudo-orphan the updates that get set on a voice just as it stops, leaving
the struct unusable until the voice is used again, or the voice gets deleted
which will clear it. But it allows the update struct to stay in place and get
applied once the voice gets a source ID.
2020-03-04 23:18:05 -08:00
Chris Robinson
48b9b541ec Avoid redundantly setting voice members 2020-03-04 13:40:21 -08:00
Chris Robinson
971862a80c Don't change flags after InitVoice 2020-03-04 11:01:35 -08:00
Chris Robinson
e7405f7801 Use a new voice state to indicate a pending source offset change 2020-03-04 10:16:59 -08:00
Chris Robinson
08dc831e0e Avoid unnecessarily reclearing some variables 2020-03-03 20:44:19 -08:00
Chris Robinson
accc1ec1c8 Add a helper to wait for the device mix 2020-03-03 20:32:44 -08:00
Chris Robinson
a01617904c Simplify getting a voice for a new source offset 2020-02-28 20:07:43 -08:00
Chris Robinson
4555b74bd7 Use a VoiceChange object to change the offset of a playing source 2020-02-26 03:52:40 -08:00
Chris Robinson
872096958b Rename the voice's PendingStop to PendingChange 2020-02-26 01:48:59 -08:00
Chris Robinson
814f80ec59 Move voice initialization to a separate function 2020-02-26 01:39:30 -08:00
Chris Robinson
8618571866 Avoid storing the source offset when it's just read and reset 2020-02-26 01:03:23 -08:00
Chris Robinson
795c4fcecc Make the source's send array static instead of dynamic 2020-02-25 06:39:03 -08:00
Chris Robinson
7144cf405a Handle playing voices after disconnection 2020-02-24 22:21:44 -08:00
Chris Robinson
fd0ed9f33f Improve searching for the next voice when playing multiple sources
Instead of searching from the beginning of the voice list for each source, just
continue searching from the last source's voice.
2020-02-24 21:40:54 -08:00
Chris Robinson
52d86ad51f Ignore VoiceChange objects while disconnected
And try to improve ALvoice/VoiceChange handling when attempting to recover a
lost device.
2020-02-24 11:01:45 -08:00
Chris Robinson
90d45984dc Simplify replaying a source 2020-02-23 21:40:54 -08:00
Chris Robinson
a37932a0d0 Fix voice allocation increase amount 2020-02-22 18:01:34 -08:00
Chris Robinson
6044e0d7ca Remove a couple unnecessary type aliases 2020-02-22 00:08:55 -08:00
Chris Robinson
a8162a77c2 Use an array of ALvoice pointers for the active voices
This allows growing the array atomically with the mixer since the ALvoice
objects themselves don't move, and a new larger array of them can be swapped in
without blocking the mixer.
2020-02-21 20:14:28 -08:00
Chris Robinson
6e6a30679e Set the voice's property update after the source ID
Otherwise the mixer has a chance to throw it out before realizing it's needed.
2020-02-21 04:55:04 -08:00
Chris Robinson
0694df9014 Handle playing and pausing with VoiceChanges 2020-02-21 04:29:32 -08:00
Chris Robinson
9887c6971d Prepare VoiceChange objects one at a time 2020-02-21 03:23:22 -08:00
Chris Robinson
9b801227d5 Don't unnecessarily count all voices when playing sources 2020-02-21 00:54:05 -08:00
Chris Robinson
9b43327f56 Asynchronously stop and rewind voices 2020-02-20 23:53:56 -08:00
Chris Robinson
bdb8ef22b0 Asynchronously stop voices if its source is being deleted 2020-02-20 22:50:37 -08:00
Chris Robinson
acf7f6f74e Add a voice flag to indicate a voice has a pending stop
Pending/asynchronous stops to be implemented soon.
2020-02-20 19:18:07 -08:00
Chris Robinson
d4e01a1818 Flag the voice as callback-based when given a callback buffer 2020-02-17 17:34:17 -08:00
Chris Robinson
04e5b23286 Don't bother looping the calculated source offset
The offset shouldn't be in a non-wrapped state when playing, and when not
playing it's always 0 anyway.
2020-02-17 17:30:47 -08:00
Chris Robinson
d6e49b503b Don't allow setting a source offset for a callback 2020-02-17 17:20:01 -08:00
Chris Robinson
3122c3b4a1 Handle running the buffer callback in the voice 2020-02-17 17:13:25 -08:00
Chris Robinson
a221f8671e Prevent queueing a callback buffer
Also prevent setting it on multiple sources
2020-02-17 00:32:22 -08:00
Chris Robinson
8665f404a5 Always start streaming sources from the start of the queue
For sources that don't start with an offset, at least. This is necessary so the
completed buffer event will give the correct count if it starts with null or
empty buffers that become processed.
2020-02-15 22:37:19 -08:00
Chris Robinson
8a9eef70af Use struct methods to get a buffer's format info 2020-01-18 13:23:59 -08:00
Chris Robinson
cdd24c7d01 Combine identical arrays 2020-01-04 00:59:49 -08:00
Chris Robinson
701d43b41e Start a new extension for a new direct_channels state
So existing behavior remains consistent for anything that needs it, and new
behavior is opt-in.
2019-12-28 11:33:19 -08:00
Chris Robinson
863171efc9 Check the voice's ambisonic order when starting 2019-12-05 00:18:01 -08:00