Page MenuHomeFreeBSD

virtual_oss(8): Improve hw.snd.basename_clone handling
AcceptedPublic

Authored by christos on Thu, Nov 6, 4:24 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 7, 12:10 PM
Unknown Object (File)
Fri, Nov 7, 12:10 PM
Unknown Object (File)
Fri, Nov 7, 11:13 AM
Unknown Object (File)
Fri, Nov 7, 9:19 AM
Unknown Object (File)
Fri, Nov 7, 8:52 AM
Unknown Object (File)
Fri, Nov 7, 6:51 AM
Unknown Object (File)
Fri, Nov 7, 4:48 AM
Unknown Object (File)
Fri, Nov 7, 3:49 AM
Subscribers

Details

Reviewers
markj
emaste
Summary

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.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68520
Build 65403: arc lint + arc unit

Event Timeline

This is pretty janky. If virtual_oss crashes, the sysctl won't be reset.

This behaviour should be documented if it isn't already.

This revision is now accepted and ready to land.Fri, Nov 7, 2:33 PM

This is pretty janky. If virtual_oss crashes, the sysctl won't be reset.

This behaviour should be documented if it isn't already.

I also do not like this, but it is the only viable way to replace /dev/dsp currently. Would putting the sysctl restoration in an atexit callback address the issue you are talking about?

This is pretty janky. If virtual_oss crashes, the sysctl won't be reset.

This behaviour should be documented if it isn't already.

I also do not like this, but it is the only viable way to replace /dev/dsp currently. Would putting the sysctl restoration in an atexit callback address the issue you are talking about?

That wouldn't totally fix it, but it's probably better yes.

I'd also get virtual_oss to print or log a message when setting the value initially.

usr.sbin/virtual_oss/virtual_oss/main.c
1915

You can read and write the sysctl with a single call.

christos marked an inline comment as done.

Address Mark's comments.

This revision now requires review to proceed.Mon, Nov 10, 3:36 PM
usr.sbin/virtual_oss/virtual_oss/main.c
2588

Why not set the atexit handler in the same place where you set the sysctl to begin with?

usr.sbin/virtual_oss/virtual_oss/main.c
2588

I thought it makes more sense to put it here along with some other callback settings (signal callback). I can move do it after the sysctl setting, no objection.

christos marked an inline comment as done.

Address Mark's comment.

usr.sbin/virtual_oss/virtual_oss/main.c
1755

atexit() handlers shouldn't call exit().

1914

Why do you call err() when the error path above returns an error string?

1915

Extra newline here.

christos marked 3 inline comments as done.

Address Mark's comments.

This revision is now accepted and ready to land.Tue, Nov 11, 12:24 AM