Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f2b0c11f authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by Android (Google) Code Review
Browse files

Fix sound effect attenuation calculation

The sound effect volume attenuation calculation is wrong: the
 division by 20 was always returning 1 or 0.
In AudioService, rename the sound effect attenuation value to
 follow the naming conventions for static variables.

Change-Id: I3c36d50f4470ff09ca98cb944aefb5ad0f968782
parent 70d0c153
Loading
Loading
Loading
Loading
+3 −3
Original line number Original line Diff line number Diff line
@@ -382,7 +382,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
    // message looper for SoundPool listener
    // message looper for SoundPool listener
    private Looper mSoundPoolLooper = null;
    private Looper mSoundPoolLooper = null;
    // volume applied to sound played with playSoundEffect()
    // volume applied to sound played with playSoundEffect()
    private static int SOUND_EFFECT_VOLUME_DB;
    private static int sSoundEffectVolumeDb;
    // getActiveStreamType() will return STREAM_NOTIFICATION during this period after a notification
    // getActiveStreamType() will return STREAM_NOTIFICATION during this period after a notification
    // stopped
    // stopped
    private static final int NOTIFICATION_VOLUME_DELAY_MS = 5000;
    private static final int NOTIFICATION_VOLUME_DELAY_MS = 5000;
@@ -439,7 +439,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
            "ro.config.vc_call_vol_steps",
            "ro.config.vc_call_vol_steps",
           MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);
           MAX_STREAM_VOLUME[AudioSystem.STREAM_VOICE_CALL]);


        SOUND_EFFECT_VOLUME_DB = context.getResources().getInteger(
        sSoundEffectVolumeDb = context.getResources().getInteger(
                com.android.internal.R.integer.config_soundEffectVolumeDb);
                com.android.internal.R.integer.config_soundEffectVolumeDb);


        mVolumePanel = new VolumePanel(context, this);
        mVolumePanel = new VolumePanel(context, this);
@@ -2882,7 +2882,7 @@ public class AudioService extends IAudioService.Stub implements OnFinished {
                float volFloat;
                float volFloat;
                // use default if volume is not specified by caller
                // use default if volume is not specified by caller
                if (volume < 0) {
                if (volume < 0) {
                    volFloat = (float)Math.pow(10, SOUND_EFFECT_VOLUME_DB/20);
                    volFloat = (float)Math.pow(10, (float)sSoundEffectVolumeDb/20);
                } else {
                } else {
                    volFloat = (float) volume / 1000.0f;
                    volFloat = (float) volume / 1000.0f;
                }
                }
+1 −1
Original line number Original line Diff line number Diff line
@@ -335,7 +335,7 @@ public class KeyguardViewMediator implements KeyguardViewCallback,
        }
        }
        int lockSoundDefaultAttenuation = context.getResources().getInteger(
        int lockSoundDefaultAttenuation = context.getResources().getInteger(
                com.android.internal.R.integer.config_lockSoundVolumeDb);
                com.android.internal.R.integer.config_lockSoundVolumeDb);
        mLockSoundVolume = (float)Math.pow(10, lockSoundDefaultAttenuation/20);
        mLockSoundVolume = (float)Math.pow(10, (float)lockSoundDefaultAttenuation/20);
        IntentFilter userFilter = new IntentFilter();
        IntentFilter userFilter = new IntentFilter();
        userFilter.addAction(Intent.ACTION_USER_SWITCHED);
        userFilter.addAction(Intent.ACTION_USER_SWITCHED);
        userFilter.addAction(Intent.ACTION_USER_REMOVED);
        userFilter.addAction(Intent.ACTION_USER_REMOVED);