OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.27 / (download) - annotate - [select for diffs], Tue Apr 2 05:32:10 2024 UTC (6 weeks, 4 days ago) by ratchov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.26: +2 -1 lines
Diff to previous 1.26 (colored)

sndiod: Migrate clients upon watchdog timeout

When -F is used, fixes the difference in behavior between watchdog
timer expiry and other errors.

Revision 1.26 / (download) - annotate - [select for diffs], Fri Apr 29 08:30:48 2022 UTC (2 years 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
Changes since 1.25: +2 -2 lines
Diff to previous 1.25 (colored)

Add sio_flush(3) function to stop playback immediately

The new sio_flush(3) functions works the same way as sio_stop(3),
except that it doesn't wait for play buffer to be drained. Instead,
it discards its contents and returns immediately.

Revision 1.25 / (download) - annotate - [select for diffs], Mon Nov 1 14:43:25 2021 UTC (2 years, 6 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.24: +48 -168 lines
Diff to previous 1.24 (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.24 / (download) - annotate - [select for diffs], Wed Mar 3 10:00:27 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0, OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.23: +4 -5 lines
Diff to previous 1.23 (colored)

sndiod: Move controls out of the device structure

Moving to a global server-wide controls list is necessary to expose
controls that are not associated to a particular device (ex. a device
selector).

The current hack to use the device-side sioctl_desc->addr variable as
client-side key can't work anymore. So, we use a unique dynamically
allocated ctl->addr key; this is much cleaner. A new "scope" enum
(with two "void *" arguments) is used to determine what the control
does control. This adds flexibility and allows to easily add new
control types that are not associated to devices.

No behavior change.

Revision 1.23 / (download) - annotate - [select for diffs], Tue Mar 2 12:15:46 2021 UTC (3 years, 2 months ago) by edd
Branch: MAIN
Changes since 1.22: +75 -62 lines
Diff to previous 1.22 (colored)

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.

With guidance from, and OK ratchov@, thanks!

Revision 1.22 / (download) - annotate - [select for diffs], Sun Jun 28 05:21:39 2020 UTC (3 years, 10 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.21: +14 -1 lines
Diff to previous 1.21 (colored)

Allow switching between alternate devices (-F option) with sndioctl(1)

Revision 1.21 / (download) - annotate - [select for diffs], Thu Jun 18 05:11:13 2020 UTC (3 years, 11 months ago) by ratchov
Branch: MAIN
Changes since 1.20: +10 -13 lines
Diff to previous 1.20 (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.20 / (download) - annotate - [select for diffs], Fri Jun 12 15:40:18 2020 UTC (3 years, 11 months ago) by ratchov
Branch: MAIN
Changes since 1.19: +3 -3 lines
Diff to previous 1.19 (colored)

On error, drop clients and close the device only if it's still open

Fixes crashes when USB devices are disconnected, caused by an attempt
to close the already closed device: it was closed once when its ref
counter drops to zero (after the last client is disconnected) and once
with an explicit call to dev_close() on the error code-path.

Revision 1.19 / (download) - annotate - [select for diffs], Fri Apr 24 11:33:28 2020 UTC (4 years ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_7_BASE, OPENBSD_6_7
Changes since 1.18: +13 -2 lines
Diff to previous 1.18 (colored)

Make sure devices are properly closed in case of an error.

Fixes possible crashes if the contol device fails, while the audio
device continues to work.

Revision 1.18 / (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.17: +37 -6 lines
Diff to previous 1.17 (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.17 / (download) - annotate - [select for diffs], Thu Jan 23 05:40:09 2020 UTC (4 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.16: +36 -5 lines
Diff to previous 1.16 (colored)

When opening a device, loop over the alternate devices list in the
worker process instead of the helper process. It is simpler this way
and allows the worker to properly log which device is being used.

Revision 1.16 / (download) - annotate - [select for diffs], Sat Sep 21 04:42:46 2019 UTC (4 years, 7 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_6_BASE, OPENBSD_6_6
Changes since 1.15: +77 -3 lines
Diff to previous 1.15 (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.15 / (download) - annotate - [select for diffs], Thu Aug 29 07:05:47 2019 UTC (4 years, 8 months ago) by ratchov
Branch: MAIN
Changes since 1.14: +8 -8 lines
Diff to previous 1.14 (colored)

Uniformize device-specific debug printfs

Revision 1.14 / (download) - annotate - [select for diffs], Thu Jul 20 10:23:45 2017 UTC (6 years, 10 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_5_BASE, OPENBSD_6_5, OPENBSD_6_4_BASE, OPENBSD_6_4, OPENBSD_6_3_BASE, OPENBSD_6_3, OPENBSD_6_2_BASE, OPENBSD_6_2
Changes since 1.13: +1 -1 lines
Diff to previous 1.13 (colored)

Fix debug printf used to report kernel bugs: print par.bps instead
of par.bits. Found by coverity.

Revision 1.13 / (download) - annotate - [select for diffs], Thu Oct 27 04:37:47 2016 UTC (7 years, 6 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.12: +1 -1 lines
Diff to previous 1.12 (colored)

Fix many typos in comments, from Michael W. Bombardieri <mb at ii.net>

Revision 1.12 / (download) - annotate - [select for diffs], Wed May 25 10:24:24 2016 UTC (7 years, 11 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.11: +0 -8 lines
Diff to previous 1.11 (colored)

Don't warn when read or write block at cycle boundary, this may
happen when remote devices are used and is not an error.

Revision 1.11 / (download) - annotate - [select for diffs], Fri Jan 8 16:17:31 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.10: +3 -3 lines
Diff to previous 1.10 (colored)

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

Revision 1.10 / (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.9: +5 -4 lines
Diff to previous 1.9 (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.9 / (download) - annotate - [select for diffs], Fri Jul 24 08:46:35 2015 UTC (8 years, 9 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8
Changes since 1.8: +2 -2 lines
Diff to previous 1.8 (colored)

Crank watchdog timeout from 2 to 4 seconds.

Revision 1.8 / (download) - annotate - [select for diffs], Fri Jul 24 08:43:58 2015 UTC (8 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.7: +7 -1 lines
Diff to previous 1.7 (colored)

Log when device is disconnected.

Revision 1.7 / (download) - annotate - [select for diffs], Fri Jul 24 08:43:04 2015 UTC (8 years, 9 months ago) by ratchov
Branch: MAIN
Changes since 1.6: +2 -1 lines
Diff to previous 1.6 (colored)

Clear watchdog timer when device is closed, fixes use-after-free in
error code-paths when device is closed before audio is stopped.

Revision 1.6 / (download) - annotate - [select for diffs], Mon Feb 16 06:28:05 2015 UTC (9 years, 3 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_7_BASE, OPENBSD_5_7
Changes since 1.5: +2 -2 lines
Diff to previous 1.5 (colored)

add missing protos, fix spacing

Revision 1.5 / (download) - annotate - [select for diffs], Wed Oct 8 16:44:47 2014 UTC (9 years, 7 months ago) by ratchov
Branch: MAIN
Changes since 1.4: +63 -1 lines
Diff to previous 1.4 (colored)

check audio parameters returned by the audio drivers,
and nicely report driver bugs rather than crashing/misbehaving
later if parameters aren't consistent.

Revision 1.4 / (download) - annotate - [select for diffs], Mon Mar 17 17:16:06 2014 UTC (10 years, 2 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.3: +2 -2 lines
Diff to previous 1.3 (colored)

unbreak monitoring mode, which was shifted in time by 1 block

Revision 1.3 / (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.2: +3 -1 lines
Diff to previous 1.2 (colored)

add missing prototypes

Revision 1.2 / (download) - annotate - [select for diffs], Fri Feb 1 09:06:27 2013 UTC (11 years, 3 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.1: +19 -1 lines
Diff to previous 1.1 (colored)

if a device doesn't respond within two seconds, then just close it
and drop all connections. This is shameful but unfortunately it's
still necessery on certain MP machines and audio driver combinations

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.