From a559a83bb4bbd7a0988384da1eb7bd7dcb993de9 Mon Sep 17 00:00:00 2001 From: Phil Burk Date: Tue, 13 Aug 2024 17:18:57 -0700 Subject: [PATCH] OboeTester: limit number of channels tested in Data Paths Do not test more USB device output channels than there are inputs. Fixes #2087 --- .../oboetester/TestDataPathsActivity.java | 46 +++++++++++-------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDataPathsActivity.java b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDataPathsActivity.java index 0b1eaab5d..4b0a99897 100644 --- a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDataPathsActivity.java +++ b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDataPathsActivity.java @@ -708,12 +708,14 @@ public static int findLargestInt(int[] arr) { } private void testOutputChannelCounts(AudioDeviceInfo inputDeviceInfo, AudioDeviceInfo outputDeviceInfo) throws InterruptedException { + final int maxOutputChannelsToTest = 4; // takes too long logSection("Output Channel Counts"); ArrayList channelCountsTested = new ArrayList(); StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration; StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration; int[] outputChannelCounts = outputDeviceInfo.getChannelCounts(); + // Are the output channels mixed together in the air or in a loopback plug? if (isDeviceTypeMixedForLoopback(outputDeviceInfo.getType())) { requestedInConfig.setChannelCount(1); setInputChannel(0); @@ -729,22 +731,30 @@ private void testOutputChannelCounts(AudioDeviceInfo inputDeviceInfo, AudioDevic testPerformancePaths(); setOutputChannel(1); testPerformancePaths(); + // Test channels for each channelCount above 2 for (int numChannels : outputChannelCounts) { - log("numChannels = " + numChannels); - if (numChannels > 4) { - log("numChannels forced to 4!"); - } - if (!channelCountsTested.contains(numChannels)) { - requestedOutConfig.setChannelCount(numChannels); - channelCountsTested.add(numChannels); - for (int channel = 0; channel < numChannels; channel++) { - setOutputChannel(channel); - testPerformancePaths(); + if (numChannels > maxOutputChannelsToTest) { + log("skip numChannels = " + numChannels); + } else { + if (!channelCountsTested.contains(numChannels)) { + log("--- test numChannels = " + numChannels); + requestedOutConfig.setChannelCount(numChannels); + channelCountsTested.add(numChannels); + for (int channel = 0; channel < numChannels; channel++) { + setOutputChannel(channel); + testPerformancePaths(); + } } } + } } else { + // This device does not mix so we have to match the input and output channel indices. + // Find the maximum number of input channels. + int[] inputChannelCounts = inputDeviceInfo.getChannelCounts(); + int maxInputChannels = findLargestChannelCount(inputChannelCounts); + int maxInputChannelsToTest = Math.min(maxOutputChannelsToTest, maxInputChannels); // test mono testMatchingChannels(1); channelCountsTested.add(1); @@ -753,14 +763,14 @@ private void testOutputChannelCounts(AudioDeviceInfo inputDeviceInfo, AudioDevic channelCountsTested.add(2); // Test matching channels for each channelCount above 2 for (int numChannels : outputChannelCounts) { - log("numChannels = " + numChannels); - if (numChannels > 4) { - log("numChannels forced to 4!"); - numChannels = 4; - } - if (!channelCountsTested.contains(numChannels)) { - testMatchingChannels(numChannels); - channelCountsTested.add(numChannels); + if (numChannels > maxInputChannelsToTest) { + log("skip numChannels = " + numChannels + " because > #inputs"); + } else { + if (!channelCountsTested.contains(numChannels)) { + log("--- test numChannels = " + numChannels); + testMatchingChannels(numChannels); + channelCountsTested.add(numChannels); + } } } }