Commit Graph

1141 Commits

Author SHA1 Message Date
Alexandre Ratchov c4b354abd7 Fix off-by-one array access when 64 channel stream is resampled 2021-07-05 14:18:53 +02:00
Alexandre Ratchov aac840d9f9 oss: Fix sio_setpar() when channel number is not set
The trap value set by sio_initpar() was interpreted as a channel
number, causing sio_setpar() to fail.

Found and analysed by Roman Bogorodskiy <bogorodskiy at gmail.com>,
thanks
2021-06-16 09:32:46 +02:00
Alexandre Ratchov 4d63a3b185 Merge remote-tracking branch 'refs/remotes/origin/master' 2021-05-31 15:09:49 +02:00
Alexandre Ratchov 1f42a21368 Drop assembly for 24-bit fixed-point operations
Now i386 compiler is smart enough to generate a single imul
instruction per fixed-point multiplication. This change also allows
24-bit precision to be used on all archs (if -DADATA_BITS=24 is used).

Tested on arm64 by Doug Moss <dougmoss710 at yahoo.com>, thanks

Suggested and ok naddy@
2021-05-31 15:08:02 +02:00
Alexandre Ratchov 23e9ebebc4 Use ${version} macro instead of hardcoded number 2021-05-25 06:38:12 +02:00
Alexandre Ratchov fde5ad8a68 Bump version to v1.8.0 2021-05-07 09:49:58 +02:00
Alexandre Ratchov 0cb3defc3c sndiod: Use proper mode to setup conversions
Now we need to use opt's mode instead of slot's mode as this is the
one used by dev_cycle(). Fixes monitoring mode not working in case
dev->rchan != dev->pchan
2021-04-29 15:15:33 +02:00
Alexandre Ratchov 12b31d021a sndiod: If mode not allowed in opt structure just play/record silence
This is similar to what we do when device is open and its mode doesn't
match requested mode.
2021-04-26 10:08:11 +02:00
Alexandre Ratchov e450bab99e configure: Generate .pc file with variable-prefixed paths 2021-04-23 14:22:47 +02:00
Alexandre Ratchov a26f7fdf36 configure: add autoconf-style --exec-prefix option 2021-04-23 13:42:05 +02:00
Alexandre Ratchov 90684ad458 sndiod: Allocate (free) conversion buffers in slot_attach (slot_detach)
Besides being better coding style, this allows a client to be detached
and then attached to a device with different parameters.
2021-04-23 11:12:35 +02:00
Alexandre Ratchov 9a5092b08e sndiod: Make play-only and rec-only start at the same position
This is necessary to make rec-only device properly work in
full-duplex. Fixes full-duplex clients stuck on rec-only device.
2021-04-23 11:01:05 +02:00
Alexandre Ratchov 5a20439ec8 Add forgotten sndio.pc.in template 2021-04-20 11:43:40 +02:00
Alexandre Ratchov ce7e998772 Add initial pkg-config support, from brad@ 2021-04-20 11:02:47 +02:00
Alexandre Ratchov 1649f75532 sndiod: Use chronological order for {dev,port}_list 2021-03-08 10:25:31 +01:00
Alexandre Ratchov d6a1624f29 sndiod: Initialize dev->master_enabled earlier 2021-03-08 07:14:16 +01:00
Alexandre Ratchov f712cdb11b sndiod: Style tweak: uniformize pattern to access ctlslot_array 2021-03-08 07:04:32 +01:00
Alexandre Ratchov 6869540f3b sndiod: When a slot structure is recycled allocate new control
Trying to rename the program level control is not needed anymore.
When a slot is given to another program, the new ctl_{new,del}()
functions can be used to delete the control of the old program and
create a new one for the new program. Cleaner, simpler.
2021-03-08 06:38:48 +01:00
Alexandre Ratchov 302865ddd8 sndiod: Style tweak: swap if/else code blocks in slot_new() 2021-03-08 06:06:12 +01:00
Alexandre Ratchov 5451c3c55e Move MTC/MMC to its own structure 2021-03-03 10:49:28 +01:00
Alexandre Ratchov ada702087d Move MIDI control endpoint to opt structure 2021-03-03 10:49:28 +01:00
Alexandre Ratchov bb27629080 Move controls list out of the device structure
Use a unique dynamically allocated ctl->addr key and a "scope"
enum to identify controls that belong to different devices.
2021-03-03 10:49:28 +01:00
Alexandre Ratchov 0adedb2a89 sndiod.8: Some article fixes; from eddie youseph and grep through jmc@ 2021-03-03 10:35:54 +01:00
Alexandre Ratchov a6a6dcb57c sndiod: Fix use-after-free causing crash when devices is disconnected 2021-03-03 10:31:20 +01:00
Alexandre Ratchov e5766cbfc0 sndiod: Allow alternative devices to support different modes
Currently sndiod does not allow you to use alternative devices (-F
devices) which support only a subset of the modes of the main (-f)
device.

For example, if you do `sndiod -f rsnd/0 -F rsnd/1` and:
- rsnd/0 is full-duplex (rec + play).
- rsnd/1 is play-only.

Then you will be unable to use rsnd/1 as sndiod deems it incompatible
and refuses to use it (similarly if rsnd/1 is record-only).

This is annoying. It means if you want to use a record-only or play-only
device, you will either have to kill sndiod and restart it specifying
only that device (`sndiod -f rsnd/1` for the above example), or failing
that, downgrade the functionality of the main device (`-m play`).

This diff (a joint effort between ratchov@ and myself) makes mixing
devices with different modes possible. It does this by making both
recording and playing available for all devices, even if the underlying
hardware doesn't support both modes.

