History log of /openbsd-current/usr.bin/sndiod/midi.h
Revision (<<< Hide revision tags) (Show revision tags >>>) Date Author Comments
# 1.16 03-May-2024 ratchov

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 tags: OPENBSD_7_1_BASE OPENBSD_7_2_BASE OPENBSD_7_3_BASE OPENBSD_7_4_BASE OPENBSD_7_5_BASE
# 1.15 01-Nov-2021 ratchov

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 tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.14 28-Jan-2021 ratchov

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


Revision tags: OPENBSD_6_8_BASE
# 1.13 12-Jun-2020 ratchov

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 tags: OPENBSD_6_7_BASE
# 1.12 25-Apr-2020 ratchov

Get a reference to the device when "snd/N" MIDI ports are opened

As the master output level control is not in software any longer the
device needs to opened for adjustments to work.


# 1.11 23-Jan-2020 ratchov

Accept MIDI clients that don't reset status during sysex messages.

The MIDI protocol requires the status byte to be resent after common
messages, including system exclusive messages. But, some MIDI clients
forget to resend it; we workaround this restoring the status byte
after sysex messages.


Revision tags: OPENBSD_6_6_BASE
# 1.10 21-Sep-2019 ratchov

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@


# 1.9 29-Aug-2019 ratchov

Fix wrong comment about MIDI port hold flag


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 09-Jan-2016 ratchov

Make midi->tickets signed (sign is needed for arithmetics even if the
actual count is always positive). Found by David Coppa. Thanks.


# 1.7 22-Nov-2015 ratchov

save port number if port structure


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 18-Nov-2013 ratchov

add missing prototypes


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 30-Nov-2012 ratchov

drain midi port output buffer before closing it ensuring the last
few bytes are not lost


# 1.4 30-Nov-2012 ratchov

use the hold flag for midi ports as well


# 1.3 30-Nov-2012 ratchov

For MIDI ports, use the same open/close logic as for audio devices:
drop clients using it when the port is closed (eg. umidi disconnected)
and try to reopen it whenever a new client connects.


# 1.2 30-Nov-2012 ratchov

Process incoming MIDI data on the fly rather than using an
input fifo; besides being simpler, this way there's no data
to drain when a connection is dropped.


# 1.1 23-Nov-2012 ratchov

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@


# 1.15 01-Nov-2021 ratchov

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 tags: OPENBSD_6_9_BASE OPENBSD_7_0_BASE
# 1.14 28-Jan-2021 ratchov

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


Revision tags: OPENBSD_6_8_BASE
# 1.13 12-Jun-2020 ratchov

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 tags: OPENBSD_6_7_BASE
# 1.12 25-Apr-2020 ratchov

Get a reference to the device when "snd/N" MIDI ports are opened

As the master output level control is not in software any longer the
device needs to opened for adjustments to work.


# 1.11 23-Jan-2020 ratchov

Accept MIDI clients that don't reset status during sysex messages.

The MIDI protocol requires the status byte to be resent after common
messages, including system exclusive messages. But, some MIDI clients
forget to resend it; we workaround this restoring the status byte
after sysex messages.


Revision tags: OPENBSD_6_6_BASE
# 1.10 21-Sep-2019 ratchov

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@


# 1.9 29-Aug-2019 ratchov

Fix wrong comment about MIDI port hold flag


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 09-Jan-2016 ratchov

Make midi->tickets signed (sign is needed for arithmetics even if the
actual count is always positive). Found by David Coppa. Thanks.


# 1.7 22-Nov-2015 ratchov

save port number if port structure


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 18-Nov-2013 ratchov

add missing prototypes


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 30-Nov-2012 ratchov

drain midi port output buffer before closing it ensuring the last
few bytes are not lost


# 1.4 30-Nov-2012 ratchov

use the hold flag for midi ports as well


# 1.3 30-Nov-2012 ratchov

For MIDI ports, use the same open/close logic as for audio devices:
drop clients using it when the port is closed (eg. umidi disconnected)
and try to reopen it whenever a new client connects.


# 1.2 30-Nov-2012 ratchov

Process incoming MIDI data on the fly rather than using an
input fifo; besides being simpler, this way there's no data
to drain when a connection is dropped.


# 1.1 23-Nov-2012 ratchov

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@


# 1.14 28-Jan-2021 ratchov

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


Revision tags: OPENBSD_6_8_BASE
# 1.13 12-Jun-2020 ratchov

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 tags: OPENBSD_6_7_BASE
# 1.12 25-Apr-2020 ratchov

Get a reference to the device when "snd/N" MIDI ports are opened

As the master output level control is not in software any longer the
device needs to opened for adjustments to work.


# 1.11 23-Jan-2020 ratchov

Accept MIDI clients that don't reset status during sysex messages.

