mirror of
https://github.com/Anything-at-25-00/android_device_tecno_LG8n.git
synced 2024-11-22 21:56:26 -08:00
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:
parent
f8d0b72323
commit
35966292e8
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue