Sync to OpenBSD.

Mostly the new AUDIO{REC,PLAY}DEVICE envoronment variables
and many man-page improvements.
This commit is contained in:
Alexandre Ratchov 2020-11-29 13:04:18 +01:00
parent 62bc69d71c
commit d1c4d40cb9
4 changed files with 111 additions and 64 deletions

View File

@ -53,7 +53,12 @@ sio_open(const char *str, unsigned int mode, int nbio)
if (str == NULL) /* backward compat */ if (str == NULL) /* backward compat */
str = devany; str = devany;
if (strcmp(str, devany) == 0 && !issetugid()) { if (strcmp(str, devany) == 0 && !issetugid()) {
str = getenv("AUDIODEVICE"); if ((mode & SIO_PLAY) == 0)
str = getenv("AUDIORECDEVICE");
if ((mode & SIO_REC) == 0)
str = getenv("AUDIOPLAYDEVICE");
if (mode == (SIO_PLAY | SIO_REC) || str == NULL)
str = getenv("AUDIODEVICE");
if (str == NULL) if (str == NULL)
str = devany; str = devany;
} }

View File

@ -34,7 +34,8 @@
.Nm sio_eof , .Nm sio_eof ,
.Nm sio_setvol , .Nm sio_setvol ,
.Nm sio_onvol , .Nm sio_onvol ,
.Nm sio_initpar .Nm sio_initpar ,
.Nm SIO_BPS
.Nd sndio interface to audio devices .Nd sndio interface to audio devices
.Sh SYNOPSIS .Sh SYNOPSIS
.In sndio.h .In sndio.h
@ -80,8 +81,8 @@
.Fc .Fc
.Ft "void" .Ft "void"
.Fn sio_initpar "struct sio_par *par" .Fn sio_initpar "struct sio_par *par"
.\"Fd #define SIO_BPS(bits) .Ft unsigned int
.\"Fd #define SIO_LE_NATIVE .Fn SIO_BPS "unsigned int bits"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
.Nm sndio .Nm sndio
@ -270,7 +271,7 @@ To ease filling the
structure, the structure, the
following macros can be used: following macros can be used:
.Bl -tag -width "SIO_BPS(bits)" .Bl -tag -width "SIO_BPS(bits)"
.It Dv SIO_BPS Ns Pq Fa bits .It Fn SIO_BPS bits
Return the smallest value for Return the smallest value for
.Fa bps .Fa bps
that is a power of two and that is large enough to that is a power of two and that is large enough to
@ -280,6 +281,7 @@ hold
Can be used to set the Can be used to set the
.Fa le .Fa le
parameter when native byte order is required. parameter when native byte order is required.
It is 1 if the native byte order is little endian or 0 otherwise.
.El .El
.Ss Getting device capabilities .Ss Getting device capabilities
There's no way to get an exhaustive list of all parameter There's no way to get an exhaustive list of all parameter
@ -385,17 +387,17 @@ bitmasks should always be used.
.Ss Starting and stopping the device .Ss Starting and stopping the device
The The
.Fn sio_start .Fn sio_start
function puts the device in a waiting state: function prepares the device to start.
the device will wait for playback data to be provided Once the play buffer is full, i.e.\&
(using the .Fa sio_par.bufsz
.Fn sio_write samples are queued with
function). .Fn sio_write ,
Once enough data is queued to ensure that play buffers playback starts automatically.
will not underrun, actual playback is started automatically. If record-only mode is selected, then
If record mode only is selected, then recording starts .Fn sio_start
immediately. starts recording immediately.
In full-duplex mode, playback and recording will start In full-duplex mode, playback and recording will start
synchronously as soon as enough data to play is available. synchronously as soon as the play buffer is full.
.Pp .Pp
The The
.Fn sio_stop .Fn sio_stop
@ -579,7 +581,7 @@ parameter of the
structure, the audio subsystem will behave as follows: structure, the audio subsystem will behave as follows:
.Bl -tag -width "SIO_IGNORE" .Bl -tag -width "SIO_IGNORE"
.It Dv SIO_IGNORE .It Dv SIO_IGNORE
The devices pauses during overruns and underruns, The device pauses during overruns and underruns,
thus the current position (obtained through thus the current position (obtained through
.Fn sio_onmove ) .Fn sio_onmove )
stops being incremented. stops being incremented.
@ -735,10 +737,17 @@ The debug level:
may be a value between 0 and 2. may be a value between 0 and 2.
.El .El
.Sh SEE ALSO .Sh SEE ALSO
.Xr mio_open 3 ,
.Xr sioctl_open 3 ,
.Xr audio 4 , .Xr audio 4 ,
.Xr sndio 7 , .Xr sndio 7 ,
.Xr sndiod 8 , .Xr sndiod 8 ,
.Xr audio 9 .Xr audio 9
.Sh HISTORY
These functions first appeared in
.Ox 4.5 .
.Sh AUTHORS
.An Alexandre Ratchov Aq Mt ratchov@openbsd.org
.Sh BUGS .Sh BUGS
The The
.Xr audio 4 .Xr audio 4