The MIDI protocol requires the status byte to be resent after common
messages, including system exclusive messages. But, some MIDI clients
forget to resend it; we workaround this restoring the status byte
after sysex messages.


Revision tags: OPENBSD_6_6_BASE
# 1.10 21-Sep-2019 ratchov

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@


# 1.9 29-Aug-2019 ratchov

Fix wrong comment about MIDI port hold flag


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 09-Jan-2016 ratchov

Make midi->tickets signed (sign is needed for arithmetics even if the
actual count is always positive). Found by David Coppa. Thanks.


# 1.7 22-Nov-2015 ratchov

save port number if port structure


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 18-Nov-2013 ratchov

add missing prototypes


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 30-Nov-2012 ratchov

drain midi port output buffer before closing it ensuring the last
few bytes are not lost


# 1.4 30-Nov-2012 ratchov

use the hold flag for midi ports as well


# 1.3 30-Nov-2012 ratchov

For MIDI ports, use the same open/close logic as for audio devices:
drop clients using it when the port is closed (eg. umidi disconnected)
and try to reopen it whenever a new client connects.


# 1.2 30-Nov-2012 ratchov

Process incoming MIDI data on the fly rather than using an
input fifo; besides being simpler, this way there's no data
to drain when a connection is dropped.


# 1.1 23-Nov-2012 ratchov

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@


# 1.13 12-Jun-2020 ratchov

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 tags: OPENBSD_6_7_BASE
# 1.12 25-Apr-2020 ratchov

Get a reference to the device when "snd/N" MIDI ports are opened

As the master output level control is not in software any longer the
device needs to opened for adjustments to work.


# 1.11 23-Jan-2020 ratchov

Accept MIDI clients that don't reset status during sysex messages.

The MIDI protocol requires the status byte to be resent after common
messages, including system exclusive messages. But, some MIDI clients
forget to resend it; we workaround this restoring the status byte
after sysex messages.


Revision tags: OPENBSD_6_6_BASE
# 1.10 21-Sep-2019 ratchov

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@


# 1.9 29-Aug-2019 ratchov

Fix wrong comment about MIDI port hold flag


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 09-Jan-2016 ratchov

Make midi->tickets signed (sign is needed for arithmetics even if the
actual count is always positive). Found by David Coppa. Thanks.


# 1.7 22-Nov-2015 ratchov

save port number if port structure


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 18-Nov-2013 ratchov

add missing prototypes


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 30-Nov-2012 ratchov

drain midi port output buffer before closing it ensuring the last
few bytes are not lost


# 1.4 30-Nov-2012 ratchov

use the hold flag for midi ports as well


# 1.3 30-Nov-2012 ratchov

For MIDI ports, use the same open/close logic as for audio devices:
drop clients using it when the port is closed (eg. umidi disconnected)
and try to reopen it whenever a new client connects.


# 1.2 30-Nov-2012 ratchov

Process incoming MIDI data on the fly rather than using an
input fifo; besides being simpler, this way there's no data
to drain when a connection is dropped.


# 1.1 23-Nov-2012 ratchov

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@


# 1.12 25-Apr-2020 ratchov

Get a reference to the device when "snd/N" MIDI ports are opened

As the master output level control is not in software any longer the
device needs to opened for adjustments to work.


# 1.11 23-Jan-2020 ratchov

Accept MIDI clients that don't reset status during sysex messages.

The MIDI protocol requires the status byte to be resent after common
messages, including system exclusive messages. But, some MIDI clients
forget to resend it; we workaround this restoring the status byte
after sysex messages.


Revision tags: OPENBSD_6_6_BASE
# 1.10 21-Sep-2019 ratchov

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@


# 1.9 29-Aug-2019 ratchov

Fix wrong comment about MIDI port hold flag


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 09-Jan-2016 ratchov

Make midi->tickets signed (sign is needed for arithmetics even if the
actual count is always positive). Found by David Coppa. Thanks.


# 1.7 22-Nov-2015 ratchov

save port number if port structure


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 18-Nov-2013 ratchov

add missing prototypes


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 30-Nov-2012 ratchov

drain midi port output buffer before closing it ensuring the last
few bytes are not lost


# 1.4 30-Nov-2012 ratchov

use the hold flag for midi ports as well


# 1.3 30-Nov-2012 ratchov

For MIDI ports, use the same open/close logic as for audio devices:
drop clients using it when the port is closed (eg. umidi disconnected)
and try to reopen it whenever a new client connects.


# 1.2 30-Nov-2012 ratchov

Process incoming MIDI data on the fly rather than using an
input fifo; besides being simpler, this way there's no data
to drain when a connection is dropped.


# 1.1 23-Nov-2012 ratchov

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@


# 1.11 23-Jan-2020 ratchov

Accept MIDI clients that don't reset status during sysex messages.

The MIDI protocol requires the status byte to be resent after common
messages, including system exclusive messages. But, some MIDI clients
forget to resend it; we workaround this restoring the status byte
after sysex messages.


