Re: [Development report #7] Audio Stack Improvements

From: Mark Johnston <markj_at_freebsd.org>
Date: Fri, 15 Mar 2024 10:52:29 UTC
Hi Christos,

On Wed, Mar 13, 2024 at 03:44:57PM +0100, Christos Margiolis wrote:
> Working on scrapping sound(4)'s "snd_clone" device cloning framework and
> using DEVFS_CDEVPRIV(9) instead. Such a change will simplify and reduce
> code size significantly, as well as improve user-experience. The WIP can
> be found on my GitHub branch, but I will submit a patch on Phabricator
> ASAP.
> 
> https://github.com/christosmarg/freebsd/commit/c8694174e2e9d77ef74c6d8e25d99b2b7d5d5652
> 
> - Discussed with Florian Walpen about the patch.
> - Reduced overall code size ("7 changed files with 327 additions and
>   1,739 deletions" according to GitHub).
> - Got rid of all snd_clone* functions, removed clone.* files and related
>   sysctls altogether.
> - Handled hw.snd.basename_clone to work with the new patch.
> - Handle character device destroying. https://reviews.freebsd.org/D43545
>   will be rewritten (and end up noticeably smaller/simpler) on top of
>   this patch once submitted.
> - Cleaned up patch and fixed most bugs I've spotted so far.
> - Simplified dsp_open() and dsp_close().
> - Removed dsp_cdevinfo* and embedded this information in the cdevpriv(9)
>   structure.
> - Tested a bunch of different cases. Need to test more and resolve a few
>   remaining bugs.
> 
> Regarding behavior that is preserved:
> - Exclusive access of an audio device still works (i.e VCHANs disabled).
> - Multiple processes can read from/write to the device.
> - A device can only be opened as many times as the maximum channel
>   number (see PCMMAXCLONE in pcm/sound.h).
> 
> Behavior changes:
> - Only one /dev/dspX device is exposed, as opposed to the current
>   /dev/dspX.[X]X devices created by the snd_clone mechanism. The
>   user/application now only needs to access the device through /dev/dspX
>   or /dev/dsp and sound(4) will take care of all necessary audio
>   routing.

Does this represent a backward compatibility break?  That is, will
applications need any modification when running on a patched kernel?

> Pending work:
> - See if it's worth preserving any of the additional devices in
>   dsp_cdevs[] (see SND_DSP_DEV attribute in pcm/dsp.c).
> - Make sure no OSS IOCTL breaks.
> - Add comments to the code.
> - Write proper commit message.
> - Update man page.
> - Update Wiki page once committed.
> - As already mentioned, rewrite https://reviews.freebsd.org/D43545.
> 
> Additional work outside the cdevpriv(9) patch includes:
> 
> Committed snd_hda patch for the	Lenovo Ideapad 330-15 and ThinkPad X230.
> https://cgit.freebsd.org/src/commit/?id=5968e477a560406c480d78ebe438a04f57121119
> 
> MFC'd all pending patches to stable/14.
> 
> Started documenting missing sound(4) sysctls.
> 
> Reviewed and committed Florian Walpen's recent snd_uaudio(4) patch.
> https://cgit.freebsd.org/src/commit/?id=a9341f0f0ae01b4d249dbf3bacfa420152c46aef
> 
> Christos