For example, if I try to record from a play-only device, then recording
will succeed, but the captured PCM data will be pure silence. Similarly,
if I try to play to a record-only device, then the audio stream will
disappear into the ether.

This is mostly a no-op for sndiod in the default configuration (except
that play-only devices now accept recording clients). If you use
alternative devices (-F), then it's possible for a record-only device to
be found first, which may be confusing if you just want to hear sound.
We can only assume that if you deviate from defaults, then you know what
you are doing.

From edd@
2021-03-03 10:22:38 +01:00
Alexandre Ratchov 350db6ce41 sndiod: Disable autovol by default and set default volume to 127
The previous behavior of automatically decreasing playback volume
when new programs start playing can be achieved with '-w on'.
2021-03-03 10:16:12 +01:00
Alexandre Ratchov 7534418e78 Make audio clients use struct opt to reach the device 2021-03-03 07:43:34 +01:00
Alexandre Ratchov a78ec25e07 Make control clients use struct opt to reach the device 2021-03-03 07:43:34 +01:00
Alexandre Ratchov 1e1589d70e Rename ctlslot->mask to ctlslot->self to match the rest of the code 2021-03-03 07:43:34 +01:00
Alexandre Ratchov e891595ec7 Order opt_list in opt_new() call order, limit items to OPT_NMAX 2021-03-03 07:43:34 +01:00
Alexandre Ratchov 8e99cca36c Move the options list out of the device structure 2021-03-03 07:43:34 +01:00
Alexandre Ratchov 4710960bbe Move the control client state out of the device structure 2021-03-03 07:43:34 +01:00
Alexandre Ratchov 8bb6267fdb Move the audio clients state out of the device structure 2021-03-03 07:43:34 +01:00
Michael Forney 7551d499a8 alsa: remove existing hardware config before setting a new one
In Linux 5.11, a behavior change for USB audio devices was introduced[0]
that prevents changing parameters such as sample rate or period
size once they are initially set without a snd_pcm_hw_free in
between. This causes sndio to get forced to 48000 Hz and and a
period size of 4800, since those are the parameters set during
sio_open.

To fix this, call snd_pcm_hw_free at the start of sio_alsa_setpar_hw
to remove any previous configuration before setting a new one.

[0] https://bugzilla.kernel.org/show_bug.cgi?id=211941
2021-03-01 09:09:51 +01:00
Alexandre Ratchov ae7637d044 Add example program that generates resampling coefficients 2021-02-12 11:37:56 +01:00
Alexandre Ratchov 2cd5b8e0ab Disconnect MIDI clients controlling disconnected audio device 2021-01-28 11:11:23 +01:00
Alexandre Ratchov ea692625ea Dont attempt to drain disconnected clients 2021-01-28 11:11:23 +01:00
Alexandre Ratchov 6f741dab61 In slot_xxx(), store dev pointer in local variable 2021-01-28 11:11:23 +01:00
Alexandre Ratchov fd4c58aae7 Use everywhere the same pattern to handle fractional clock ticks
No behavior change; the code change is to make the maths easier to
proofread
2021-01-28 11:11:23 +01:00
Alexandre Ratchov 63d4639f9a Make slot_{attach,detach}() the opposite of each other
No bahavior change, but this makes the code is much easier.

Now, slot_attach() moves slot's clock forward and puts the slot on
device list; slot_detach() does the opposite: remove from device list
and move clock backwards.
2021-01-28 11:11:23 +01:00
Alexandre Ratchov ae76a1f941 Drop/move unused prototypes for slot_xxx() 2021-01-28 11:11:23 +01:00
Alexandre Ratchov ac7ddc5301 Drop unused dev_nctl() function 2021-01-27 11:57:35 +01:00
Alexandre Ratchov b1c2df5d9c aucat, sndiod: const-ify lookup tables
From naddy@
2021-01-13 17:30:19 +01:00
Alexandre Ratchov 21580f56b5 Clip 16-bit resampled signal as there's no room for filter overshoots 2021-01-11 14:46:32 +01:00
Alexandre Ratchov 2996dcdc03 Use a 8-th order FIR low-pass filter for resampling 2020-12-20 11:01:27 +01:00
Alexandre Ratchov 40cdc42e22 Check sample signedness when setting up format conversions.
Fixes confusion between s16 and u16 found in aucat and analysed by
James Cook <falsifian at falsifian.org>. Thanks.
2020-12-10 22:05:56 +01:00
Alexandre Ratchov d1c4d40cb9 Sync to OpenBSD.
Mostly the new AUDIO{REC,PLAY}DEVICE envoronment variables
and many man-page improvements.
2020-11-29 13:04:18 +01:00
Alexandre Ratchov 62bc69d71c sndioctl: Flush stdout before polling
If stdout is not flushed, output is not seen by programs using
sndioctl through a pipe (ex. "sndioctl -m | cat" displays nothing).

Patch from Érico Nogueira <ericonr@disroot.org>, idea
from Duncan Overbruck <mail@duncano.de>
2020-09-07 07:14:39 +02:00
Duncan Overbruck 7a03da2848 Add libsndio.so.${MAJ} symlink and use it as SONAME on linux
This avoids having to rebuild a lot of packages even if the
ABI did not break. cubeb used by firefox currently dlopen's
either libsndio.so.7.1 or libsndio.so, with the major link
this would also avoid having to patch this as long as the
ABI doesn't break without having to ship the libsndio.so
symlink outside of -dev/-devel packages.
2020-09-02 15:35:34 +02:00
Alexandre Ratchov c888f2750b Don't add server.device knob if there's only one audio device 2020-07-19 13:13:40 +02:00