LG8n: InCallService: Map AOSP gain step range to MTK one

MTK has 15 volume steps, we have whatever is set in vc_call_vol_steps.
Mapping our range to theirs allows reaching higher volume levels.

A log curve is used to make gain transitions less abrupt at higher volumes.

Change-Id: I5f0e6467ba9fd0779d7e4abbf9f258b0b42224e4
Signed-off-by: fjrXTR <fajarslebew31@gmail.com>
Signed-off-by: xyzuniverse <dev.xyzuniverse@gmail.com>
Signed-off-by: fjrXTR <fajarslebew31@gmail.com>
Signed-off-by: Shirayuki39 <lorddemecrius83@proton.me>
This commit is contained in:
telepathine 2022-08-15 13:41:12 +02:00 committed by Shirayuki39
parent df9b347312
commit 7a4571151c

View file

@ -1,15 +1,20 @@
package org.lineageos.mediatek.incallservice;
import android.os.SystemProperties;
import android.media.AudioSystem;
import android.util.Log;
public class GainUtils {
public static final String LOG_TAG = "MediatekInCallService";
public static void setGainLevel(int audioDevice, int gainIndex, int streamType) {
int maxStep = SystemProperties.getInt("ro.config.vc_call_vol_steps", 7);
String parameters = String.format("volumeDevice=%d;volumeIndex=%d;volumeStreamType=%d",
audioDevice, Math.min(7, gainIndex), streamType);
audioDevice,
Math.round(
(15.0 / Math.log(maxStep + 1.0))
* Math.log(Math.min(maxStep, gainIndex) + 1.0)),
streamType);
Log.d(LOG_TAG, "Setting audio parameters to: " + parameters);
AudioSystem.setParameters(parameters);
}