Page MenuHomeFreeBSD

sound: Implement AFMT_FLOAT support
Needs ReviewPublic

Authored by christos on Sat, Nov 16, 6:15 PM.
Tags
None
Referenced Files
F102864316: D47638.id146593.diff
Mon, Nov 18, 4:04 AM
F102844804: D47638.diff
Sun, Nov 17, 10:10 PM
F102836701: D47638.diff
Sun, Nov 17, 7:40 PM
F102834911: D47638.id146593.diff
Sun, Nov 17, 7:04 PM
Unknown Object (File)
Sun, Nov 17, 4:00 PM
Unknown Object (File)
Sun, Nov 17, 3:45 PM
Unknown Object (File)
Sat, Nov 16, 7:16 PM
Unknown Object (File)
Sat, Nov 16, 6:41 PM

Details

Summary

Even though the OSS manual [1] advises against using AFMT_FLOAT, there
are applications that expect the sound driver to support it, and might
not work properly without it.

This patch adds AFMT_FLOAT in sys/soundcard.h and implements AFMT_FLOAT
<-> AFMT_S32_LE conversion functions. As a result, applications can
write/read floats to/from sound(4), but internally, because sound(4)
works with integers, we convert AFMT_FLOAT to AFMT_S32_LE before doing
any processing.

[1] http://manuals.opensound.com/developer/AFMT_FLOAT.html

PR: 281390, 157050, 184380, 264973
Sponsored by: The FreeBSD Foundation
MFC after: 2 days

Diff Detail

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

Event Timeline

Hello,

i can confirm so far that it works fine with emulators/wine.

I did took 2 FMOD games for testing (Way of the Hunter and Roboquest) that required AFMT_FLOAT.

Thank you for your work!

sys/dev/sound/pcm/feeder_format.c
68

I'm a bit worried about a possible performance impact, and we might need to hoist the fpu_kern_enter / fpu_kern_leaave up a level, but we can profile it and see what the impact actually is.

Very welcome, thanks for tackling this @christos. Please note that there are sound cards supporting float format, and I intend to experiment with that some time in the future (probably needs bitperfect for now).

sys/dev/sound/pcm/feeder_format.c
68

I'm a bit worried about a possible performance impact, and we might need to hoist the fpu_kern_enter / fpu_kern_leaave up a level, but we can profile it and see what the impact actually is.

+1. Also the way this function is called through a function pointer for every sample seems quite inefficient, at least I don't see how it could be inlined there. Means a restructuring could help all format conversions, not just float.

Although I see moving format conversions out to userland as the better option in the middle to long term, anyway.