Skip to content

Commit

Permalink
OboeTester: test in_channels=3 and SessionId
Browse files Browse the repository at this point in the history
Added to Data Paths to catch b/270535408

Fixes #2001
  • Loading branch information
philburk committed Apr 30, 2024
1 parent b8f12a8 commit 9a7d406
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ private static class TestStreamOptions {
public final int mmapUsed;
public final int performanceMode;
public final int sharingMode;
public final int sessionId;

public TestStreamOptions(StreamConfiguration configuration, int channelUsed) {
this.channelUsed = channelUsed;
Expand All @@ -89,6 +90,7 @@ public TestStreamOptions(StreamConfiguration configuration, int channelUsed) {
mmapUsed = configuration.isMMap() ? 1 : 0;
performanceMode = configuration.getPerformanceMode();
sharingMode = configuration.getSharingMode();
sessionId = configuration.getSessionId();
}

int countDifferences(TestStreamOptions other) {
Expand All @@ -100,6 +102,7 @@ int countDifferences(TestStreamOptions other) {
count += (mmapUsed != other.mmapUsed) ? 1 : 0;
count += (performanceMode != other.performanceMode) ? 1 : 0;
count += (sharingMode != other.sharingMode) ? 1 : 0;
count += (sessionId != other.sessionId) ? 1 : 0;
return count;
}

Expand All @@ -112,6 +115,7 @@ public String comparePassedDirection(String prefix, TestStreamOptions passed) {
text.append(TestDataPathsActivity.comparePassedField(prefix,this, passed, "mmapUsed"));
text.append(TestDataPathsActivity.comparePassedField(prefix,this, passed, "performanceMode"));
text.append(TestDataPathsActivity.comparePassedField(prefix,this, passed, "sharingMode"));
text.append(TestDataPathsActivity.comparePassedField(prefix,this, passed, "sessionId"));
return text.toString();
}
@Override
Expand Down Expand Up @@ -236,6 +240,7 @@ protected String getConfigText(StreamConfiguration config) {
+ ", ID = " + String.format(Locale.getDefault(), "%2d", config.getDeviceId())
+ ", Perf = " + StreamConfiguration.convertPerformanceModeToText(
config.getPerformanceMode())
+ ((config.getSessionId() > 0) ? (", sessionId = " + config.getSessionId()) : "")
+ ",\n ch = " + channelText(channel, config.getChannelCount())
+ ", cm = " + convertChannelMaskToText(config.getChannelMask());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.mobileer.oboetester;

import static com.mobileer.oboetester.IntentBasedTestSupport.configureStreamsFromBundle;
import static com.mobileer.oboetester.StreamConfiguration.UNSPECIFIED;
import static com.mobileer.oboetester.StreamConfiguration.convertChannelMaskToText;

import android.app.Instrumentation;
Expand All @@ -37,6 +38,8 @@

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Locale;

/**
Expand Down Expand Up @@ -572,6 +575,8 @@ private void testDeviceOutputInfo(AudioDeviceInfo outputDeviceInfo) throws Inte
requestedOutConfig.setDeviceId(outputDeviceInfo.getId());
resetChannelConfigurations(requestedInConfig, requestedOutConfig);

testBug_270535408(inputDeviceInfo, outputDeviceInfo);

if (mCheckBoxAllChannels.isChecked()) {
runOnUiThread(() -> mCheckBoxAllChannels.setEnabled(false));
testOutputChannelCounts(inputDeviceInfo, outputDeviceInfo);
Expand Down Expand Up @@ -695,7 +700,7 @@ public static int findLargestInt(int[] arr) {

private void testOutputChannelCounts(AudioDeviceInfo inputDeviceInfo, AudioDeviceInfo outputDeviceInfo) throws InterruptedException {
logSection("Output Channel Counts");
ArrayList<Integer> channelCountsTested =new ArrayList<Integer>();
ArrayList<Integer> channelCountsTested = new ArrayList<Integer>();
StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration;
StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration;

Expand Down Expand Up @@ -767,6 +772,26 @@ private void testMatchingChannels(int numChannels) throws InterruptedException {
}
}

// b/270535408 | no input when channels=3 and sessionId is allocated
private void testBug_270535408(AudioDeviceInfo inputDeviceInfo,
AudioDeviceInfo outputDeviceInfo) throws InterruptedException {
int[] inputChannelCounts = inputDeviceInfo.getChannelCounts();
if (findLargestChannelCount(inputChannelCounts) >= 3) {
logSection("Bug 270535408, 3ch + SessionId");
StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration;
StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration;
requestedInConfig.setChannelCount(3);
requestedInConfig.setSessionId(AudioManager.AUDIO_SESSION_ID_GENERATE);
requestedInConfig.setPerformanceMode(StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY);
requestedOutConfig.setPerformanceMode(StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY);
testCurrentConfigurations();
// Now test without a sessionId so we have a passing test to compare with.
requestedInConfig.setSessionId(-1); // AAUDIO_SESSION_ID_NONE
testCurrentConfigurations();
requestedInConfig.setChannelCount(UNSPECIFIED);
}
}

private void testPerformancePaths() throws InterruptedException {
StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration;
StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration;
Expand Down

0 comments on commit 9a7d406

Please sign in to comment.