Use floats to define volumes in audio.volume.* settings



Firefox OS
5 years ago
5 years ago


(Reporter: mwu, Unassigned)


Firefox Tracking Flags

(Not tracked)




5 years ago
From my comment bug 876334:

The main problem I have is exposing the int value in mozSettings. There's nothing special about having 16 different volume levels - it's just an implementation detail in AudioFlinger. I would argue it was actually a bad decision there too - it's usually only hardware mixers that require 2^n volume levels. For any audio buffers that come from the host side, float volume levels simply involve multiplying the sample. To work with AudioFlinger, we can just round(volume * max_volume_index). Gaia would have to make sure to use powers of twos to ensure the volume changes mean anything though.

Comment 1

5 years ago

No matter we adjust volume by index or floating value, the most important thing is that how does gaia know what value is legal. Currently we hardcode the max_volume_index in sound_manager.js (gaia) so it can know what value is available to have a real level changing.

So I would like to propose we should have Web APIs for
  1. exposing how many levels are available on a specific AudioChannel.
     (ex: Normal/content channel is 15 levels but telephony is 5 levels)
     (ex: different audio backend may have different settings.)

  2. setting the volume directly not via settings, because 
     a. we can't pass the error back to Gaia side when error is occurred during ::observer(). 
     b. On the other hands, any apps declared setting permission can control the system volume. I would like to have individual permission to limit this.
     c. we can check the legal value in this web API not do it by Gaia itself only.

Does it make sense? Thanks.
You need to log in before you can comment on or make changes to this bug.