OpenBSD CVS

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


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

Request diff between arbitrary revisions


Default branch: MAIN


Revision 1.113 / (download) - annotate - [select for diffs], Mon May 6 05:37:26 2024 UTC (13 days, 9 hours ago) by ratchov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.112: +3 -3 lines
Diff to previous 1.112 (colored)

sndiod: Ignore server.device settings to a non-working device

Revision 1.112 / (download) - annotate - [select for diffs], Mon Apr 22 11:01:02 2024 UTC (3 weeks, 6 days ago) by ratchov
Branch: MAIN
Changes since 1.111: +4 -3 lines
Diff to previous 1.111 (colored)

sndiod: Use resampling algorithm from aucat

sndiod doesn't use partial blocks as aucat, but having the same
algorithm makes code review and testing easier.

Revision 1.111 / (download) - annotate - [select for diffs], Mon Apr 22 10:57:36 2024 UTC (3 weeks, 6 days ago) by ratchov
Branch: MAIN
Changes since 1.110: +1 -3 lines
Diff to previous 1.110 (colored)

sndiod: Drop duplicate prototype of dev_new()

Revision 1.110 / (download) - annotate - [select for diffs], Mon Apr 22 10:43:16 2024 UTC (3 weeks, 6 days ago) by ratchov
Branch: MAIN
Changes since 1.109: +4 -1 lines
Diff to previous 1.109 (colored)

sndiod: Call ctlslot->ops->sync() after every control update

This ensures that the final NULL sioctl_ondesc() call-back
call is not lost.

Revision 1.109 / (download) - annotate - [select for diffs], Mon Apr 22 10:39:51 2024 UTC (3 weeks, 6 days ago) by ratchov
Branch: MAIN
Changes since 1.108: +6 -3 lines
Diff to previous 1.108 (colored)

sndiod: Return the number of controls ctl_del() has deleted.

Revision 1.108 / (download) - annotate - [select for diffs], Tue Apr 2 05:21:32 2024 UTC (6 weeks, 5 days ago) by ratchov
Branch: MAIN
Changes since 1.107: +2 -2 lines
Diff to previous 1.107 (colored)

sndiod: Fix confusion between the slot and ctlslot pointers

Fixes crash when the device is disconnected and the clients are not
migrated to another device.

