45 Commits

Author SHA1 Message Date
Chris Robinson
d7367aeee0 Fix requeueing logic for OpenSLCapture::captureSamples
The write vector represents the chunks queued for OpenSL, and the write pointer
only increments when OpenSL fills in more samples. So requeueing from the start
of the write vector is requeueing chunks that are already queued, which is
obviously wrong. It instead needs to queue chunks that become available as
they're read.

Because the ring buffer holds more elements than can be written to at a givem
time, the read vector does not represent the next writable chunks to queue.
Advancing the read pointer increases the number of writable elements, so
instead of queueing from the read vector or the start of the write vector,
queue from the end of the write vector given the number of chunks read.
2022-05-28 06:56:41 -07:00
Chris Robinson
d9fe5a11cd Reset the ringbuffer when stopping OpenSL playback 2022-04-26 23:42:23 -07:00
Chris Robinson
593966c8db Handle 3D7.1 as a separate channel configuration
It's treated as 5.1 + 2 aux channels. This allows AL_DIRECT_CHANNELS_SOFT to
behave better, not forwarding rear left/right channel inputs to lower front and
upper rear, and allows reporting a more appropriate output mode to the app
instead of 7.1.
2022-04-26 23:32:15 -07:00
Chris Robinson
2fb7538f68 Clear capture buffers before enqueueing them with OpenSL 2022-04-08 21:46:30 -07:00
Chris Robinson
d06ed618d3 Avoid using an if_constexpr macro
It doesn't actually use if constexpr, and compilers are smart enough to
optimize. Some functions can use templates instead.
2022-02-22 03:03:44 -08:00
Chris Robinson
29fba79cd5 Avoid 5.1Rear as its own channel configuration
It messes with 5.1 sources using direct channels, and the surround channels are
supposed to map to the side labels. Individual backends can deal with the
channel order/label differences, as they already do to a degree.
2021-07-30 07:38:26 -07:00
Chris Robinson
061148072f Update include headers
Don't add alc/ to the include paths.
2021-04-27 16:04:54 -07:00
Chris Robinson
581174ef98 Use the DeviceBase for the backend 2021-04-24 09:03:14 -07:00
Chris Robinson
d2f587ee23 Move helpers.cpp to core 2021-04-22 03:15:26 -07:00
Chris Robinson
730c964029 Allow calling BackendBase::open multiple times on playback devices
It will not be called while the device is running. If the first call succeeds,
a subsequent call that happens to fail must leave the existing device state as
it was so it can be resumed.

