Page MenuHomeFreeBSD

sound: Turn PCM_CLAMP_* macros into a function
Needs ReviewPublic

Authored by christos on Fri, Jan 10, 6:36 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sun, Jan 19, 6:20 AM
Unknown Object (File)
Sat, Jan 18, 8:21 AM
Unknown Object (File)
Sat, Jan 18, 6:36 AM
Unknown Object (File)
Sat, Jan 18, 5:43 AM
Unknown Object (File)
Sat, Jan 18, 4:05 AM
Unknown Object (File)
Fri, Jan 17, 12:18 PM
Unknown Object (File)
Thu, Jan 16, 7:25 AM
Subscribers

Details

Summary

This makes some subsequent feeder refactors easier to implement.

Sponsored by: The FreeBSD Foundation
MFC after: 1 week

Diff Detail

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

Event Timeline

sys/dev/sound/pcm/pcm.h
360

Not sure if we should return 0 or just sample unmodified.

This currently shifts 32bit samples out of the 32bit range in case SND_PCM_64 is not set. sample << PCM_FXSHIFT happens twice. The root cause is in D47932 though.

sys/dev/sound/pcm/pcm.h
337

To match how pcm_clamp() is used in the macros, and make it 64bit in case SND_PCM_64 is set (yes, bad type name).

354–356

This doesn't make sense to check for a 32bit signed int (typedef int32_t intpcm_t;). Also it's not what the original clamp checks if SND_PCM_64 is not set.

360

I think this code should never be executed anyway. Means we can return 0, but please put an assertion here.

christos added inline comments.
sys/dev/sound/pcm/pcm.h
354–356

I did fix the clamp checks, but I'm not sure what you mean by "to check for a 32bit signed int".

sys/dev/sound/pcm/pcm.h
354–356

That was a tautology, you can forget about it if you fix the clamp checks and the type of the sample argument. It was just the first thing to cross my mind, that a 32bit signed integer cannot exceed 32bit signed max and min values, and thus the check doesn't make sense.