[Development report #2] Audio Stack Improvements

From: Christos Margiolis <christos_at_freebsd.org>
Date: Tue, 16 Jan 2024 14:52:27 UTC

Last week's report:

Trying various different approaches to solving
While it’s no longer the case that the USB stack completely hangs
endlessly, the existing code makes the channel belonging to the detached
USB device go to sleep for hw.snd.timeout seconds and manually kills it
after the timeout, effectively terminating the read/write operation.
What we really want in the case of a hot-unplug, however, is to kill the
channel immediately without waiting. We could set the timeout to 1
second, but this is still not ideal. Upon detach, pcm_unregister() sets
an SD_F_DETACHING flag, and, while it should theoretically be easy to
simply add a `if (PCM_DETACHING(dev))` at the beginning of chn_read()
and chn_write() and kill the channel if the case is true, the channel
goes to sleep before the detach routine is called. I suspect that if we
somehow get around this issue, then the bug will be fixed. Other things
I tried included manually freeing up resources and destroying the
device’s devfs nodes, and while this seemed like it worked, the channel
had again already gone to sleep. Suggestions and ideas are all welcome!

Worked with imp@, emaste@ and markj@ to finalize the patches mentioned
in last week’s report.

Simplified device_set_usb_desc() by calling only usb_devinfo() to set
the device's description and removing the first attempt to fetch the
description through the iInterface descriptor, which 1) is not present
in many devices and 2) usually includes less information.

Wrote a few more new minor patches: