Page MenuHomeFreeBSD

sound tests: Fix downshift calculation in pcm_read_write test
ClosedPublic

Authored by dev_submerge.ch on Feb 10 2025, 11:30 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Feb 26, 10:39 AM
Unknown Object (File)
Wed, Feb 26, 10:39 AM
Unknown Object (File)
Wed, Feb 26, 10:39 AM
Unknown Object (File)
Wed, Feb 26, 10:39 AM
Unknown Object (File)
Wed, Feb 26, 12:34 AM
Unknown Object (File)
Fri, Feb 21, 11:43 AM
Unknown Object (File)
Fri, Feb 21, 1:58 AM
Unknown Object (File)
Feb 20 2025, 2:05 AM
Subscribers

Details

Summary

In some situations the feeders in the sound module lower the pcm sample
resolution through a downshift of the sample value. The pcm_read_write
test implements this operation with an arithmetic division to avoid
implementation defined or architecture specific behavior.
Due to different rounding, the test produced marginally different sample
values, which made the test fail on 32 bit architectures. Correct this.

MFC after: 1 week

Diff Detail

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

Event Timeline

Tested it by undefing SND_PCM_64 and it works fine. Thank you.

This revision is now accepted and ready to land.Feb 11 2025, 11:34 AM
tests/sys/sound/pcm_read_write.c
88

I'd suggest adding { } around this block too

92–97

Values are the same for positive inputs; would a case for if (value < 0) be faster than the two modulo ops?

tests/sys/sound/pcm_read_write.c
92–97

I was thinking the same earlier, but it might be better to keep things straight forward. After all this is a function that only runs a few times in total; performance shouldn't really be a concern IMHO.

Put braces around if block as suggested.

This revision now requires review to proceed.Feb 11 2025, 11:03 PM
dev_submerge.ch added inline comments.
tests/sys/sound/pcm_read_write.c
92–97

It's less calculations vs breaking speculative execution, depending on the case. But this is executed like 16 times in total, so I don't think any further efforts are justified.

This revision is now accepted and ready to land.Feb 11 2025, 11:43 PM
christos retitled this revision from sound tests: Fix downshift calculation in pcm_read_write test. to sound tests: Fix downshift calculation in pcm_read_write test.Feb 18 2025, 7:35 PM