Revision tags: OPENBSD_6_6_BASE
# 1.10 21-Sep-2019 ratchov

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@


# 1.9 29-Aug-2019 ratchov

Fix wrong comment about MIDI port hold flag


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 09-Jan-2016 ratchov

Make midi->tickets signed (sign is needed for arithmetics even if the
actual count is always positive). Found by David Coppa. Thanks.


# 1.7 22-Nov-2015 ratchov

save port number if port structure


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 18-Nov-2013 ratchov

add missing prototypes


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 30-Nov-2012 ratchov

drain midi port output buffer before closing it ensuring the last
few bytes are not lost


# 1.4 30-Nov-2012 ratchov

use the hold flag for midi ports as well


# 1.3 30-Nov-2012 ratchov

For MIDI ports, use the same open/close logic as for audio devices:
drop clients using it when the port is closed (eg. umidi disconnected)
and try to reopen it whenever a new client connects.


# 1.2 30-Nov-2012 ratchov

Process incoming MIDI data on the fly rather than using an
input fifo; besides being simpler, this way there's no data
to drain when a connection is dropped.


# 1.1 23-Nov-2012 ratchov

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@


# 1.10 21-Sep-2019 ratchov

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@


# 1.9 29-Aug-2019 ratchov

Fix wrong comment about MIDI port hold flag


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 09-Jan-2016 ratchov

Make midi->tickets signed (sign is needed for arithmetics even if the
actual count is always positive). Found by David Coppa. Thanks.


# 1.7 22-Nov-2015 ratchov

save port number if port structure


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 18-Nov-2013 ratchov

add missing prototypes


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 30-Nov-2012 ratchov

drain midi port output buffer before closing it ensuring the last
few bytes are not lost


# 1.4 30-Nov-2012 ratchov

use the hold flag for midi ports as well


# 1.3 30-Nov-2012 ratchov

For MIDI ports, use the same open/close logic as for audio devices:
drop clients using it when the port is closed (eg. umidi disconnected)
and try to reopen it whenever a new client connects.


# 1.2 30-Nov-2012 ratchov

Process incoming MIDI data on the fly rather than using an
input fifo; besides being simpler, this way there's no data
to drain when a connection is dropped.


# 1.1 23-Nov-2012 ratchov

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@


# 1.9 29-Aug-2019 ratchov

Fix wrong comment about MIDI port hold flag


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE OPENBSD_6_3_BASE OPENBSD_6_4_BASE OPENBSD_6_5_BASE
# 1.8 09-Jan-2016 ratchov

Make midi->tickets signed (sign is needed for arithmetics even if the
actual count is always positive). Found by David Coppa. Thanks.


# 1.7 22-Nov-2015 ratchov

save port number if port structure


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 18-Nov-2013 ratchov

add missing prototypes


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 30-Nov-2012 ratchov

drain midi port output buffer before closing it ensuring the last
few bytes are not lost


# 1.4 30-Nov-2012 ratchov

use the hold flag for midi ports as well


# 1.3 30-Nov-2012 ratchov

For MIDI ports, use the same open/close logic as for audio devices:
drop clients using it when the port is closed (eg. umidi disconnected)
and try to reopen it whenever a new client connects.


# 1.2 30-Nov-2012 ratchov

Process incoming MIDI data on the fly rather than using an
input fifo; besides being simpler, this way there's no data
to drain when a connection is dropped.


# 1.1 23-Nov-2012 ratchov

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@


Revision tags: OPENBSD_5_9_BASE OPENBSD_6_0_BASE OPENBSD_6_1_BASE OPENBSD_6_2_BASE
# 1.8 09-Jan-2016 ratchov

Make midi->tickets signed (sign is needed for arithmetics even if the
actual count is always positive). Found by David Coppa. Thanks.


# 1.7 22-Nov-2015 ratchov

save port number if port structure


Revision tags: OPENBSD_5_5_BASE OPENBSD_5_6_BASE OPENBSD_5_7_BASE OPENBSD_5_8_BASE
# 1.6 18-Nov-2013 ratchov

add missing prototypes


Revision tags: OPENBSD_5_3_BASE OPENBSD_5_4_BASE
# 1.5 30-Nov-2012 ratchov

drain midi port output buffer before closing it ensuring the last
few bytes are not lost


# 1.4 30-Nov-2012 ratchov

use the hold flag for midi ports as well


# 1.3 30-Nov-2012 ratchov

For MIDI ports, use the same open/close logic as for audio devices:
drop clients using it when the port is closed (eg. umidi disconnected)
and try to reopen it whenever a new client connects.


# 1.2 30-Nov-2012 ratchov

Process incoming MIDI data on the fly rather than using an
input fifo; besides being simpler, this way there's no data
to drain when a connection is dropped.


# 1.1 23-Nov-2012 ratchov

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@