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

Commit fd79c292 authored by Jaideep Sharma's avatar Jaideep Sharma
Browse files

audiopolicy: treat HDMI as part of last connected media device

Recognize HDMI as part of last connected media device.
So, if HDMI is connected last then media should be played
on HDMI.

Test: connect USB Headset then connect HDMI, check playback
Bug: 304884506

Change-Id: Ifa24b8d840e6201588bb4267672976f3918eb273
parent 1dc7cc18
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -79,6 +79,7 @@ device_out_group_t LastRemovableMediaDevices::getDeviceOutGroup(audio_devices_t
    case AUDIO_DEVICE_OUT_USB_ACCESSORY:
    case AUDIO_DEVICE_OUT_USB_DEVICE:
    case AUDIO_DEVICE_OUT_DGTL_DOCK_HEADSET:
    case AUDIO_DEVICE_OUT_AUX_DIGITAL:
        return GROUP_WIRED;
    case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP:
    case AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES:
+9 −7
Original line number Diff line number Diff line
@@ -296,7 +296,8 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy,
                            // excluding HEARING_AID and BLE_HEADSET because Dialer uses
                            // setCommunicationDevice to select them explicitly
                            AUDIO_DEVICE_OUT_HEARING_AID,
                            AUDIO_DEVICE_OUT_BLE_HEADSET
                            AUDIO_DEVICE_OUT_BLE_HEADSET,
                            AUDIO_DEVICE_OUT_AUX_DIGITAL
                            }));
        if (!devices.isEmpty()) break;
        devices = availableOutputDevices.getFirstDevicesFromTypes({
@@ -399,20 +400,21 @@ DeviceVector Engine::getDevicesForStrategyInt(legacy_strategy strategy,
        }

        if (devices2.isEmpty() && (getLastRemovableMediaDevices().size() > 0)) {
            std::vector<audio_devices_t> excludedDevices;
            // no sonification on aux digital (e.g. HDMI)
            if (strategy == STRATEGY_SONIFICATION) {
                excludedDevices.push_back(AUDIO_DEVICE_OUT_AUX_DIGITAL);
            }
            if ((getForceUse(AUDIO_POLICY_FORCE_FOR_MEDIA) != AUDIO_POLICY_FORCE_NO_BT_A2DP)) {
                // Get the last connected device of wired and bluetooth a2dp
                devices2 = availableOutputDevices.getFirstDevicesFromTypes(
                        getLastRemovableMediaDevices());
                        getLastRemovableMediaDevices(GROUP_NONE, excludedDevices));
            } else {
                // Get the last connected device of wired except bluetooth a2dp
                devices2 = availableOutputDevices.getFirstDevicesFromTypes(
                        getLastRemovableMediaDevices(GROUP_WIRED));
                        getLastRemovableMediaDevices(GROUP_WIRED, excludedDevices));
            }
        }
        if ((devices2.isEmpty()) && (strategy != STRATEGY_SONIFICATION)) {
            // no sonification on aux digital (e.g. HDMI)
            devices2 = availableOutputDevices.getDevicesFromType(AUDIO_DEVICE_OUT_AUX_DIGITAL);
        }
        if ((devices2.isEmpty()) &&
                (getForceUse(AUDIO_POLICY_FORCE_FOR_DOCK) == AUDIO_POLICY_FORCE_ANALOG_DOCK)) {
            devices2 = availableOutputDevices.getDevicesFromType(