From nobody Wed Mar 13 14:44:57 2024 X-Original-To: freebsd-multimedia@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Tvtb9003Pz5D2Jl for ; Wed, 13 Mar 2024 14:45:08 +0000 (UTC) (envelope-from christos@freebsd.org) Received: from margiolis.net (mail.margiolis.net [95.179.159.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA512) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4Tvtb76zyHz43Tn; Wed, 13 Mar 2024 14:45:07 +0000 (UTC) (envelope-from christos@freebsd.org) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=margiolis.net header.s=mail header.b="h/JqAKIV"; dmarc=fail reason="No valid SPF, DKIM not aligned (relaxed)" header.from=freebsd.org (policy=none); spf=softfail (mx1.freebsd.org: 95.179.159.8 is neither permitted nor denied by domain of christos@freebsd.org) smtp.mailfrom=christos@freebsd.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; s=mail; bh=FL0L+TIO/lei0+k r+ni4dMrlcrQ6y46EhusOWS6pk7Q=; h=subject:cc:to:from:date; d=margiolis.net; b=h/JqAKIV9HGq2lsbdy9Dc0cBXu66CN+23zI2CfbI5MU1ya/9ttN 6u8y4Oo/bCmqDmJqLla02FzCU6QATymly0a5mYZva8J1t5lWYgaLWnUl+iTAP4xQQu6CKz t/QqPiYdJGJFwwuTpKcO7bIFLiUnA7Km4gI2egM3BG5RRZPo2I= Received: from tpad (public-gprs530105.centertel.pl [31.61.189.250]) by margiolis.net (OpenSMTPD) with ESMTPSA id b0ff0552 (TLSv1.3:AEAD-AES256-GCM-SHA384:256:NO); Wed, 13 Mar 2024 14:44:59 +0000 (UTC) Date: Wed, 13 Mar 2024 15:44:57 +0100 From: Christos Margiolis To: status-updates@freebsdfoundation.org Cc: freebsd-multimedia@freebsd.org, markj@freebsd.org, jrm@freebsd.org Subject: [Development report #7] Audio Stack Improvements Message-ID: List-Id: Multimedia discussions List-Archive: https://lists.freebsd.org/archives/freebsd-multimedia List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-multimedia@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spamd-Bar: -- X-Spamd-Result: default: False [-2.70 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MID_RHS_NOT_FQDN(0.50)[]; R_DKIM_ALLOW(-0.20)[margiolis.net:s=mail]; DMARC_POLICY_SOFTFAIL(0.10)[freebsd.org : No valid SPF, DKIM not aligned (relaxed),none]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; FREEFALL_USER(0.00)[christos]; MISSING_XM_UA(0.00)[]; MIME_TRACE(0.00)[0:+]; ASN(0.00)[asn:20473, ipnet:95.179.144.0/20, country:US]; RCVD_TLS_ALL(0.00)[]; MLMMJ_DEST(0.00)[freebsd-multimedia@freebsd.org]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; R_SPF_SOFTFAIL(0.00)[~all:c]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_NONE(0.00)[]; DKIM_TRACE(0.00)[margiolis.net:+] X-Rspamd-Queue-Id: 4Tvtb76zyHz43Tn 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. 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