Page MenuHomeFreeBSD

sound: Initialize channels with sane default rate and format
ClosedPublic

Authored by christos on Jan 12 2025, 12:55 AM.
Tags
None
Referenced Files
F111029296: D48434.id151460.diff
Wed, Feb 26, 10:37 AM
F111029287: D48434.id149143.diff
Wed, Feb 26, 10:37 AM
F111029283: D48434.id.diff
Wed, Feb 26, 10:37 AM
F110999517: D48434.diff
Wed, Feb 26, 12:33 AM
Unknown Object (File)
Tue, Feb 25, 2:23 PM
Unknown Object (File)
Fri, Feb 21, 7:35 AM
Unknown Object (File)
Thu, Feb 20, 6:08 AM
Unknown Object (File)
Mon, Feb 17, 2:39 AM
Subscribers

Details

Summary

There is no good reason to initialize with AFMT_U8 at 8000Hz.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

sys/dev/sound/pcm/channel.c
1208–1210

Shouldn't we try to match here what we set for vchanformat and vchanrate? That would be the driver's selected rate for example, at least with all your patches applied. Or maybe fix it the other way round, it's just that we already start with different settings here.

sys/dev/sound/pcm/channel.c
1208–1210

Without D47917, vchanrate and vchanformat are initialized after the first vchans' creation during attach, but because the primary channels are created first, they wouldn't be able to use vchanrate and vchanformat here, and would instead need to wait for the chn_reset()s in vchan_create() in order to get an actual speed & format. The vchan defaults are S16_LE:2.0 at 48000 Hz anyway, which is what I'm also doing here, so without any manual vchan settings, these values should be the same as vchanrate and vchanformat.

Without D47917, they are not initialized at all until the first vchan is created, so we can also not use them here.

I see now that there's a chn_reset() following this for primary channels, which means the defaults here may be overridden if not compatible. Also my concern was in conjunction with D48435, but I think we have to fix it there.

This revision is now accepted and ready to land.Jan 21 2025, 7:58 PM