Page MenuHomeFreeBSD

sound tests: Fix downshift calculation in pcm_read_write test.
AcceptedPublic

Authored by dev_submerge.ch on Mon, Feb 10, 11:30 PM.

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 Skipped
Unit
Tests Skipped
Build Status
Buildable 62350
Build 59234: arc lint + arc unit

Event Timeline

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

This revision is now accepted and ready to land.Tue, Feb 11, 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.Tue, Feb 11, 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.Tue, Feb 11, 11:43 PM