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

Commit 0ab37791 authored by Jinsuk Kim's avatar Jinsuk Kim
Browse files

CEC: Replace determistic mute commands

Compatibility issues on deterministic mute control commands
<MUTE_FUNCTION>/<RESTORE_AUDIO_VOLUME> are hard to get around.
This CL falls back to going with a non-deterministic one <MUTE>.

Bug: 24986703
Change-Id: Ia4cc0cf5ce6846a8d3bfbe638487b76a9986de89
(cherry picked from commit bae1d89e5734c9a4341681712deb63213b0b8452)
parent b96bccf9
Loading
Loading
Loading
Loading
+16 −0
Original line number Diff line number Diff line
@@ -448,4 +448,20 @@ final class HdmiCecKeycode {
    static boolean isSupportedKeycode(int androidKeycode) {
        return HdmiCecKeycode.androidKeyToCecKey(androidKeycode) != null;
    }

    /**
     * Returns CEC keycode to control audio mute status.
     *
     * @param muting {@code true} if audio is being muted
     */
    public static int getMuteKey(boolean muting) {
        // CEC_KEYCODE_MUTE_FUNCTION, CEC_KEYCODE_RESTORE_VOLUME_FUNCTION are deterministic
        // commands that ensures the status changes to what we want, while CEC_KEYCODE_MUTE
        // simply toggles the status.
        // The former is a better choice in this regard, but there are compatibility issues
        // observed - many audio receivers don't recognize the commands. We fall back on
        // CEC_KEYCODE_MUTE for now.
        // return muting ? CEC_KEYCODE_MUTE_FUNCTION : CEC_KEYCODE_RESTORE_VOLUME_FUNCTION;
        return CEC_KEYCODE_MUTE;
    }
}
+1 −2
Original line number Diff line number Diff line
@@ -1099,8 +1099,7 @@ final class HdmiCecLocalDeviceTv extends HdmiCecLocalDevice {
        // Remove existing volume action.
        removeAction(VolumeControlAction.class);
        sendUserControlPressedAndReleased(getAvrDeviceInfo().getLogicalAddress(),
                mute ? HdmiCecKeycode.CEC_KEYCODE_MUTE_FUNCTION :
                        HdmiCecKeycode.CEC_KEYCODE_RESTORE_VOLUME_FUNCTION);
                HdmiCecKeycode.getMuteKey(mute));
    }

    @Override
+2 −4
Original line number Diff line number Diff line
@@ -68,10 +68,8 @@ final class SystemAudioStatusAction extends HdmiCecFeatureAction {
        // the audio amplifier is unknown.
        tv().setAudioStatus(false, Constants.UNKNOWN_VOLUME);

        int uiCommand = tv().isSystemAudioActivated()
                ? HdmiCecKeycode.CEC_KEYCODE_RESTORE_VOLUME_FUNCTION  // SystemAudioMode: ON
                : HdmiCecKeycode.CEC_KEYCODE_MUTE_FUNCTION;           // SystemAudioMode: OFF
        sendUserControlPressedAndReleased(mAvrAddress, uiCommand);
        sendUserControlPressedAndReleased(mAvrAddress,
                HdmiCecKeycode.getMuteKey(!tv().isSystemAudioActivated()));

        // Still return SUCCESS to callback.
        finishWithCallback(HdmiControlManager.RESULT_SUCCESS);