Commit Graph

22 Commits

Author SHA1 Message Date
Christos Margiolis 4f7092eeb2 virtual_oss_cmd(8): Improve error messages
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-06-02 15:00:45 +02:00
Christos Margiolis 453de99b38 virtual_oss(8): Fix buffer overflow in voss_compressor() call
This particular calls swaps the samples and maxchan arguments, which can
cause a buffer overflow in p_ch_chain if maxchan exceeds its bounds
(VMAX_CHAN).

Reported by:	Yuxiang Yang, Yizhou Zhao, Ao Wang, Xuewei Feng, Qi Li, and Ke Xu from Tsinghua University using GLM-5.1 from Z.ai
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
Reviewed by:	emaste
2026-05-28 16:46:01 +02:00
Christos Margiolis 5f904cb1b0 virtual_oss(8): Create loopback devices with GID_AUDIO
Make sure the user is part of the audio group to avoid unintended
snooping of loopback audio by unprivileged users.

While here, retire voss_dsp_perm, since we don't use the same value
everywhere now.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	emaste
Pull-Request:	https://ron-dev.freebsd.org/FreeBSD/src/pulls/26
2026-05-21 19:32:43 +02:00
Christos Margiolis 788d71e73f virtual_oss.8: Remove CPU performance example
See also:	https://github.com/freebsd/virtual_oss/issues/2
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-04-17 22:48:38 +02:00
Christos Margiolis a2b601343b virtual_oss: Combine -d, -l and -L option getopt code
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D55671
2026-03-10 11:55:21 +01:00
Christos Margiolis e75c8faf27 virtual_oss: Use virtual_oss_timestamp() to avoid duplication
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-03-08 00:46:28 +01:00
Christos Margiolis 3a410851bf virtual_oss: Use virtual_oss_delay_ns() to avoid duplication
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
2026-03-08 00:46:25 +01:00
Christos Margiolis d15987cc06 virtual_oss(8): Expose ioctl interface
PR:		293545
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2026-03-04 19:06:17 +01:00
Tuukka Pasanen 6d5a428056 virtual_oss: Add SPDX-License-Identifier tags
Reviewed by: emaste
Sponsored by: The FreeBSD Foundation
2026-02-19 10:07:05 -05:00
Brooks Davis 373c72ad50 virtual_oss: build system tidying
general:
 - find libsamplerate's headers in the temporary sysroot instead of
   digging in the source tree.
 - use LIBADD where possible

lib/virtual_oss:
 - centralize SHLIBDIR define
 - centralize include path for internal headers
 - don't try to find libsamplerate directly in .OBJDIR

No functional changes.

Reviewed by:	christos
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D54704
2026-01-16 09:33:56 +00:00
Brooks Davis adab1dd6a7 virtual_oss: build commands/libs in parallel
Reviewed by:	christos
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D54703
2026-01-16 09:33:50 +00:00
Brooks Davis 497a13601f virtual_oss: remove needless .include in intermediate Makefile
It doesn't define anything we use.

Reviewed by:	christos
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D54702
2026-01-16 09:33:22 +00:00
Christos Margiolis e5c0d7020f virtual_oss(8): Improve hw.snd.basename_clone handling
If we request a /dev/dsp virtual_oss(8) device, we have to replace the
sound(4) one by first disabling hw.snd.basename_clone. This sysctl tells
sound(4) to not create the /dev/dsp alias for the default device. There
are currently two issues with the way this is handled by virtual_oss(8),
however:

1. It uses system(3) instead of sysctlbyname(3).
2. It does not restore hw.snd.basename_clone to its original value, so
   if prior to virtual_oss(8) running, hw.snd.basename_clone was enabled
   (which is the case by default), and it is closed at some point,
   hw.snd.basename_clone stays disabled, which is annoying, because
   users have to manually restore it, otherwise applications that open
   the default device (i.e., most) will not work.

