Bug 281390 - sound: OSS have no AFMT_FLOAT support
Summary: sound: OSS have no AFMT_FLOAT support
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Some People
Assignee: Christos Margiolis
URL:
Keywords:
Depends on:
Blocks: 280612
  Show dependency treegraph
 
Reported: 2024-09-09 12:38 UTC by Ivan Rozhuk
Modified: 2024-12-11 14:27 UTC (History)
7 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ivan Rozhuk 2024-09-09 12:38:33 UTC
Past issues:
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=157050
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=184380

In the wild some software from ports that have OSS support just define AFMT_FLOAT inside own code.

AFMT_FLOAT used in wine: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=264973
Currently as workaround wine builds with ALSA.


I suggest to add some in kernel conversion from AFMT_FLOAT to some thing that aleady support by "PCM subsystem mixing through its feeder subsystem" or update feeder subsystem to support AFMT_FLOAT.
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2024-09-30 05:45:30 UTC
^Triage: I don't see a proposed solution yet, so "In Progress" may be premature.
Comment 2 Christos Margiolis freebsd_committer freebsd_triage 2024-09-30 15:22:43 UTC
(In reply to Mark Linimon from comment #1)
I am working on it.
Comment 3 Christos Margiolis freebsd_committer freebsd_triage 2024-11-16 18:15:54 UTC
https://reviews.freebsd.org/D47638
Comment 6 Ed Maste freebsd_committer freebsd_triage 2024-11-19 16:01:26 UTC
(In reply to Ivan Rozhuk from comment #4)
Note that we need not plain float->int but rather (float*constant)->int; this could be done with integer instructions but either way this should be something we look at after profiling if the overhead of fpu_kern_enter/_leave is excessive.
Comment 7 Ivan Rozhuk 2024-11-19 17:51:20 UTC
(In reply to Ed Maste from comment #6)

(float*constant)->int -> float->(int*constant) ? :)

As described in http://0x80.pl/articles/convert-float-to-integer.html float to int conversion should be not so expensive as fpu_kern_**() staff.

Also their code simple and under BSD2 license.
Comment 8 Ivan Rozhuk 2024-12-11 05:56:37 UTC
		v = ((uint32_t)v & 0x000000ff) << 24 |
		    (v & 0x0000ff00) << 8 |
		    (v & 0x00ff0000) << 16 |
		    (v & 0xff000000) << 24;

bswap_32(), htonl() can do same.
Also this code look as err since 2 components move to 24 bits.
Comment 9 Christos Margiolis freebsd_committer freebsd_triage 2024-12-11 10:07:32 UTC
(In reply to Ivan Rozhuk from comment #8)
I did some rewriting before posting and missed this shifting error I accidentally introduced. I updated the diff. Thank you for pointing this out!

As for bswap32(), it will cast the in32_t value to uint32_t, which could produce a wrong value if the int32_t sample has a negative value. Or am I missing something?
Comment 10 Christos Margiolis freebsd_committer freebsd_triage 2024-12-11 14:27:58 UTC
(In reply to Christos Margiolis from comment #9)
After some further research, it seems that bswap32() should not be a problem.