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

Commit cdd69e63 authored by Oscar Azucena's avatar Oscar Azucena Committed by Android (Google) Code Review
Browse files

Merge "Refactored base code to getDeviceForPortId"

parents 82231edf 6c6e871f
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
@@ -298,15 +298,7 @@ public final class AudioPlaybackConfiguration implements Parcelable {
        if (mDeviceId == PLAYER_DEVICEID_INVALID) {
            return null;
        }
        // TODO(175802592): change this to AudioManager.getDeviceForPortId() when available
        AudioDeviceInfo[] devices =
                AudioManager.getDevicesStatic(AudioManager.GET_DEVICES_OUTPUTS);
        for (int i = 0; i < devices.length; i++) {
            if (devices[i].getId() == mDeviceId) {
                return devices[i];
            }
        }
        return null;
        return AudioManager.getDeviceForPortId(mDeviceId, AudioManager.GET_DEVICES_OUTPUTS);
    }

    /**
+1 −8
Original line number Diff line number Diff line
@@ -1578,14 +1578,7 @@ public class AudioRecord implements AudioRouting, MicrophoneDirection,
        if (deviceId == 0) {
            return null;
        }
        AudioDeviceInfo[] devices =
                AudioManager.getDevicesStatic(AudioManager.GET_DEVICES_INPUTS);
        for (int i = 0; i < devices.length; i++) {
            if (devices[i].getId() == deviceId) {
                return devices[i];
            }
        }
        return null;
        return AudioManager.getDeviceForPortId(deviceId, AudioManager.GET_DEVICES_INPUTS);
    }

    /*
+2 −8
Original line number Diff line number Diff line
@@ -262,14 +262,8 @@ public final class AudioRecordingConfiguration implements Parcelable {
                final AudioPortConfig[] sources = patch.sources();
                if ((sources != null) && (sources.length > 0)) {
                    // not supporting multiple sources, so just look at the first source
                    final int devId = sources[0].port().id();
                    final AudioDeviceInfo[] devices =
                            AudioManager.getDevicesStatic(AudioManager.GET_DEVICES_INPUTS);
                    for (int j = 0; j < devices.length; j++) {
                        if (devices[j].getId() == devId) {
                            return devices[j];
                        }
                    }
                    int devId = sources[0].port().id();
                    return AudioManager.getDeviceForPortId(devId, AudioManager.GET_DEVICES_INPUTS);
                }
                // patch handle is unique, there won't be another with the same handle
                break;
+1 −8
Original line number Diff line number Diff line
@@ -3493,14 +3493,7 @@ public class AudioTrack extends PlayerBase
        if (deviceId == 0) {
            return null;
        }
        AudioDeviceInfo[] devices =
                AudioManager.getDevicesStatic(AudioManager.GET_DEVICES_OUTPUTS);
        for (int i = 0; i < devices.length; i++) {
            if (devices[i].getId() == deviceId) {
                return devices[i];
            }
        }
        return null;
        return AudioManager.getDeviceForPortId(deviceId, AudioManager.GET_DEVICES_OUTPUTS);
    }

    private void tryToDisableNativeRoutingCallback() {
+1 −8
Original line number Diff line number Diff line
@@ -1484,14 +1484,7 @@ public class MediaPlayer extends PlayerBase
        if (deviceId == 0) {
            return null;
        }
        AudioDeviceInfo[] devices =
                AudioManager.getDevicesStatic(AudioManager.GET_DEVICES_OUTPUTS);
        for (int i = 0; i < devices.length; i++) {
            if (devices[i].getId() == deviceId) {
                return devices[i];
            }
        }
        return null;
        return AudioManager.getDeviceForPortId(deviceId, AudioManager.GET_DEVICES_OUTPUTS);
    }


Loading