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 cfcb03649..bc66a970f 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 @@ -62,6 +62,9 @@ public class TestDataPathsActivity extends BaseAutoGlitchActivity { public static final String KEY_USE_ALL_OUTPUT_CHANNEL_MASKS = "use_all_output_channel_masks"; public static final boolean VALUE_DEFAULT_USE_ALL_OUTPUT_CHANNEL_MASKS = false; + public static final String KEY_USE_ALL_SAMPLE_RATES = "use_all_sample_rates"; + public static final boolean VALUE_DEFAULT_USE_ALL_SAMPLE_RATES = false; + public static final String KEY_SINGLE_TEST_INDEX = "single_test_index"; public static final int VALUE_DEFAULT_SINGLE_TEST_INDEX = -1; @@ -124,6 +127,7 @@ public class TestDataPathsActivity extends BaseAutoGlitchActivity { private CheckBox mCheckBoxInputDevices; private CheckBox mCheckBoxOutputDevices; private CheckBox mCheckBoxAllOutputChannelMasks; + private CheckBox mCheckBoxAllSampleRates; private static final int[] INPUT_PRESETS = { StreamConfiguration.INPUT_PRESET_GENERIC, @@ -166,6 +170,21 @@ public class TestDataPathsActivity extends BaseAutoGlitchActivity { StreamConfiguration.CHANNEL_7POINT1POINT4, }; + private static final int[] SAMPLE_RATES = { + 8000, + 11025, + 12000, + 16000, + 22050, + 24000, + 32000, + 44100, + 48000, + 64000, + 88200, + 96000, + }; + @NonNull public static String comparePassedField(String prefix, Object failed, Object passed, String name) { try { @@ -290,6 +309,8 @@ protected void onCreate(Bundle savedInstanceState) { mCheckBoxOutputDevices = (CheckBox)findViewById(R.id.checkbox_paths_output_devices); mCheckBoxAllOutputChannelMasks = (CheckBox)findViewById(R.id.checkbox_paths_all_output_channel_masks); + mCheckBoxAllSampleRates = + (CheckBox)findViewById(R.id.checkbox_paths_all_sample_rates); } @Override @@ -393,18 +414,22 @@ String getOneLineSummary() { + ", IN" + (actualInConfig.isMMap() ? "-M" : "-L") + " D=" + actualInConfig.getDeviceId() + ", ch=" + channelText(getInputChannel(), actualInConfig.getChannelCount()) + + ", SR=" + actualInConfig.getSampleRate() + ", OUT" + (actualOutConfig.isMMap() ? "-M" : "-L") + " D=" + actualOutConfig.getDeviceId() + ", ch=" + channelText(getOutputChannel(), actualOutConfig.getChannelCount()) + + ", SR=" + actualOutConfig.getSampleRate() + ", mag = " + getMagnitudeText(mMaxMagnitude); } void setupDeviceCombo(int inputChannelCount, int inputChannelMask, int inputChannel, + int inputSampleRate, int outputChannelCount, int outputChannelMask, - int outputChannel) throws InterruptedException { + int outputChannel, + int outputSampleRate) throws InterruptedException { // Configure settings StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration; StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration; @@ -418,6 +443,9 @@ void setupDeviceCombo(int inputChannelCount, requestedInConfig.setSharingMode(StreamConfiguration.SHARING_MODE_SHARED); requestedOutConfig.setSharingMode(StreamConfiguration.SHARING_MODE_SHARED); + requestedInConfig.setSampleRate(inputSampleRate); + requestedOutConfig.setSampleRate(outputSampleRate); + if (inputChannelMask != 0) { requestedInConfig.setChannelMask(inputChannelMask); } else { @@ -452,8 +480,8 @@ void testPresetCombo(int inputPreset, int outputChannel, boolean mmapEnabled ) throws InterruptedException { - setupDeviceCombo(numInputChannels, 0, inputChannel, numOutputChannels, 0, - outputChannel); + setupDeviceCombo(numInputChannels, 0, inputChannel, 48000, + numOutputChannels, 0, outputChannel, 48000); StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration; requestedInConfig.setInputPreset(inputPreset); @@ -508,20 +536,21 @@ void testInputDeviceCombo(int deviceId, int channelCount, int channelMask, int inputChannel, + int inputSampleRate, boolean mmapEnabled) throws InterruptedException { String typeString = AudioDeviceInfoConverter.typeToString(deviceType); if (channelMask != 0) { setTestName("Test InDev: #" + deviceId + " " + typeString + "_" + convertChannelMaskToText(channelMask) + "_" + - inputChannel + "/" + channelCount); + inputChannel + "/" + channelCount + "_" + inputSampleRate); } else { setTestName("Test InDev: #" + deviceId + " " + typeString - + "_" + inputChannel + "/" + channelCount); + + "_" + inputChannel + "/" + channelCount + "_" + inputSampleRate); } final int numOutputChannels = 2; - setupDeviceCombo(channelCount, channelMask, inputChannel, numOutputChannels, 0, - 0); + setupDeviceCombo(channelCount, channelMask, inputChannel, inputSampleRate, + numOutputChannels, 0, 0, 48000); StreamConfiguration requestedInConfig = mAudioInputTester.requestedConfiguration; requestedInConfig.setInputPreset(StreamConfiguration.INPUT_PRESET_VOICE_RECOGNITION); @@ -539,13 +568,14 @@ void testInputDeviceCombo(int deviceId, int deviceType, int channelCount, int channelMask, - int inputChannel) throws InterruptedException { + int inputChannel, + int inputSampleRate) throws InterruptedException { if (NativeEngine.isMMapSupported()) { testInputDeviceCombo(deviceId, deviceType, channelCount, channelMask, inputChannel, - true); + inputSampleRate, true); } testInputDeviceCombo(deviceId, deviceType, channelCount, channelMask, inputChannel, - false); + inputSampleRate, false); } void testInputDevices() throws InterruptedException { @@ -563,21 +593,29 @@ void testInputDevices() throws InterruptedException { int[] channelCounts = deviceInfo.getChannelCounts(); numTested++; // Always test mono and stereo. - testInputDeviceCombo(id, deviceType, 1, 0, 0); - testInputDeviceCombo(id, deviceType, 2, 0, 0); - testInputDeviceCombo(id, deviceType, 2, 0, 1); + testInputDeviceCombo(id, deviceType, 1, 0, 0, 48000); + testInputDeviceCombo(id, deviceType, 2, 0, 0, 48000); + testInputDeviceCombo(id, deviceType, 2, 0, 1, 48000); if (channelCounts.length > 0) { for (int numChannels : channelCounts) { // Test higher channel counts. if (numChannels > 2) { log("numChannels = " + numChannels + "\n"); for (int channel = 0; channel < numChannels; channel++) { - testInputDeviceCombo(id, deviceType, numChannels, 0, channel); + testInputDeviceCombo(id, deviceType, numChannels, 0, channel, + 48000); } } } } + runOnUiThread(() -> mCheckBoxAllSampleRates.setEnabled(false)); + if (mCheckBoxAllSampleRates.isChecked()) { + for (int sampleRate : SAMPLE_RATES) { + testInputDeviceCombo(id, deviceType, 1, 0, 0, sampleRate); + } + } + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S_V2) { int[] channelMasks = deviceInfo.getChannelMasks(); if (channelMasks.length > 0) { @@ -592,7 +630,7 @@ void testInputDevices() throws InterruptedException { int channelCount = Integer.bitCount(nativeChannelMask); for (int channel = 0; channel < channelCount; channel++) { testInputDeviceCombo(id, deviceType, channelCount, nativeChannelMask, - channel); + channel, 48000); } } } @@ -661,19 +699,20 @@ void testOutputDeviceCombo(int deviceId, int channelCount, int channelMask, int outputChannel, + int outputSampleRate, boolean mmapEnabled) throws InterruptedException { String typeString = AudioDeviceInfoConverter.typeToString(deviceType); if (channelMask != 0) { setTestName("Test OutDev: #" + deviceId + " " + typeString - + " Mask:" + channelMask + "_" + outputChannel + "/" + channelCount); + + " Mask:" + channelMask + "_" + outputChannel + "/" + channelCount + "_" + outputSampleRate); } else { setTestName("Test InDev: #" + deviceId + " " + typeString - + "_" + outputChannel + "/" + channelCount); + + "_" + outputChannel + "/" + channelCount + "_" + outputSampleRate); } final int numInputChannels = 2; // TODO review, done because of mono problems on some devices - setupDeviceCombo(numInputChannels, 0, 0, channelCount, channelMask, - outputChannel); + setupDeviceCombo(numInputChannels, 0, 0, 48000, + channelCount, channelMask, outputChannel, outputSampleRate); StreamConfiguration requestedOutConfig = mAudioOutTester.requestedConfiguration; requestedOutConfig.setDeviceId(deviceId); @@ -703,13 +742,14 @@ void testOutputDeviceCombo(int deviceId, int deviceType, int channelCount, int channelMask, - int outputChannel) throws InterruptedException { + int outputChannel, + int outputSampleRate) throws InterruptedException { if (NativeEngine.isMMapSupported()) { testOutputDeviceCombo(deviceId, deviceType, channelCount, channelMask, outputChannel, - true); + outputSampleRate, true); } - testOutputDeviceCombo(deviceId, deviceType, channelCount, channelMask, outputChannel - , false); + testOutputDeviceCombo(deviceId, deviceType, channelCount, channelMask, outputChannel, + outputSampleRate, false); } void logBoth(String text) { @@ -738,21 +778,29 @@ void testOutputDevices() throws InterruptedException { int[] channelCounts = deviceInfo.getChannelCounts(); numTested++; // Always test mono and stereo. - testOutputDeviceCombo(id, deviceType, 1, 0, 0); - testOutputDeviceCombo(id, deviceType, 2, 0, 0); - testOutputDeviceCombo(id, deviceType, 2, 0, 1); + testOutputDeviceCombo(id, deviceType, 1, 0, 0, 48000); + testOutputDeviceCombo(id, deviceType, 2, 0, 0, 48000); + testOutputDeviceCombo(id, deviceType, 2, 0, 1, 48000); if (channelCounts.length > 0) { for (int numChannels : channelCounts) { // Test higher channel counts. if (numChannels > 2) { log("numChannels = " + numChannels + "\n"); for (int channel = 0; channel < numChannels; channel++) { - testOutputDeviceCombo(id, deviceType, numChannels, 0, channel); + testOutputDeviceCombo(id, deviceType, numChannels, 0, channel, + 48000); } } } } + runOnUiThread(() -> mCheckBoxAllSampleRates.setEnabled(false)); + if (mCheckBoxAllSampleRates.isChecked()) { + for (int sampleRate : SAMPLE_RATES) { + testOutputDeviceCombo(id, deviceType, 1, 0, 0, sampleRate); + } + } + if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.S_V2 && deviceType == AudioDeviceInfo.TYPE_BUILTIN_SPEAKER) { runOnUiThread(() -> mCheckBoxAllOutputChannelMasks.setEnabled(false)); @@ -762,7 +810,8 @@ void testOutputDevices() throws InterruptedException { log("channelMask = " + convertChannelMaskToText(channelMask) + "\n"); int channelCount = Integer.bitCount(channelMask); for (int channel = 0; channel < channelCount; channel++) { - testOutputDeviceCombo(id, deviceType, channelCount, channelMask, channel); + testOutputDeviceCombo(id, deviceType, channelCount, channelMask, + channel, 48000); } } } @@ -814,6 +863,7 @@ public void runTest() { mCheckBoxInputDevices.setEnabled(true); mCheckBoxOutputDevices.setEnabled(true); mCheckBoxAllOutputChannelMasks.setEnabled(true); + mCheckBoxAllSampleRates.setEnabled(true); keepScreenOn(false); }); } @@ -834,6 +884,9 @@ public void startTestUsingBundle() { boolean shouldUseAllOutputChannelMasks = mBundleFromIntent.getBoolean(KEY_USE_ALL_OUTPUT_CHANNEL_MASKS, VALUE_DEFAULT_USE_ALL_OUTPUT_CHANNEL_MASKS); + boolean shouldUseAllSampleRates = + mBundleFromIntent.getBoolean(KEY_USE_ALL_SAMPLE_RATES, + VALUE_DEFAULT_USE_ALL_SAMPLE_RATES); int singleTestIndex = mBundleFromIntent.getInt(KEY_SINGLE_TEST_INDEX, VALUE_DEFAULT_SINGLE_TEST_INDEX); @@ -842,6 +895,7 @@ public void startTestUsingBundle() { mCheckBoxInputDevices.setChecked(shouldUseInputDevices); mCheckBoxOutputDevices.setChecked(shouldUseOutputDevices); mCheckBoxAllOutputChannelMasks.setChecked(shouldUseAllOutputChannelMasks); + mCheckBoxAllSampleRates.setChecked(shouldUseAllSampleRates); mAutomatedTestRunner.setTestIndexText(singleTestIndex); }); diff --git a/apps/OboeTester/app/src/main/res/layout/activity_data_paths.xml b/apps/OboeTester/app/src/main/res/layout/activity_data_paths.xml index 1803a2fbd..52d8da948 100644 --- a/apps/OboeTester/app/src/main/res/layout/activity_data_paths.xml +++ b/apps/OboeTester/app/src/main/res/layout/activity_data_paths.xml @@ -35,6 +35,12 @@ android:layout_height="wrap_content" android:checked="true" android:text="OutDev" /> + + + + +