OpenBSD CVS

CVS log for src/usr.bin/sndiod/sndiod.c


[BACK] Up to [local] / src / usr.bin / sndiod

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.49 / (download) - annotate - [select for diffs], Fri May 3 05:18:09 2024 UTC (2 weeks, 2 days ago) by ratchov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.48: +87 -24 lines
Diff to previous 1.48 (colored)

sndiod: Fix SIGHUP to reopen the devices in priority order

With this commit, SIGHUP makes sndiod discover new devices and if
there is a new device with higher priority (greater -F option number)
than the current one, sndiod switches to it.  If the current device is
already the one with the highest priority (i.e. last -F), then SIGHUP
does nothing.

Revision 1.48 / (download) - annotate - [select for diffs], Mon Mar 7 08:58:33 2022 UTC (2 years, 2 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5, OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3, OPENBSD_7_2_BASE, OPENBSD_7_2, OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.47: +13 -2 lines
Diff to previous 1.47 (colored)

Switch internal sample representation to 24-bit fixed-point.

The default device precision doesn't change (yet), i.e. we still
request the usual 16-bit mode, when available. Hardware supporting
24-bit samples only gets end-to-end 24-bit processing by default.

ok kettenis

Revision 1.47 / (download) - annotate - [select for diffs], Mon Nov 1 14:43:25 2021 UTC (2 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.46: +72 -26 lines
Diff to previous 1.46 (colored)

Stop binding audio devices exposed by sndiod to physical devices

This a shift towards a new model: clients connect to logical devices
(created with -s option) then the server routes data to/from the
underlying physical device (registered with -f option). The binding
may be changed at run-time with the server.device control exposed by
sndioctl(1).

As audio devices exposed by sndiod(8) are not bound to fixed physical
devices anymore, the physical audio device number component of
sndio(7) descriptors was removed.

fixes, help from and ok denis, edd

Revision 1.46 / (download) - annotate - [select for diffs], Mon Jul 12 15:09:20 2021 UTC (2 years, 10 months ago) by beck
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.45: +2 -2 lines
Diff to previous 1.45 (colored)

Change the error reporting pattern throughout the tree when unveil
fails to report the path that the failure occured on. Suggested by
deraadt@ after some tech discussion.

Work done and verified by Ashton Fagg <ashton@fagg.id.au>

ok deraadt@ semarie@ claudio@

Revision 1.45 / (download) - annotate - [select for diffs], Mon Mar 8 09:42:50 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.44: +17 -14 lines
Diff to previous 1.44 (colored)

sndiod: Use chronological order for {dev,port}_list

This simplifies the logic of the initialization code, makes debug
printfs nicer and could slightly ease futur development.

No behavior change.

Revision 1.44 / (download) - annotate - [select for diffs], Fri Feb 5 17:59:33 2021 UTC (3 years, 3 months ago) by jcs
Branch: MAIN
Changes since 1.43: +3 -3 lines
Diff to previous 1.43 (colored)

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'.

ok ratchov, patrick

Revision 1.43 / (download) - annotate - [select for diffs], Fri Jan 29 11:21:00 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.42: +3 -1 lines
Diff to previous 1.42 (colored)

Move the options list out of the device structure

No behavior change. Later this will ease applying the configuration of
one device to another by "just" swapping pointers.

Revision 1.42 / (download) - annotate - [select for diffs], Fri Jan 29 10:51:24 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.41: +3 -1 lines
Diff to previous 1.41 (colored)

Move the audio clients state out of the device structure

No behavior change. Later this will ease moving clients from one
device to another by "just" swapping pointers.

Revision 1.41 / (download) - annotate - [select for diffs], Thu Jun 18 05:11:13 2020 UTC (3 years, 11 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.40: +10 -8 lines
Diff to previous 1.40 (colored)

Don't try to open device that's already open

Save the current alternate device index and skip it in
dev_reopen(). Handling alternate device indices this way will ease
future development as well.

Revision 1.40 / (download) - annotate - [select for diffs], Sat Apr 25 05:35:52 2020 UTC (4 years ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.39: +20 -13 lines
Diff to previous 1.39 (colored)

If no -f options are used, expose first 4 audio(4) devices to clients

Revision 1.39 / (download) - annotate - [select for diffs], Wed Apr 1 16:54:17 2020 UTC (4 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.38: +15 -2 lines
Diff to previous 1.38 (colored)

If no -q options are used, expose first 8 midi(4) devices to sndiod clients

Revision 1.38 / (download) - annotate - [select for diffs], Wed Feb 26 13:53:58 2020 UTC (4 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.37: +4 -2 lines
Diff to previous 1.37 (colored)

Add API to control audio device parameters exposed by sndiod.

The API exposes controls of modern audio hardware and sndiod software
volume knobs in a uniform way.  Hardware knobs are exposed through
sndiod.  Multiple programs may use the controls at the same time
without the need to continuously scan the controls.

For now sndiod exposes only its own controls and the master output and
input volumes of the underlying hardware (if any), i.e. those
typically exposed by acpi volume keys.

ok deraadt

Revision 1.37 / (download) - annotate - [select for diffs], Sat Sep 21 04:52:07 2019 UTC (4 years, 7 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.36: +2 -2 lines
Diff to previous 1.36 (colored)

Lower the default audio block size from 20ms to 10ms.

Then new default block size is supported by virtually all devices
which allows switching between devices without further configuration.
The buffer size remains the same, so this change won't affect audio
stability.

ok mpi@

Revision 1.36 / (download) - annotate - [select for diffs], Sat Sep 21 04:42:46 2019 UTC (4 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.35: +51 -12 lines
Diff to previous 1.35 (colored)

Allow switching between devices without disconnecting clients.

The new -F option allows alternate device to be specified.  If the
device is disconnected, the one given with the last -f or -F options
will be used instead. Similarly, the new -Q option allows an alternate
MIDI port to be specified.

ok mpi@

Revision 1.35 / (download) - annotate - [select for diffs], Sat Jun 29 21:23:18 2019 UTC (4 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.34: +19 -19 lines
Diff to previous 1.34 (colored)

Check if syscalls return -1 instead of any negative or non-zero value.

ok deraadt

Revision 1.34 / (download) - annotate - [select for diffs], Wed Aug 8 22:31:43 2018 UTC (5 years, 9 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4
Changes since 1.33: +22 -1 lines
Diff to previous 1.33 (colored)

Use unveil(2) in the helper process to disallow access to other files
than the devices specified with -f and -q options.

ok deraadt@

Revision 1.33 / (download) - annotate - [select for diffs], Tue Jun 26 07:12:35 2018 UTC (5 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.32: +3 -5 lines
Diff to previous 1.32 (colored)

Replace the gloal opt list with per-device lists.

Revision 1.32 / (download) - annotate - [select for diffs], Thu Oct 20 05:48:50 2016 UTC (7 years, 7 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.31: +122 -118 lines
Diff to previous 1.31 (colored)

Move initialization of the helper process in its own routine to make
code more readable. No bahavior change.

Revision 1.31 / (download) - annotate - [select for diffs], Wed Mar 23 06:16:35 2016 UTC (8 years, 1 month ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.30: +4 -4 lines
Diff to previous 1.30 (colored)

Remove unused arguments of dev_adjpar(), getbasepath() and all
slotops->onvol() implementations. From David CARLIER <devnexen at
gmail.com>. Thanks.

Revision 1.30 / (download) - annotate - [select for diffs], Sat Jan 9 10:06:57 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.29: +2 -0 lines
Diff to previous 1.29 (colored)

Check in advance that the socket path is a directory and report the
error if it isn't. Fixes ugly/delayed error messages in this case.

Revision 1.29 / (download) - annotate - [select for diffs], Sat Jan 9 08:57:34 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.28: +3 -3 lines
Diff to previous 1.28 (colored)

Remove trailing '\n' from strings passed to err(1)

Revision 1.28 / (download) - annotate - [select for diffs], Fri Jan 8 16:17:31 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.27: +7 -6 lines
Diff to previous 1.27 (colored)

Make code fit in 80 columns, remove trailing spaces & tabs.

Revision 1.27 / (download) - annotate - [select for diffs], Fri Jan 8 15:55:05 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.26: +17 -3 lines
Diff to previous 1.26 (colored)

move code to add a midi port in a new mkport() routine

Revision 1.26 / (download) - annotate - [select for diffs], Fri Jan 8 13:56:33 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.25: +7 -5 lines
Diff to previous 1.25 (colored)

Make mkopt() return NULL on failure

Revision 1.25 / (download) - annotate - [select for diffs], Fri Jan 8 13:32:17 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.24: +18 -6 lines
Diff to previous 1.24 (colored)

Unbreak support for multiple -L options.

Revision 1.24 / (download) - annotate - [select for diffs], Fri Jan 8 13:19:34 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.23: +0 -1 lines
Diff to previous 1.23 (colored)

No need to include sys/queue.h

Revision 1.23 / (download) - annotate - [select for diffs], Fri Jan 8 13:14:11 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.22: +6 -3 lines
Diff to previous 1.22 (colored)

Make listen_new_xxx() routines return NULL on failure and check the
returned value wheneverer they are called.

Revision 1.22 / (download) - annotate - [select for diffs], Wed Dec 23 20:12:18 2015 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.21: +9 -0 lines
Diff to previous 1.21 (colored)

Add pledge calls to both "helper" and "worker" processes.

ok deraadt, semarie

Revision 1.21 / (download) - annotate - [select for diffs], Wed Dec 23 12:24:12 2015 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.20: +2 -3 lines
Diff to previous 1.20 (colored)

fix false-positive "uninitialized" gcc warning

Revision 1.20 / (download) - annotate - [select for diffs], Wed Dec 23 12:20:24 2015 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.19: +30 -14 lines
Diff to previous 1.19 (colored)

Call getpwname() earlier, and if it fails, return the proper
exit code, so that the failure gets reported by /etc/rc.

Revision 1.19 / (download) - annotate - [select for diffs], Mon Dec 21 22:03:47 2015 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.18: +0 -2 lines
Diff to previous 1.18 (colored)

Don't attempt to remove unix socket as it's owned by root and
we've already dropped root privileges.

Revision 1.18 / (download) - annotate - [select for diffs], Sun Dec 20 11:38:33 2015 UTC (8 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.17: +107 -53 lines
Diff to previous 1.17 (colored)

In case of a bug in sndiod, an attacker (a local user) could run
arbitrary code as user _sndio, i.e. get a second uid.

Mitigate the risk by implementing initial privilege separation as
follows. Break sndiod in two processes: a chroot()ed "worker" process
processing input, and a non-chroot()ed "helper" process opening
devices and passing descriptors to the worker.

With help from benno, claudio, semarie and gilles.

ok benno, semarie and tb

Revision 1.17 / (download) - annotate - [select for diffs], Thu Nov 26 12:35:37 2015 UTC (8 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.16: +16 -26 lines
Diff to previous 1.16 (colored)

Cleanup in the opposite order as initialization, inline privdrop()
function. No behaviour change.

Revision 1.16 / (download) - annotate - [select for diffs], Tue Nov 24 12:14:08 2015 UTC (8 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.15: +2 -4 lines
Diff to previous 1.15 (colored)

remove unused test when handling of -U option

Revision 1.15 / (download) - annotate - [select for diffs], Mon Nov 23 12:33:20 2015 UTC (8 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.14: +2 -5 lines
Diff to previous 1.14 (colored)

Remove unused -M option (2+ years get used to it is enough)

Revision 1.14 / (download) - annotate - [select for diffs], Mon Nov 23 12:01:04 2015 UTC (8 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.13: +5 -3 lines
Diff to previous 1.13 (colored)

Save and restore umask when creating /tmp/aucat/ to ensure the
directory gets the right permissions, as we do in other places.

Revision 1.13 / (download) - annotate - [select for diffs], Sun Nov 22 16:52:06 2015 UTC (8 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.12: +11 -7 lines
Diff to previous 1.12 (colored)

Disallow multiple -L options and remove the constraint -U to
be used before -L. No behaviour change as -L is still disabled.

Revision 1.12 / (download) - annotate - [select for diffs], Wed Nov 18 08:36:20 2015 UTC (8 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.11: +5 -1 lines
Diff to previous 1.11 (colored)

disable networking (i.e. -L option) until privilege separation is
implemented

Revision 1.11 / (download) - annotate - [select for diffs], Fri Oct 2 12:21:59 2015 UTC (8 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.10: +2 -2 lines
Diff to previous 1.10 (colored)

Replace %s in the format string, with its value (macro).

Revision 1.10 / (download) - annotate - [select for diffs], Fri Oct 2 09:36:24 2015 UTC (8 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.9: +5 -5 lines
Diff to previous 1.9 (colored)

As the socket path is known, use its size rather that PATH_MAX.

Revision 1.9 / (download) - annotate - [select for diffs], Fri Oct 2 09:21:46 2015 UTC (8 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.8: +4 -4 lines
Diff to previous 1.8 (colored)

use macros instead of hard-coded strings for unix sockets paths

Revision 1.8 / (download) - annotate - [select for diffs], Sun Apr 26 17:26:59 2015 UTC (9 years ago) by dcoppa
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.7: +2 -2 lines
Diff to previous 1.7 (colored)


Fix typo in the buffer size value: 7680 in the manpage vs 7860 in
the sndiod.c code.
Initially, I thought the error was in the manpage, but Alexander
told me it was the code, so fix the code instead.

ok ratchov@

Revision 1.7 / (download) - annotate - [select for diffs], Fri Jan 16 06:40:12 2015 UTC (9 years, 4 months ago) by deraadt
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.6: +1 -2 lines
Diff to previous 1.6 (colored)

Replace <sys/param.h> with <limits.h> and other less dirty headers where
possible.  Annotate <sys/param.h> lines with their current reasons.  Switch
to PATH_MAX, NGROUPS_MAX, HOST_NAME_MAX+1, LOGIN_NAME_MAX, etc.  Change
MIN() and MAX() to local definitions of MINIMUM() and MAXIMUM() where
sensible to avoid pulling in the pollution.  These are the files confirmed
through binary verification.
ok guenther, millert, doug (helped with the verification protocol)

Revision 1.6 / (download) - annotate - [select for diffs], Wed Mar 5 20:24:16 2014 UTC (10 years, 2 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.5: +1 -3 lines
Diff to previous 1.5 (colored)

remove unused "autostart" feature

Revision 1.5 / (download) - annotate - [select for diffs], Mon Nov 18 17:37:45 2013 UTC (10 years, 6 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.4: +17 -1 lines
Diff to previous 1.4 (colored)

add missing prototypes

Revision 1.4 / (download) - annotate - [select for diffs], Sat Dec 1 12:06:14 2012 UTC (11 years, 5 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4, OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.3: +27 -11 lines
Diff to previous 1.3 (colored)

Parse "-m mode1,mode2,.. " strings strictly.

Revision 1.3 / (download) - annotate - [select for diffs], Fri Nov 30 21:04:35 2012 UTC (11 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.2: +2 -2 lines
Diff to previous 1.2 (colored)

use the hold flag for midi ports as well

Revision 1.2 / (download) - annotate - [select for diffs], Fri Nov 23 07:25:07 2012 UTC (11 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.1: +5 -2 lines
Diff to previous 1.1 (colored)

add a -M flag that does nothing; allows setups with -M in sndiod_flags
to work.

Revision 1.1 / (download) - annotate - [select for diffs], Fri Nov 23 07:03:28 2012 UTC (11 years, 5 months ago) by ratchov
Branch: MAIN

Remplace aucat server by a new sndiod daemon aimed to be simpler
smaller and faster than aucat. It's a drop in replacement with the
following exceptions that don't affect the default setup:
  - The sample rate and the encoding are a per-device parameters
    thus -r and -e options must precede the corresponding -f option
  - MIDI thru boxes are dynamically created and no -M option
    is required anymore, so -M was removed.
  - MIDI ports are exposed with a new ``midi/N'' name, rather
    than abusing MIDI thru boxes.
with help from armani@, ok deraadt@

This form allows you to request diff's between any two revisions of a file. You may select a symbolic revision name using the selection box or you may type in a numeric name using the type-in text box.