From b701ac026661d2a5be0079ed023bb75d4f651e26 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 26 Apr 2023 14:14:59 -0700 Subject: [PATCH] Fixed building with Java 1.7 --- .../java/org/libsdl/app/SDLAudioManager.java | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/android-project/app/src/main/java/org/libsdl/app/SDLAudioManager.java b/android-project/app/src/main/java/org/libsdl/app/SDLAudioManager.java index 54c2b1017..cee88913f 100644 --- a/android-project/app/src/main/java/org/libsdl/app/SDLAudioManager.java +++ b/android-project/app/src/main/java/org/libsdl/app/SDLAudioManager.java @@ -35,12 +35,16 @@ public class SDLAudioManager { mAudioDeviceCallback = new AudioDeviceCallback() { @Override public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) { - Arrays.stream(addedDevices).forEach(deviceInfo -> addAudioDevice(deviceInfo.isSink(), deviceInfo.getId())); + for (AudioDeviceInfo deviceInfo : addedDevices) { + addAudioDevice(deviceInfo.isSink(), deviceInfo.getId()); + } } @Override public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) { - Arrays.stream(removedDevices).forEach(deviceInfo -> removeAudioDevice(deviceInfo.isSink(), deviceInfo.getId())); + for (AudioDeviceInfo deviceInfo : removedDevices) { + removeAudioDevice(deviceInfo.isSink(), deviceInfo.getId()); + } } }; } @@ -286,25 +290,25 @@ public class SDLAudioManager { private static AudioDeviceInfo getInputAudioDeviceInfo(int deviceId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); - return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)) - .filter(deviceInfo -> deviceInfo.getId() == deviceId) - .findFirst() - .orElse(null); - } else { - return null; + for (AudioDeviceInfo deviceInfo : audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)) { + if (deviceInfo.getId() == deviceId) { + return deviceInfo; + } + } } + return null; } private static AudioDeviceInfo getOutputAudioDeviceInfo(int deviceId) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) { AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE); - return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)) - .filter(deviceInfo -> deviceInfo.getId() == deviceId) - .findFirst() - .orElse(null); - } else { - return null; + for (AudioDeviceInfo deviceInfo : audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)) { + if (deviceInfo.getId() == deviceId) { + return deviceInfo; + } + } } + return null; } private static void registerAudioDeviceCallback() {