View File

@ -19,7 +19,7 @@
.Os .Os
.Sh NAME .Sh NAME
.Nm sndio .Nm sndio
.Nd interface to audio and MIDI .Nd audio and MIDI device descriptors
.Sh DESCRIPTION .Sh DESCRIPTION
Programs access audio and MIDI hardware using the Programs access audio and MIDI hardware using the
.Nm sndio .Nm sndio
@ -62,8 +62,9 @@ Additionally,
exposes a MIDI port used to control audio programs using exposes a MIDI port used to control audio programs using
standard MIDI Machine Control (MMC), MIDI Time Code (MTC), standard MIDI Machine Control (MMC), MIDI Time Code (MTC),
and master volume messages. and master volume messages.
.Sh AUDIO AND MIDI DESCRIPTORS .Ss Server device descriptors
From the user's perspective every audio device or MIDI port From the user's perspective, every audio device or MIDI port exposed by
.Xr sndiod 8
has a descriptor of the form: has a descriptor of the form:
.Bd -literal -offset center .Bd -literal -offset center
type[@hostname][,servnum]/devnum[.option] type[@hostname][,servnum]/devnum[.option]
@ -77,14 +78,6 @@ The type of the audio device or MIDI port.
Possible values are: Possible values are:
.Pp .Pp
.Bl -tag -width "midithru" -offset 3n -compact .Bl -tag -width "midithru" -offset 3n -compact
.It Cm rsnd
Raw
.Xr audio 4
device.
.It Cm rmidi
Raw
.Xr midi 4
port.
.It Cm snd .It Cm snd
Audio device exposed by Audio device exposed by
.Xr sndiod 8 . .Xr sndiod 8 .
@ -94,8 +87,6 @@ MIDI thru port created with
.It Cm midi .It Cm midi
MIDI port exposed by MIDI port exposed by
.Xr sndiod 8 . .Xr sndiod 8 .
.It Cm default
Default audio device or MIDI port (see below).
.El .El
.It Ar hostname .It Ar hostname
The hostname or address where the remote The hostname or address where the remote
@ -113,47 +104,49 @@ Useful only if multiple
servers are running on the same system. servers are running on the same system.
.It Ar devnum .It Ar devnum
Device number. Device number.
For hardware audio or MIDI ports, this corresponds to It corresponds to the number of the corresponding
the character device minor number. .Fl f
For audio devices or MIDI ports created with or
.Fl q
option on the
.Xr sndiod 8 .Xr sndiod 8
it corresponds to the number of the corresponding command line.
.Fl fq
option on the command line.
.It Ar option .It Ar option
Corresponds to the sub-device string registered using the Corresponds to the sub-device string registered using the
.Fl s .Fl s
option of option of
.Xr sndiod 8 . .Xr sndiod 8 .
.El .El
.Ss Raw device descriptors
Every raw audio device or MIDI port has a descriptor of the form:
.Pp .Pp
For example: .D1 Ar type Ns / Ns Ar devnum
.Pp .Pp
.Bl -tag -width "snd/0.rear" -offset 3n -compact The
.It Li rsnd/0 .Ar type
Raw access to first audio device. can be either
.It Li rmidi/5 .Cm rsnd
Raw access to MIDI port number 5. or
.It Li snd/0 .Cm rmidi .
Audio device referred by first The rsnd/0 device descriptor accesses the
.Fl f .Pa /dev/audio0
option of device, rsnd/1 accesses
.Xr sndiod 8 . .Pa /dev/audio1 ,
.It Li snd/0.rear and so on.
Sub-device registered with Similarly, rmidi/0 accesses
.Fl s Fa rear . .Pa /dev/rmidi0
.It Li midithru/0 and so on.
First MIDI thru port created with .Ss Default Audio and MIDI devices
.Xr sndiod 8 . When no audio device descriptor is provided to a program
.El or when the reserved word
.Sh DEFAULTS
If
.Cm default .Cm default
is used as the audio device, the program will use the is used as the audio device, the program will use the
one specified in the one specified in the
.Ev AUDIODEVICE .Ev AUDIODEVICE , AUDIOPLAYDEVICE
environment variable. and/or
If it is not set, the program first tries to connect to .Ev AUDIORECDEVICE
environment variables.
If they are not set, the program first tries to connect to
.Li snd/0 . .Li snd/0 .
If that fails, it then tries to use If that fails, it then tries to use
.Li rsnd/0 . .Li rsnd/0 .
@ -175,7 +168,7 @@ is running, this allows programs to exchange MIDI data on
machines with no MIDI hardware by default, e.g. a MIDI player machines with no MIDI hardware by default, e.g. a MIDI player
could use a software synthesizer with no manual configuration could use a software synthesizer with no manual configuration
required. required.
.Sh AUTHENTICATION .Ss Authentication
For privacy reasons only one user may have connections to For privacy reasons only one user may have connections to
.Xr sndiod 8 .Xr sndiod 8
at a given time. at a given time.
@ -190,10 +183,20 @@ and contains 128 bits of raw random data.
If a session needs to be shared between multiple users, they If a session needs to be shared between multiple users, they
can connect to the server using the same cookie. can connect to the server using the same cookie.
.Sh ENVIRONMENT .Sh ENVIRONMENT
.Bl -tag -width "AUDIODEVICEXXX" -compact .Bl -tag -width "AUDIOPLAYDEVICE" -compact
.It Ev AUDIODEVICE .It Ev AUDIODEVICE
Audio device descriptor to use Audio device descriptor to use
when no descriptor is explicitly specified to a program. when no descriptor is explicitly specified to a program.
.It Ev AUDIOPLAYDEVICE
Audio device descriptor to use for play-only mode
when no descriptor is explicitly specified to a program.
Overrides
.Ev AUDIODEVICE .
.It Ev AUDIORECDEVICE
Audio device descriptor to use for record-only mode
when no descriptor is explicitly specified to a program.
Overrides
.Ev AUDIODEVICE .
.It Ev MIDIDEVICE .It Ev MIDIDEVICE
MIDI port descriptor to use MIDI port descriptor to use
when no descriptor is explicitly specified to a program. when no descriptor is explicitly specified to a program.
@ -207,9 +210,31 @@ if the program has the set-user-ID or set-group-ID bits set.
.It Pa ~/.sndio/cookie .It Pa ~/.sndio/cookie
User's session authentication cookie. User's session authentication cookie.
.It Pa /dev/audioN .It Pa /dev/audioN
Audio devices. Raw audio devices.
.It Pa /dev/rmidiN .It Pa /dev/rmidiN
MIDI ports. Raw MIDI ports.
.El
.Sh EXAMPLES
.Bl -tag -width "snd/0.rear" -compact
.It Li snd/0
Audio device referred to by the first
.Fl f
option of
.Xr sndiod 8 .
.It Li snd/0.rear
Sub-device registered with
.Dq -s rear .
.It Li midithru/0
First MIDI thru port created with
.Xr sndiod 8 .
.It Li default
Default audio or MIDI device.
.It Li rsnd/0
Direct hardware access to
.Pa /dev/audio0 .
.It Li rmidi/5
Direct hardware access to
.Pa /dev/rmidi5 .
.El .El
.Sh SEE ALSO .Sh SEE ALSO
.Xr aucat 1 , .Xr aucat 1 ,

View File

@ -72,8 +72,8 @@ The set of available controls depends on the audio device.
Commands use the following two formats to display and change Commands use the following two formats to display and change
controls respectively: controls respectively:
.Pp .Pp
.Dl group/stream[channel].function .Dl [group/]stream[channel].function
.Dl group/stream[channel].function=value .Dl [group/]stream[channel].function=value
.Pp .Pp
On the left-hand side are specified the control group (if any), On the left-hand side are specified the control group (if any),
the affected stream name, and the optional channel number. the affected stream name, and the optional channel number.
@ -119,5 +119,13 @@ Toggle the above
control: control:
.Pp .Pp
.Dl $ sndioctl output.mute=! .Dl $ sndioctl output.mute=!
.Pp
Allow audio recording and set all
.Cm input
channels to 50%:
.Bd -literal -offset indent
# sysctl kern.audio.record=1
$ sndioctl input.mute=0 input.level=0.5
.Ed
.Sh SEE ALSO .Sh SEE ALSO
.Xr sioctl_open 3 .Xr sioctl_open 3