17

AudioManager has a setParameters method that accepts a Key-Value pair in string representation ("parameter_name=parameter_value").
Internally, it calls native AudioSystem.setParameters.
The only way to get a parameter value is if you know its name, by calling AudioManager.getParameters method which calls the corresponding native method in `AudioSystem'.

Is there a way (using reflection or other techniques) to get a list of supported parameters (of course the result will be dependent on the device it is called on as it is platform-specific)?

Oren
  • 937
  • 1
  • 10
  • 34

1 Answers1

7

After brief investigation I can guess that there is no reliable way to enumerate all available keys for audio device parameters. Android headers define small set of general parameters, that probably should be supported by all devices. You can find actual keys here (look for AUDIO_PARAMETER_* macros). And interface to actual device implementation struct audio_hw_device (that is implemented by vendor) has only get_parameters()/set_parameters() and no enumeration entry points. So, there is no way to request full list of supported parameter keys.

To top it off:

  1. we have small set of predefined, common parameters
  2. to cope with vendor-specific parameters - we should obtain list of extra keys from vendor docs or hardware related sources for particular device.

Any correctives are welcome.

Sergio
  • 8,099
  • 2
  • 26
  • 52
  • Do they work for you? Trying on Galaxy S7 with Android 8, all of them return me an empty string... Example: `audioManager.getParameters("channels")` – android developer Jun 26 '18 at 07:58
  • I haven't tried it with Oreo, but seems like a lot of keys were removed in newest versions. Take a look at audio.h for some 8.0 revision. – Sergio Jun 28 '18 at 03:47
  • Where exactly is the best place to find it, and what to look for in the file? – android developer Jun 28 '18 at 06:46
  • Just open link from answer and change Android revision. E.g. https://android.googlesource.com/platform/hardware/libhardware/+/android-8.1.0_r33/include/hardware/audio.h. Look for AUDIO_PARAMETER_* as answer says. – Sergio Jun 28 '18 at 14:57
  • Thank you. Seems to have a lot of abbreviations. Wonder what each means, and if any of them could help with my issue on call recording: https://stackoverflow.com/q/50970915/878126 – android developer Jun 28 '18 at 19:37