Revision 1.107 / (download) - annotate - [select for diffs], Sat Dec 9 22:12:03 2023 UTC (5 months, 1 week ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_7_5_BASE, OPENBSD_7_5
Changes since 1.106: +2 -2 lines
Diff to previous 1.106 (colored)

Fix wrong call to slot->ops->exit() causing server to abort.

ok kn@

Revision 1.106 / (download) - annotate - [select for diffs], Mon Dec 26 19:16:03 2022 UTC (16 months, 3 weeks ago) by jmc
Branch: MAIN
CVS Tags: OPENBSD_7_4_BASE, OPENBSD_7_4, OPENBSD_7_3_BASE, OPENBSD_7_3
Changes since 1.105: +4 -4 lines
Diff to previous 1.105 (colored)

spelling fixes; from paul tagliamonte
amendments to his diff are noted on tech

Revision 1.105 / (download) - annotate - [select for diffs], Fri Apr 29 09:12:57 2022 UTC (2 years ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_7_2_BASE, OPENBSD_7_2
Changes since 1.104: +9 -3 lines
Diff to previous 1.104 (colored)

Wait until the buffer is drained before closing the device

Fixes last few samples not being played when very large buffers
are used.

Revision 1.104 / (download) - annotate - [select for diffs], Tue Mar 15 05:53:37 2022 UTC (2 years, 2 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_7_1_BASE, OPENBSD_7_1
Changes since 1.103: +2 -2 lines
Diff to previous 1.103 (colored)

Fix crash caused by confusion between requested device and last used one

Found by and ok semarie@

Revision 1.103 / (download) - annotate - [select for diffs], Mon Nov 1 14:43:24 2021 UTC (2 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.102: +245 -178 lines
Diff to previous 1.102 (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.102 / (download) - annotate - [select for diffs], Mon May 3 04:29:50 2021 UTC (3 years ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_7_0_BASE, OPENBSD_7_0
Changes since 1.101: +35 -26 lines
Diff to previous 1.101 (colored)

If mode is not allowed in struct opt, then just play/record silence

This is similar to what we already do when device is opened and its
mode doesn't match requested mode. Besides adding consistency, this
change would allow client's opt structure to be changed dynamically.

Revision 1.101 / (download) - annotate - [select for diffs], Wed Apr 28 05:10:29 2021 UTC (3 years ago) by ratchov
Branch: MAIN
Changes since 1.100: +4 -14 lines
Diff to previous 1.100 (colored)

sndiod: Attach client at the same position, regardless the device mode

This is necessary to make rec-only devices properly work in
full-duplex. Fixes full-duplex clients stuck on rec-only device.

Revision 1.100 / (download) - annotate - [select for diffs], Wed Apr 28 05:05:05 2021 UTC (3 years ago) by ratchov
Branch: MAIN
Changes since 1.99: +40 -35 lines
Diff to previous 1.99 (colored)

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.

Revision 1.99 / (download) - annotate - [select for diffs], Wed Mar 10 08:22:25 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_9_BASE, OPENBSD_6_9
Changes since 1.98: +8 -27 lines
Diff to previous 1.98 (colored)

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.

Revision 1.98 / (download) - annotate - [select for diffs], Wed Mar 10 08:21:27 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.97: +16 -16 lines
Diff to previous 1.97 (colored)

sndiod: Style tweak: swap if/else code blocks in slot_new()

Revision 1.97 / (download) - annotate - [select for diffs], Mon Mar 8 09:42:50 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.96: +6 -4 lines
Diff to previous 1.96 (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.96 / (download) - annotate - [select for diffs], Mon Mar 8 09:38:36 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.95: +2 -2 lines
Diff to previous 1.95 (colored)

sndiod: Initialize dev->master_enabled earlier

This is better style as since recently dev->master_enabled is used by
the ctlslot_xxx family functions which -- in the future -- could be
called with the device closed.

No behavior change.

Revision 1.95 / (download) - annotate - [select for diffs], Mon Mar 8 09:35:08 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.94: +6 -4 lines
Diff to previous 1.94 (colored)

sndiod: Style tweak: uniformize pattern to access ctlslot_array

Revision 1.94 / (download) - annotate - [select for diffs], Wed Mar 3 10:19:06 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.93: +111 -107 lines
Diff to previous 1.93 (colored)

sndiod: Move MTC/MMC state to its own global structure

Revision 1.93 / (download) - annotate - [select for diffs], Wed Mar 3 10:13:06 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.92: +28 -157 lines
Diff to previous 1.92 (colored)

sndiod: Move MIDI control endpoint to opt structure

No behavior change.

Revision 1.92 / (download) - annotate - [select for diffs], Wed Mar 3 10:00:27 2021 UTC (3 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.91: +276 -165 lines
Diff to previous 1.91 (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.91 / (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.90: +41 -41 lines
Diff to previous 1.90 (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.90 / (download) - annotate - [select for diffs], Tue Feb 2 11:18:57 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.89: +5 -5 lines
Diff to previous 1.89 (colored)

Fix use-after-free in dev_abort()

Fixes crash that can occur when an usb device is unplugged, found by edd@

Revision 1.89 / (download) - annotate - [select for diffs], Fri Jan 29 11:38:23 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.88: +38 -37 lines
Diff to previous 1.88 (colored)

Make audio clients use struct opt to reach the device

No behavior change. This decreases the number of explicit references
to the dev structure

Revision 1.88 / (download) - annotate - [select for diffs], Fri Jan 29 11:36:44 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.87: +9 -9 lines
Diff to previous 1.87 (colored)

Make control clients use struct opt to reach the device

No behavior change. This decreases the number of explicit references
to the dev structure.

Revision 1.87 / (download) - annotate - [select for diffs], Fri Jan 29 11:31:28 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.86: +4 -4 lines
Diff to previous 1.86 (colored)

Rename ctlslot->mask to ctlslot->self to match the rest of the code

No binary change.

Revision 1.86 / (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.85: +1 -4 lines
Diff to previous 1.85 (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.85 / (download) - annotate - [select for diffs], Fri Jan 29 10:55:19 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.84: +9 -13 lines
Diff to previous 1.84 (colored)

Move the control client state out of the device structure

No behavior change. Later this will ease changing the controlled
device by "just" swapping pointers.

Revision 1.84 / (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.83: +55 -35 lines
Diff to previous 1.83 (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.83 / (download) - annotate - [select for diffs], Thu Jan 28 11:17:58 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.82: +3 -1 lines
Diff to previous 1.82 (colored)

When an audio device is disconnected, drop MIDI clients controlling it

Revision 1.82 / (download) - annotate - [select for diffs], Thu Jan 28 11:15:31 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.81: +6 -5 lines
Diff to previous 1.81 (colored)

Dont attempt to drain disconnected clients

Clients are always drained before they disconnect, so this change
affects programs that die unexpectedly or loose thier network
connection.

Besides the bad style, this change fixes a theoretical bug when the
disconnected client slot could be recycled and given to another client
while it's being drained

Revision 1.81 / (download) - annotate - [select for diffs], Thu Jan 28 11:10:00 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.80: +9 -16 lines
Diff to previous 1.80 (colored)

In slot_xxx(), store dev pointer in local variable

This removes many redundant dereferences to obtain the dev pointer
from the slot stucture and makes the source slightly more readable.
No behavior change.

Revision 1.80 / (download) - annotate - [select for diffs], Thu Jan 28 11:06:58 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.79: +9 -3 lines
Diff to previous 1.79 (colored)

Use everywhere the same pattern to handle fractional clock ticks

No behavior change; this change is only to make the maths easier to
proofread

Revision 1.79 / (download) - annotate - [select for diffs], Thu Jan 28 11:06:07 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.78: +56 -16 lines
Diff to previous 1.78 (colored)

Make slot_{attach,detach}() the opposite of each other

No bahavior change. 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. This will allow to detach a
client and attach it later in exactly the same state.

Revision 1.78 / (download) - annotate - [select for diffs], Thu Jan 28 11:02:28 2021 UTC (3 years, 3 months ago) by ratchov
Branch: MAIN
Changes since 1.77: +1 -18 lines
Diff to previous 1.77 (colored)

Drop unused dev_nctl() function and few unused prototypes

Revision 1.77 / (download) - annotate - [select for diffs], Sun Jul 19 11:13:35 2020 UTC (3 years, 10 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_8_BASE, OPENBSD_6_8
Changes since 1.76: +10 -7 lines
Diff to previous 1.76 (colored)

Don't add server.device knob if there's only one audio device

Revision 1.76 / (download) - annotate - [select for diffs], Sun Jul 19 11:07:14 2020 UTC (3 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.75: +2 -2 lines
Diff to previous 1.75 (colored)

Fix initial alternate device number

The initial alternate device number was set to 1 (instead of -1),
causing device number 1 to be skipped the first time sndiod is used.

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

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

Revision 1.74 / (download) - annotate - [select for diffs], Sun Jun 28 05:17:25 2020 UTC (3 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.73: +3 -2 lines
Diff to previous 1.73 (colored)

Add a new SIOCTL_SEL control type to select one of a predefined set of
mutually exclusive values. It's the same as SIOCTL_LIST except that
exactly one list element may be selected.

Revision 1.73 / (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.72: +30 -4 lines
Diff to previous 1.72 (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.72 / (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.71: +6 -5 lines
Diff to previous 1.71 (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.71 / (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.70: +3 -19 lines
Diff to previous 1.70 (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.70 / (download) - annotate - [select for diffs], Thu Apr 16 12:26:55 2020 UTC (4 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.69: +78 -13 lines
Diff to previous 1.69 (colored)

If available, use hardware "output.level" for volume control.

With this change, there's a single outputs.level control: either the
hardware one or software one. Consequently, there can't be control
name clashes and there's no need to move hardware's top-level controls
into the "hw/" group.

Revision 1.69 / (download) - annotate - [select for diffs], Thu Apr 16 12:23:53 2020 UTC (4 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.68: +12 -4 lines
Diff to previous 1.68 (colored)

Hide controls of unused slots from "mixer" clients.

Revision 1.68 / (download) - annotate - [select for diffs], Wed Apr 15 14:22:29 2020 UTC (4 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.67: +6 -4 lines
Diff to previous 1.67 (colored)

Don't forget to notify clients when a control is removed

Revision 1.67 / (download) - annotate - [select for diffs], Wed Apr 15 14:21:35 2020 UTC (4 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.66: +4 -1 lines
Diff to previous 1.66 (colored)

Properly log CTL_NONE controls

Revision 1.66 / (download) - annotate - [select for diffs], Tue Mar 31 06:29:05 2020 UTC (4 years, 1 month ago) by ratchov
Branch: MAIN
Changes since 1.65: +2 -2 lines
Diff to previous 1.65 (colored)

Don't send "control changed" messages when hardware controls are set.

This sends twice the "control changed" messages because a second
message will be sent upon the notification from the hardware.

Revision 1.65 / (download) - annotate - [select for diffs], Sun Mar 8 14:52:20 2020 UTC (4 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.64: +13 -1 lines
Diff to previous 1.64 (colored)

Don't forget to notify clients when controls list is ready.

This is needed because when devices are swapped, clients need to know
when to rebuild their user interface.

Revision 1.64 / (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.63: +353 -8 lines
Diff to previous 1.63 (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.63 / (download) - annotate - [select for diffs], Fri Jan 10 19:01:55 2020 UTC (4 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.62: +22 -12 lines
Diff to previous 1.62 (colored)

Unbreak channel duplication (aka -j option).

Fix from Peter Piwowarski <peterjpiwowarski at gmail.com> with few
tweaks from me. Thanks.

Revision 1.62 / (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.61: +72 -3 lines
Diff to previous 1.61 (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.61 / (download) - annotate - [select for diffs], Thu Sep 19 05:10:19 2019 UTC (4 years, 8 months ago) by ratchov
Branch: MAIN
Changes since 1.60: +17 -20 lines
Diff to previous 1.60 (colored)

Don't attempt to join/expand nonexistent channels.

If the (hardware) device has fewer channels than the exposed
sub-device, then join/expand only to channels that exist on the
device.

Revision 1.60 / (download) - annotate - [select for diffs], Thu Sep 19 05:04:34 2019 UTC (4 years, 8 months ago) by ratchov
Branch: MAIN
Changes since 1.59: +46 -21 lines
Diff to previous 1.59 (colored)

Move device slot convertions setup in its own routine.

No behabior change.

Revision 1.59 / (download) - annotate - [select for diffs], Thu Sep 19 05:02:27 2019 UTC (4 years, 8 months ago) by ratchov
Branch: MAIN
Changes since 1.58: +17 -17 lines
Diff to previous 1.58 (colored)

Move device buffer allocation to its own routines.

This makes the code more readable and the routine available for other
uses. No behavior change.

Revision 1.58 / (download) - annotate - [select for diffs], Thu Aug 29 07:38:15 2019 UTC (4 years, 8 months ago) by ratchov
Branch: MAIN
Changes since 1.57: +13 -3 lines
Diff to previous 1.57 (colored)

Split dev_close() routine in two parts.

The first part disconnects clients, the other closes the device
and frees audio buffers. No behavior change.

Revision 1.57 / (download) - annotate - [select for diffs], Thu Aug 29 07:35:25 2019 UTC (4 years, 8 months ago) by ratchov
Branch: MAIN
Changes since 1.56: +25 -15 lines
Diff to previous 1.56 (colored)

Split dev_open() in two parts.

The first part resets audio parameters to the prefered ones, the
second part opens the device and allocates the audio buffers. No
behavior change.

Revision 1.56 / (download) - annotate - [select for diffs], Thu Aug 29 07:10:27 2019 UTC (4 years, 8 months ago) by ratchov
Branch: MAIN
Changes since 1.55: +2 -1 lines
Diff to previous 1.55 (colored)

Move code de disconnect all MIDI clients to its own routine.

This makes the routine reusable, no behavior change.

Revision 1.55 / (download) - annotate - [select for diffs], Thu Aug 29 07:07:33 2019 UTC (4 years, 8 months ago) by ratchov
Branch: MAIN
Changes since 1.54: +19 -10 lines
Diff to previous 1.54 (colored)

Move code de disconnect all audio clients to its own routine.

This makes the routine reusable, no behavior change.

Revision 1.54 / (download) - annotate - [select for diffs], Fri Jul 12 06:30:55 2019 UTC (4 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.53: +15 -3 lines
Diff to previous 1.53 (colored)

Add affinity between the program and its mixer control.

Currently, if there are two instances of the same program, sndiod will
allocate one volume control to each. If both programs disconnect and
reconnect, the information of which control is assigned to which
program is lost. This makes difficult to run two instances of a player
and crossfade between each other with a MIDI controller.

To address this, the program chooses a 32-bit "id" (for now the
process pid) and sends it to the server. The server records the id in
the client's slot structure.  When the server accepts a new
connection, it uses the id to identify the slot the client used during
the previous connection; if it was not recycled yet, it's assigned to
the program.

Revision 1.53 / (download) - annotate - [select for diffs], Wed Jul 10 14:30:39 2019 UTC (4 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.52: +3 -19 lines
Diff to previous 1.52 (colored)

Remove few level 3 debug printfs related to slot allocation.

Revision 1.52 / (download) - annotate - [select for diffs], Wed Jul 10 14:28:44 2019 UTC (4 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.51: +20 -23 lines
Diff to previous 1.51 (colored)

Replace the "umap" bitmap by a simple table of slot pointers.

Makes the code simpler at virtually no cost since we need 8 entries
only. No behavior change.

Revision 1.51 / (download) - annotate - [select for diffs], Wed Jul 10 14:24:42 2019 UTC (4 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.50: +17 -16 lines
Diff to previous 1.50 (colored)

Swap "if" and "else" code blocks in slot_new() to improve readability.

No behavior change.

Revision 1.50 / (download) - annotate - [select for diffs], Wed Jul 10 14:22:52 2019 UTC (4 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.49: +2 -3 lines
Diff to previous 1.49 (colored)

Slot name can't be empty. So, no need to check if it is empty.

Revision 1.49 / (download) - annotate - [select for diffs], Wed Jul 10 14:21:34 2019 UTC (4 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.48: +2 -2 lines
Diff to previous 1.48 (colored)

Use NULL instead of 0 where a pointer is expected.

Revision 1.48 / (download) - annotate - [select for diffs], Sun Jun 16 13:50:39 2019 UTC (4 years, 11 months ago) by ratchov
Branch: MAIN
Changes since 1.47: +2 -3 lines
Diff to previous 1.47 (colored)

Ignore the frame cents component in MMC relocate message.

As MTC requires new position to be transmitted with one frame
precision and then to advance in quarter-frame steps, its not
necessary to pollute out mtc position pointer with a frame cents
information, care about rounding errors and so on.

Revision 1.47 / (download) - annotate - [select for diffs], Tue Jun 26 07:49:44 2018 UTC (5 years, 10 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.46: +10 -8 lines
Diff to previous 1.46 (colored)

Initialize the slot->skip counter in slot_start() instead of
slot_attach(). Now this makes no difference, because slot_attach() is
always called right after slot_start(). However this will allow us to
call slot_{attach,detach}() routines, while preserving the state of
the slot.

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

Remove redundant slot->tstate variable.

It was used to determine whether the slot obeys MMC and is ready
to start. The stop->opt->mmc flag indicates if it obeys MMC and
the slot->pstate == SLOT_READY indicates if it's ready. So
slot->tstate can be safely removed.

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

Remove useless check if s->ops == NULL from slot_setvol().

Revision 1.44 / (download) - annotate - [select for diffs], Tue Jun 26 07:42:04 2018 UTC (5 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.43: +1 -2 lines
Diff to previous 1.43 (colored)

No need to initialize slot->mix.weight as it's recalculated and
overwritten in dev_mix_adjvol(), which is always called.

Revision 1.43 / (download) - annotate - [select for diffs], Tue Jun 26 07:39:59 2018 UTC (5 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.42: +13 -1 lines
Diff to previous 1.42 (colored)

Move slot-related debug printfs from sock_hello() to slot_new().

Revision 1.42 / (download) - annotate - [select for diffs], Tue Jun 26 07:36:27 2018 UTC (5 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.41: +34 -36 lines
Diff to previous 1.41 (colored)

Convert all the slot_xxx() routines to use the number of channels
instead of the maximum channel number. This way the code is simpler.
No behaviour change.

Revision 1.41 / (download) - annotate - [select for diffs], Tue Jun 26 07:31:29 2018 UTC (5 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.40: +13 -17 lines
Diff to previous 1.40 (colored)

Remove {mix,sub}.slot_cmin fields from the slot structure, as the same
information is already available in the opt structure.

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

Remove dev_{cmin,cmax} from the slot structure as the same information
is available in the opt structure.

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

Remove slot->dup which is a copy of opt->dup, and just use the latter
everywhere.

Revision 1.38 / (download) - annotate - [select for diffs], Tue Jun 26 07:22:55 2018 UTC (5 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.37: +4 -5 lines
Diff to previous 1.37 (colored)

Remove slot->maxweight, because it's a copy of opt->maxweight. Just
use the latter everywhere.

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

Initialize slot with parameters from the opt struct.

Revision 1.36 / (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.35: +5 -1 lines
Diff to previous 1.35 (colored)

Replace the gloal opt list with per-device lists.

Revision 1.35 / (download) - annotate - [select for diffs], Tue Jun 26 07:11:39 2018 UTC (5 years, 10 months ago) by ratchov
Branch: MAIN
Changes since 1.34: +150 -127 lines
Diff to previous 1.34 (colored)

Move slot buffer allocations in their own routines.

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

Factor common code of slot_stop().

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

Remove handling of unreachable state in slot_stop().

Revision 1.32 / (download) - annotate - [select for diffs], Fri Jun 8 06:20:49 2018 UTC (5 years, 11 months ago) by ratchov
Branch: MAIN
Changes since 1.31: +84 -95 lines
Diff to previous 1.31 (colored)

The conversion chain processes exactly one block, so no need to
calculate & count the number of processed samples. This allows to move
the calls to processing routines in dev_mix_badd() and
dev_sub_bcopy(), which is much simpler. No behaviour change.

Revision 1.31 / (download) - annotate - [select for diffs], Thu Nov 23 06:26:45 2017 UTC (6 years, 5 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_3_BASE, OPENBSD_6_3
Changes since 1.30: +7 -7 lines
Diff to previous 1.30 (colored)

Fix slot leak occuring when the device mode doesn't match
the client mode. Found by landry@.

Revision 1.30 / (download) - annotate - [select for diffs], Tue Nov 7 11:41:07 2017 UTC (6 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.29: +14 -1 lines
Diff to previous 1.29 (colored)

prefill with silence the buffer where cmap_copy() stores samples
rather than the client buffer. Fixes uninitialized data being treated
as recorded samples when resampling or format conversions are involved
but no mono->stereo conversion is used.

Revision 1.29 / (download) - annotate - [select for diffs], Fri Nov 3 17:12:59 2017 UTC (6 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.28: +4 -0 lines
Diff to previous 1.28 (colored)

Prefill client rec buffer with silence. This is necessary because
certain channels don't get samples, for instance when mono->stereo
conversion is disabled.

Revision 1.28 / (download) - annotate - [select for diffs], Wed Feb 15 21:28:23 2017 UTC (7 years, 3 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_2_BASE, OPENBSD_6_2, OPENBSD_6_1_BASE, OPENBSD_6_1
Changes since 1.27: +1 -1 lines
Diff to previous 1.27 (colored)

Fix the code supposed to abort when attempting to detach a slot that's
not on the slot list (the check was a no-op). Found by jsg@, thanks!

Revision 1.27 / (download) - annotate - [select for diffs], Tue Jan 3 06:53:20 2017 UTC (7 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.26: +1 -1 lines
Diff to previous 1.26 (colored)

Many typos in comments. From Michael W. Bombardieri. Thanks.

Revision 1.26 / (download) - annotate - [select for diffs], Wed May 25 05:34:23 2016 UTC (7 years, 11 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_6_0_BASE, OPENBSD_6_0
Changes since 1.25: +1 -1 lines
Diff to previous 1.25 (colored)

Set initial mixer slot name to "prog" to make all slots visible in
audioctl and alike.

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

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

Revision 1.24 / (download) - annotate - [select for diffs], Sat Jan 9 08:53:08 2016 UTC (8 years, 4 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_9_BASE, OPENBSD_5_9
Changes since 1.23: +1 -1 lines
Diff to previous 1.23 (colored)

unexpand tabs

Revision 1.23 / (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.22: +16 -16 lines
Diff to previous 1.22 (colored)

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

Revision 1.22 / (download) - annotate - [select for diffs], Wed Nov 25 18:51:08 2015 UTC (8 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.21: +0 -1 lines
Diff to previous 1.21 (colored)

fix latest: don't set d->path as we just allocated it

Revision 1.21 / (download) - annotate - [select for diffs], Wed Nov 25 18:47:12 2015 UTC (8 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.20: +3 -1 lines
Diff to previous 1.20 (colored)

Allocate device names in the heap, so they can be generated.

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

If the clock is ticking because of a MMC start message, then stop
it on exit. This avoids holding an extra ref to the device,
in turn preventing sndiod from exitting cleanly.

Revision 1.19 / (download) - annotate - [select for diffs], Mon Nov 23 10:02:42 2015 UTC (8 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.18: +2 -2 lines
Diff to previous 1.18 (colored)

use device numbers stored in the dev structure rather than
assuming dev_list is ordered

Revision 1.18 / (download) - annotate - [select for diffs], Sat Sep 5 11:19:20 2015 UTC (8 years, 8 months ago) by ratchov
Branch: MAIN
Changes since 1.17: +3 -3 lines
Diff to previous 1.17 (colored)

typos in comments: xfree -> free

Revision 1.17 / (download) - annotate - [select for diffs], Mon Jun 2 07:51:25 2014 UTC (9 years, 11 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_8_BASE, OPENBSD_5_8, OPENBSD_5_7_BASE, OPENBSD_5_7, OPENBSD_5_6_BASE, OPENBSD_5_6
Changes since 1.16: +2 -12 lines
Diff to previous 1.16 (colored)

log attach position only if log_level >= 0,
remove empty dev_mon_snoop() function

Revision 1.16 / (download) - annotate - [select for diffs], Mon Mar 17 17:53:33 2014 UTC (10 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.15: +48 -65 lines
Diff to previous 1.15 (colored)

Drop dev_clear(), merge dev_full_cycle() and dev_empty_cycle()
into dev_cycle(). No behavior change.

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

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

Revision 1.14 / (download) - annotate - [select for diffs], Fri Mar 7 10:23:05 2014 UTC (10 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.13: +4 -4 lines
Diff to previous 1.13 (colored)

remove unused "delta" argument from onmove callbacks

Revision 1.13 / (download) - annotate - [select for diffs], Fri Mar 7 10:15:38 2014 UTC (10 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.12: +1 -47 lines
Diff to previous 1.12 (colored)

remove unused mmc start/stop/relocate call-backs as they don't
make sense for clients and are handled through midi anyway

Revision 1.12 / (download) - annotate - [select for diffs], Wed Mar 5 20:31:22 2014 UTC (10 years, 2 months ago) by ratchov
Branch: MAIN
Changes since 1.11: +188 -195 lines
Diff to previous 1.11 (colored)

- properly set initial position: fixes incorrect position reporting
  on busy machines configured to use tiny block sizes
- run play and rec cycle in the same loop. No behavior change,
  but the code is much simpler this way.

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

remove unused "autostart" feature

Revision 1.10 / (download) - annotate - [select for diffs], Sat Feb 8 15:17:37 2014 UTC (10 years, 3 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_5_BASE, OPENBSD_5_5
Changes since 1.9: +3 -7 lines
Diff to previous 1.9 (colored)

copy the correct number of channels in join/expand

Revision 1.9 / (download) - annotate - [select for diffs], Tue Dec 31 12:27:49 2013 UTC (10 years, 4 months ago) by ratchov
Branch: MAIN
Changes since 1.8: +29 -2 lines
Diff to previous 1.8 (colored)

Drop blocks and instert silence immediately in the socket rx/tx code
path rather than waiting for the next device cycle. This fixes deadocks
when the slot uses the SIO_SYNC mode.

Revision 1.8 / (download) - annotate - [select for diffs], Fri Dec 20 08:47:37 2013 UTC (10 years, 5 months ago) by ratchov
Branch: MAIN
Changes since 1.7: +5 -3 lines
Diff to previous 1.7 (colored)

set the target device number of standard system exclusive
messages to 0x7f (aka "any device").

Revision 1.7 / (download) - annotate - [select for diffs], Mon Nov 18 17:37:45 2013 UTC (10 years, 6 months ago) by ratchov
Branch: MAIN
Changes since 1.6: +57 -11 lines
Diff to previous 1.6 (colored)

add missing prototypes

Revision 1.6 / (download) - annotate - [select for diffs], Sun May 5 20:42:53 2013 UTC (11 years ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_4_BASE, OPENBSD_5_4
Changes since 1.5: +8 -7 lines
Diff to previous 1.5 (colored)

Initialize channel ranges of new slots to full sub-device channels.
Fixes wrong channel mappings when the client specifies no channels.
Found by Dimitri Sokolyuk <sokolyuk at gmail.com>, thanks!

Revision 1.5 / (download) - annotate - [select for diffs], Sun May 5 09:50:21 2013 UTC (11 years ago) by ratchov
Branch: MAIN
Changes since 1.4: +2 -1 lines
Diff to previous 1.4 (colored)

Initialize client rate. Fixes crashes when the client doesn't set the
rate. Problem reported and analyzed by Dimitri Sokolyuk <sokolyuk at
gmail.com>. Thanks!

Revision 1.4 / (download) - annotate - [select for diffs], Tue Feb 26 22:52:08 2013 UTC (11 years, 2 months ago) by ratchov
Branch: MAIN
CVS Tags: OPENBSD_5_3_BASE, OPENBSD_5_3
Changes since 1.3: +3 -3 lines
Diff to previous 1.3 (colored)

Encoding conversion buffer size is one stream block, not one device
block. Fix crashes occuring when the client sample frequency is much
larger than the device sample frequency. Found by Alexander Polakov,
thanks.

ok deraadt@

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

When the audio device is closed, mark it as closed before
dropping connections otherwise clients may try to drain their
buffer and would attempt to reopen the device

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

don't exit if midi control port is destroyed (it never is)

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.