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

Commit a477bab9 authored by Jason Simmons's avatar Jason Simmons
Browse files

Only send master volume or mute updates if the settings have changed

Change-Id: If12ec3b7a4b4bf5165d7538013759f07a845d8c4
parent 64006cb1
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -733,9 +733,11 @@ public class AudioService extends IAudioService.Stub {

    /** @see AudioManager#setMasterMute(boolean, IBinder) */
    public void setMasterMute(boolean state, IBinder cb) {
        if (state != AudioSystem.getMasterMute()) {
            AudioSystem.setMasterMute(state);
            sendMasterMuteUpdate(state, AudioManager.FLAG_SHOW_UI);
        }
    }

    /** get master mute state. */
    public boolean isMasterMute() {
@@ -762,10 +764,14 @@ public class AudioService extends IAudioService.Stub {
        if (!AudioSystem.getMasterMute()) {
            int oldVolume = getMasterVolume();
            AudioSystem.setMasterVolume(volume);

            int newVolume = getMasterVolume();
            if (newVolume != oldVolume) {
                // Post a persist master volume msg
                sendMsg(mAudioHandler, MSG_PERSIST_MASTER_VOLUME, 0, SENDMSG_REPLACE,
                        Math.round(volume * (float)1000.0), 0, null, PERSIST_DELAY);
            sendMasterVolumeUpdate(flags, oldVolume, getMasterVolume());
                sendMasterVolumeUpdate(flags, oldVolume, newVolume);
            }
        }
    }