This is a rough first pass. It will fail when trying to re-open the same device
which can only be opened once (for instance, with direct hardware access, on
hardware that doesn't do its own mixing). Some backends won't guarantee the new
device is usable until the reset() or start() call.
2021-03-08 22:29:40 -08:00
Chris Robinson
cff3693387 Use if constexpr when possible 2021-01-22 05:50:27 -08:00
Chris Robinson
5729e1004d Make the endian test more C++-like 2021-01-21 23:21:18 -08:00
Chris Robinson
229bf45e24 Avoid calling readAdvance in a loop 2021-01-17 03:17:46 -08:00
Chris Robinson
855a8c0cd9 Don't assume the ring buffer's read vector is the next writable space
This is untrue since the ring buffer leaves one element unwritten, so there's
one extra element to be written once a readable element is read.
2021-01-15 18:18:07 -08:00
Chris Robinson
eedc42890f Move alexcpt to core 2020-12-24 22:49:55 -08:00
Chris Robinson
6ae0115bf7 Avoid AL/ALC types in the backends 2020-12-17 23:21:45 -08:00
Chris Robinson
5edd5a11fc Don't use ALC error enums for the backend error code 2020-12-17 21:07:53 -08:00
Chris Robinson
4d1ac95ae2 Don't return an enum from captureSamples
It's always no_error
2020-12-17 03:06:52 -08:00
Chris Robinson
d578bc6cb1 Move logging to core 2020-12-17 02:47:03 -08:00
Eliot Miranda
e3179aa058
Add a gain argument to altonegen (#502)
* Fix a speeling rorre in an error message.
Add a gain command-line argument to altonegen.c

* Fix some formatting issues and a copy/paste error.
2020-12-04 11:15:27 -08:00
Chris Robinson
e8b3e82f96 Change a couple functions into member functions 2020-08-07 06:22:39 -07:00
Chris Robinson
6ce9bf6c94 Move a couple related functions to the backend base 2020-06-12 12:53:47 -07:00
Chris Robinson
4094135ed7 Don't return a bool from the backend start method 2020-04-28 19:25:58 -07:00
Chris Robinson
02d7fbfa0c Use standard attribute declarations 2020-04-13 23:27:56 -07:00
Chris Robinson
662d77159b Get rid of a redundant enum 2020-03-30 16:00:02 -07:00
Chris Robinson
f2ddf971df Return the enumerated device names from the backend
Rather than using an out parameter.
2020-03-30 15:37:41 -07:00
Chris Robinson
9b237790b2 Remove the mutex from the backend base 2020-03-29 23:57:37 -07:00
Chris Robinson
eb49290dab Remove unnecessary locks now that the mixer doesn't require one 2020-02-26 04:58:02 -08:00
Chris Robinson
e6e2f509f8 Make CreateRingBuffer a static RingBuffer method 2020-01-10 07:56:43 -08:00
Chris Robinson
2e6a55a87c Handle padding between device sample frames
The padding must be constant and sample type aligned (e.g. some fixed multiple
of two bytes between the start of two consecutive frames for 16-bit output).
The intent is to always have the ability for stereo output with WASAPI even if
the device has some other unsupported configuration, as long as front-left and
front-right exist.
2019-12-21 20:43:46 -08:00
Chris Robinson
630d4d573d Gracefully drain the OpenSL capture buffer on disconnect 2019-10-10 13:33:27 -07:00
Chris Robinson
b687e952ef Make C callbacks noexcept
No telling what would happen if exceptions managed to get back into presumably
C-based callers.
2019-10-09 03:29:25 -07:00
Chris Robinson
963580c2d5 Never return null from CreateRingBuffer
Allocation failure would already throw a bad_alloc anyway, now a size overflow
throws an exception too.
2019-10-08 21:55:03 -07:00
Chris Robinson
7726a06d26 Clean up some exception messages and avoid duplicate log messages 2019-10-08 05:44:38 -07:00
Chris Robinson
52a003e9bb Avoid raw lock/unlock calls 2019-10-07 23:22:06 -07:00
Chris Robinson
02d80cd74d Use exceptions for backend open failures 2019-10-07 21:37:56 -07:00
Chris Robinson
fcf850c1dd Clean up some more conversion warnings 2019-09-16 07:32:13 -07:00
Chris Robinson
e16e2269b6 Add a fallback if SLAndroidDataFormat_PCM_EX isn't available 2019-09-15 20:46:37 -07:00
Chris Robinson
c5a3c52822 Return and pass more appropriate types for backends 2019-09-15 09:50:28 -07:00
Chris Robinson
4b8f78a8d6 Fix a few more GCC warnings 2019-09-14 19:42:54 -07:00
Chris Robinson
2c348cecb6 Fix some more implicit conversions noted by GCC 2019-09-14 18:35:23 -07:00
Chris Robinson
1a9f1e0869 Fix a few more C-style casts 2019-09-11 08:08:23 -07:00
Chris Robinson
e286ec8d09 Move some declarations out of alcmain.h 2019-08-05 15:03:18 -07:00
Chris Robinson
2fa2c35bdc Modify LIKELY and UNLIKELY to not need extra parenthesis 2019-08-04 11:59:14 -07:00
Chris Robinson
cb3e96e756 Rename Alc to alc 2019-07-28 18:56:04 -07:00