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

Commit d52ff5e0 authored by Paul McLean's avatar Paul McLean Committed by Android (Google) Code Review
Browse files

Merge "Changing AudioManager.listAudioDevicePorts to take a ArrayList<AudioDevicePort> argument."

parents 004a46eb ceb47aae
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -130,8 +130,7 @@ public class AudioDevicesManager {
    public ArrayList<AudioDeviceInfo> listDevices(int flags) {
        Slog.i(TAG, "AudioManager.listDevices(" + Integer.toHexString(flags) + ")");

        //FIXME - Use ArrayList<AudioDevicePort> when mAudioManager.listAudioDevicePorts() is fixed.
        ArrayList<AudioPort> ports = new ArrayList<AudioPort>();
        ArrayList<AudioDevicePort> ports = new ArrayList<AudioDevicePort>();
        int status = mAudioManager.listAudioDevicePorts(ports);

        Slog.i(TAG, "  status:" + status + " numPorts:" + ports.size());
@@ -140,9 +139,9 @@ public class AudioDevicesManager {

        if (status == AudioManager.SUCCESS) {
            deviceList = new ArrayList<AudioDeviceInfo>();
             for (AudioPort port : ports) {
                if (/*port instanceof AudioDevicePort &&*/ checkFlags((AudioDevicePort)port, flags)) {
                    deviceList.add(new AudioDeviceInfo((AudioDevicePort)port));
             for (AudioDevicePort port : ports) {
                if (checkFlags(port, flags)) {
                    deviceList.add(new AudioDeviceInfo(port));
                }
            }
        }
+2 −2
Original line number Diff line number Diff line
@@ -3459,14 +3459,14 @@ public class AudioManager {
     * @see listAudioPorts(ArrayList<AudioPort>)
     * @hide
     */
    public int listAudioDevicePorts(ArrayList<AudioPort> devices) {
    public int listAudioDevicePorts(ArrayList<AudioDevicePort> devices) {
        ArrayList<AudioPort> ports = new ArrayList<AudioPort>();
        int status = updateAudioPortCache(ports, null);
        if (status == SUCCESS) {
            devices.clear();
            for (int i = 0; i < ports.size(); i++) {
                if (ports.get(i) instanceof AudioDevicePort) {
                    devices.add(ports.get(i));
                    devices.add((AudioDevicePort)ports.get(i));
                }
            }
        }
+8 −10
Original line number Diff line number Diff line
@@ -699,15 +699,14 @@ class TvInputHardwareManager implements TvInputHal.Callback {

        private void findAudioSinkFromAudioPolicy(List<AudioDevicePort> sinks) {
            sinks.clear();
            ArrayList<AudioPort> devicePorts = new ArrayList<AudioPort>();
            ArrayList<AudioDevicePort> devicePorts = new ArrayList<AudioDevicePort>();
            if (mAudioManager.listAudioDevicePorts(devicePorts) != AudioManager.SUCCESS) {
                return;
            }
            int sinkDevice = mAudioManager.getDevicesForStream(AudioManager.STREAM_MUSIC);
            for (AudioPort port : devicePorts) {
                AudioDevicePort devicePort = (AudioDevicePort) port;
                if ((devicePort.type() & sinkDevice) != 0) {
                    sinks.add(devicePort);
            for (AudioDevicePort port : devicePorts) {
                if ((port.type() & sinkDevice) != 0) {
                    sinks.add(port);
                }
            }
        }
@@ -716,14 +715,13 @@ class TvInputHardwareManager implements TvInputHal.Callback {
            if (type == AudioManager.DEVICE_NONE) {
                return null;
            }
            ArrayList<AudioPort> devicePorts = new ArrayList<AudioPort>();
            ArrayList<AudioDevicePort> devicePorts = new ArrayList<AudioDevicePort>();
            if (mAudioManager.listAudioDevicePorts(devicePorts) != AudioManager.SUCCESS) {
                return null;
            }
            for (AudioPort port : devicePorts) {
                AudioDevicePort devicePort = (AudioDevicePort) port;
                if (devicePort.type() == type && devicePort.address().equals(address)) {
                    return devicePort;
            for (AudioDevicePort port : devicePorts) {
                if (port.type() == type && port.address().equals(address)) {
                    return port;
                }
            }
            return null;