Page MenuHomeFreeBSD

sound: Fix min/max sample rate assignment for VCHANs
Needs ReviewPublic

Authored by christos on Thu, Jun 20, 5:39 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Jun 26, 12:50 AM
Unknown Object (File)
Mon, Jun 24, 10:06 PM
Unknown Object (File)
Sat, Jun 22, 7:31 PM
Unknown Object (File)
Fri, Jun 21, 6:32 PM
Unknown Object (File)
Fri, Jun 21, 2:44 PM
Unknown Object (File)
Fri, Jun 21, 1:51 PM
Unknown Object (File)
Fri, Jun 21, 11:58 AM
Unknown Object (File)
Fri, Jun 21, 8:51 AM
Subscribers

Details

Summary

Currently the min/max sample rate reported for a given VCHAN is whatever
is specified in dev.pcm.X.[play|rec].vchanrate, and is the same for both
the min and the max. For example, if *.vchanrate is set to 48000, then
the min/max will be both 48000. Fix this by assigning the min/max to
either the physical channel's min/max, or, when hw.snd.feeder_rate_round
is set to 0, to feeder_rate_[min|max].

Sponsored by: The FreeBSD Foundation
MFC after: 2 days

Test Plan

Printing the oss_audioinfo->[min|max]_rate for a VCHAN when hw.snd.feeder_rate_round is not 0:

min_rate=44100
max_rate=96000

Which is the min/max of the physical channel.

And with hw.snd.feeder_rate_round=0:

min_rate=1
max_rate=2016000

Which takes the value from feeder_rate_[min|max]:

root@freebsd:~ # sysctl hw.snd.feeder_rate_min
hw.snd.feeder_rate_min: 1
root@freebsd:~ # sysctl hw.snd.feeder_rate_max
hw.snd.feeder_rate_max: 2016000

Diff Detail

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

Event Timeline

christos added inline comments.
sys/dev/sound/pcm/vchan.c
216

@dev_submerge.ch I am not really sure what values we must assign in the case of AFMT_PASSTHROUGH. Any ideas?

sys/dev/sound/pcm/vchan.c
216

The passthrough formats I know are all 48kHz on optical / SPDIF, but I think HDMI audio has more options now. This is supposedly going out bitperfect with no sample rate conversion, which suggests these should match the physical sample rates of the hardware.

sys/dev/sound/pcm/vchan.c
216

Then I can assign them to the parent channel's min/max as I do in the !feeder_rate_round case (will add appropriate AFMT_PASSTHROUGH check to make sure we never end up in the feeder_rate_round case for passthrough vchans).

Handle AFMT_PASSTHROUGH case: Set min/max to the parent's min/max.

Sorry for the delay, had some serious outage due to virus infection (me, not my machines). Just to make sure, this is for the SNDCTL_ENGINEINFO case, right?

There's another thing to check here, with > 8 channels we set the bitperfect flag on the parent channel, and sample rate conversion is not possible to my knowledge. That case is similar but separate from AFMT_PASSTHROUGH, see the check in sys/dev/sound/pcm/feeder_chain.c:

/*
   * If channel is in bitperfect or passthrough mode, make it appear
   * that 'origin' and 'target' identical, skipping mostly chain
   * procedures.
   */
  if (CHN_BITPERFECT(c) || (c->format & AFMT_PASSTHROUGH)) {

AFAIK, current convention is for drivers to set the bitperfect flag when channel count exceeds 8 outputs / inputs. At least snd_uaudio and the snd_hdsp* drivers do so. There's also the possibility to set the bitperfect sysctl for pcm devices, but I'm not sure how that affects vchans.

sys/dev/sound/pcm/vchan.c
227–228

I get a panic here when running ossinfo, it says "mutex not owned", at sys/dev/sound/pcm/channel.c:2409. The vchan_getcaps() function is called from dsp_oss_audioinfo().