Fix both issues.

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	markj
Differential Revision:	https://reviews.freebsd.org/D53621
2025-11-11 13:07:44 +01:00
Christos Margiolis 7bedc4634d virtual_oss(8): Use kldload(2) instead of system(3)
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	imp, markj, emaste
Differential Revision:	https://reviews.freebsd.org/D53617
2025-11-11 13:07:40 +01:00
Christos Margiolis 30a873ee37 virtual_oss(8): Retire unused utils.h
Sponsored by:	The FreeBSD Foundation
MFC after:	1 day
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D53174
2025-10-18 15:17:43 +02:00
Lexi Winter 1b806e607f packages: Add a sound package
Put virtual_oss, /etc/devd/snd.conf and the other audio-related tools
into a new "sound" package.  Don't create a separate -lib package,
since it's unlikely someone will want mixer(3) without mixer(8).

Put the sound package in the optional set rather than minimal, since
it's not actually required for audio hardware support, and many systems
(including nearly all servers) won't want it installed.

MFC after:	3 seconds
Reviewed by:	christos
Sponsored by:	https://www.patreon.com/bsdivy
Differential Revision:	https://reviews.freebsd.org/D52823
2025-10-02 02:37:35 +01:00
Christos Margiolis 8af6aee96e virtual_oss(8): Remove floating point formats from preference list
virtual_oss(8) chooses formats based on preference lists (see
VPREFERRED_*) for each sample depth (-b option). However, if we, for
example, use 32 bits LE for the sample depth, what will end up happening
is that the format chosen will be 0x10001000, which corresponds to
AFMT_S32_LE *and* AFMT_F32_LE OR'd together. This happens because the
preference lists include both AFMT_S32_* and AFMT_F32_* in the 32-bit
cases.

Because we essentially end up using an invalid format, sound(4) will
eventually reach pcm_sample_write()'s (sys/dev/sound/pcm/pcm.h)
__assert_unreachable() case.

This patch is a temporary fix to address the panic, until a proper
solution for using floating point formats is found.

PR:		289904
Sponsored by:	The FreeBSD Foundation
MFC after:	2 days
2025-09-30 15:25:53 +02:00
Christos Margiolis 25d551b5fb virtual_bt_speaker(8): Do not build if WITHOUT_BLUETOOTH is set
virtual_bt_speaker(8) includes bluetooth.h, which won't exist if
WITHOUT_BLUETOOTH is set, which will result in a build failure.

Reported by:	peterj
Fixes:		9cab9fde5e ("virtual_oss: Port to base")
Sponsored by:	The FreeBSD Foundation
MFC after:	3 days
2025-09-30 11:10:01 +02:00
Christos Margiolis 0532cd2d77 virtual_oss(8): Fix GCC errors and warnings
Reported by:	CI
Fixes:          9cab9fde5e ("virtual_oss: Port to base")
Sponsored by:	The FreeBSD Foundation
MFC after:	4 days
2025-09-29 18:16:26 +02:00
Christos Margiolis 69ede18b95 virtual_oss(8): Use proper format specifier for uintmax_t *
Fixes armv7 build.

Reported by:	CI
Fixes:          9cab9fde5e ("virtual_oss: Port to base")
Sponsored by:	The FreeBSD Foundation
MFC after:	4 days
2025-09-29 12:40:10 +02:00
Christos Margiolis 86a7787e32 virtual_bt_speaker(8): Fix aarch64 build
Reported by:	fuz, otis
Fixes:		9cab9fde5e ("virtual_oss: Port to base")
Sponsored by:	The FreeBSD Foundation
2025-09-28 17:39:44 +02:00
Christos Margiolis 9cab9fde5e virtual_oss: Port to base
This patch diverges quite a bit from the current upstream [1] in a few
ways:

1. virtual_oss(8), virtual_bt_speaker(8) and virtual_oss_cmd(8) are
   actually separate programs.
2. Backends (lib/virtual_oss) are built as separate shared libraries and
   we dlopen() them in virtual_oss(8) and virtual_bt_speaker(8) on
   demand.
3. virtual_equalizer(8) and the sndio and bluetooth backends are built
   as ports, because they depend on third-party libraries.
4. Use newer libav API in bluetooth backend (see HAVE_LIBAV ifdefs) to
   address compiler errors.

[1] https://github.com/freebsd/virtual_oss

Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Reviewed by:	emaste
Differential Revision:	https://reviews.freebsd.org/D52308
2025-09-28 11:56:52 +02:00