Closed Bug 1814359 Opened 1 year ago Closed 1 year ago

Switch audio to 24-bit precision on platforms using sndio

Categories

(Core :: Audio/Video: cubeb, enhancement)

Firefox 109
All
OpenBSD
enhancement

Tracking

()

RESOLVED FIXED
112 Branch
Tracking Status
firefox112 --- fixed

People

(Reporter: alex, Assigned: padenot)

References

()

Details

Attachments

(4 files)

User Agent: Mozilla/5.0 (X11; OpenBSD amd64; rv:109.0) Gecko/20100101 Firefox/109.0

Steps to reproduce:

Play or record audio.

Actual results:

If the sndio backend of libcubeb is used, the resulting audio is converted from float to 16-bit integers.

Expected results:

The resulting audio should be 24-bit. Both firefox and sndiod use greater precision internally, so there's no point converting back and forth to 16-bit. Firefox uses 'float' for sample representation (which has 24-bit precision at full dynamic range) and the sndiod server uses 24-bit fixed-point numbers.

The proposed patch simply changes the precision to 24-bit. It converts floats from/to the format used internally by the sndiod server. This not only improves the precision, but also saves few CPU cycles as sndiod server doesn't need the extra conversion from/to 16-bit anymore.

The Bugbug bot thinks this bug should belong to the 'Core::Audio/Video: cubeb' component, and is moving the bug to that component. Please correct in case you think the bot is wrong.

Component: Untriaged → Audio/Video: cubeb
Product: Firefox → Core

setting platform to OpenBSD but that might be of interest for other sndio users on linux and FreeBSD ?

OS: Unspecified → OpenBSD
Hardware: Unspecified → All

before doing a PR on the github repo, what do you think of the intent paul ?

Flags: needinfo?(padenot)

Yeah this is the right thing to do I think, thanks for the patch. Other cubeb backends on desktop platforms use float32 internally (and then the OS decides what it prefers later in the pipeline, this depends on the OS, OS version, configuration and what hardware is hooked up to it). If this is an option for sndio, it's something we could consider as well.

Android still uses int16 everywhere for historical reasons (because we used to run Firefox on Android devices that have very poor fpu), but I'm thinking of changing that, because it's a bit of a pain to maintain two paths. Mobile devices have had very capable CPUs for a long time now.

All that to say, please send this as a PR upstream, and I'll get it merged there + imported in Firefox shortly.

Flags: needinfo?(padenot)

(In reply to Paul Adenot (:padenot) from comment #4)

Yeah this is the right thing to do I think, thanks for the patch. Other cubeb backends on desktop platforms use float32 internally (and then the OS decides what it prefers later in the pipeline, this depends on the OS, OS version, configuration and what hardware is hooked up to it). If this is an option for sndio, it's something we could consider as well.

The sndio API doesn't support floats, but note taken for the future.

the patch is now shipping to OpenBSD users backported to 110. Can we get cubeb upgraded in firefox ?

Flags: needinfo?(padenot)
Assignee: nobody → padenot
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true

Sorry for the delay, here it is (and also fixing an unrelated issue in our vendoring system).

Flags: needinfo?(padenot)
Pushed by padenot@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/7026280c2b03
Add a missing patch statement in cubeb's moz.yaml, fix path in patch file. r=cubeb-reviewers,kinetik
https://hg.mozilla.org/integration/autoland/rev/f857110d7111
Update libcubeb to revision 70b4e3db. r=cubeb-reviewers,kinetik
https://hg.mozilla.org/integration/autoland/rev/84d4a4e7dab6
Reapply in-tree patch for libcubeb. r=cubeb-reviewers,kinetik
Status: ASSIGNED → RESOLVED
Closed: 1 year ago
Resolution: --- → FIXED
Target Milestone: --- → 112 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: