aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Burk <philburk@mobileer.com>2023-08-16 08:57:16 -0700
committerGitHub <noreply@github.com>2023-08-16 08:57:16 -0700
commit127e9ba233e070c3cc82e04cb1c9620cd9586b08 (patch)
tree0768bf9c3bfe1265c42d7b7f59d28a774689189f
parente94d769135fdddfc21d752b353f9d32f8ea79f3f (diff)
downloadoboe-127e9ba233e070c3cc82e04cb1c9620cd9586b08.tar.gz
oboe: copy more parameters in FilterAudioStream (#1898)
sharingMode and the hardware formats were not getting copied. It was noticed in OboeTester. The test specs for TEST DISCONNECT were made more rational. Also a unit test was added to catch the oboe bug. Fixes #1897
-rw-r--r--apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDisconnectActivity.java30
-rw-r--r--src/common/FilterAudioStream.h4
-rw-r--r--tests/testStreamOpen.cpp27
3 files changed, 53 insertions, 8 deletions
diff --git a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDisconnectActivity.java b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDisconnectActivity.java
index b2e28b85..b3d485b2 100644
--- a/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDisconnectActivity.java
+++ b/apps/OboeTester/app/src/main/java/com/mobileer/oboetester/TestDisconnectActivity.java
@@ -199,7 +199,7 @@ public class TestDisconnectActivity extends TestAudioActivity {
private String getConfigText(StreamConfiguration config) {
return ((config.getDirection() == StreamConfiguration.DIRECTION_OUTPUT) ? "OUT" : "IN")
+ ", Perf = " + StreamConfiguration.convertPerformanceModeToText(
- config.getPerformanceMode())
+ config.getPerformanceMode())
+ ", " + StreamConfiguration.convertSharingModeToText(config.getSharingMode())
+ ", " + config.getSampleRate();
}
@@ -213,6 +213,10 @@ public class TestDisconnectActivity extends TestAudioActivity {
mAutomatedTestRunner.log(text);
}
+ private void flushLog() {
+ mAutomatedTestRunner.flushLog();
+ }
+
private void appendFailedSummary(String text) {
mAutomatedTestRunner.appendFailedSummary(text);
}
@@ -293,6 +297,7 @@ public class TestDisconnectActivity extends TestAudioActivity {
+ ", Dev = " + actualConfig.getDeviceId()
);
log(actualConfigText);
+ flushLog();
stream = (isInput)
? mAudioInTester.getCurrentAudioStream()
@@ -345,6 +350,7 @@ public class TestDisconnectActivity extends TestAudioActivity {
// Wait for Java plug count to change or stream to disconnect.
while (!mTestFailed && mAutomatedTestRunner.isThreadEnabled() && !mSkipTest &&
stream.getState() == StreamConfiguration.STREAM_STATE_STARTED) {
+ flushLog();
Thread.sleep(POLL_DURATION_MILLIS);
if (mPlugCount > oldPlugCount) {
timeoutCount = TIME_TO_FAILURE_MILLIS / POLL_DURATION_MILLIS;
@@ -355,6 +361,7 @@ public class TestDisconnectActivity extends TestAudioActivity {
// Wait for timeout or stream to disconnect.
while (!mTestFailed && mAutomatedTestRunner.isThreadEnabled() && !mSkipTest && (timeoutCount > 0) &&
stream.getState() == StreamConfiguration.STREAM_STATE_STARTED) {
+ flushLog();
Thread.sleep(POLL_DURATION_MILLIS);
timeoutCount--;
if (timeoutCount == 0) {
@@ -417,6 +424,7 @@ public class TestDisconnectActivity extends TestAudioActivity {
} else {
log(TEXT_SKIP);
}
+ flushLog();
// Give hardware time to settle between tests.
Thread.sleep(1000);
mAutomatedTestRunner.incrementTestCount();
@@ -442,20 +450,28 @@ public class TestDisconnectActivity extends TestAudioActivity {
testConfiguration(true, performanceMode, sharingMode);
}
+ private void testConfiguration(int performanceMode,
+ int sharingMode, int sampleRate) throws InterruptedException {
+ testConfiguration(false, performanceMode, sharingMode, sampleRate);
+ testConfiguration(true, performanceMode, sharingMode, sampleRate);
+ }
+
@Override
public void runTest() {
mPlugCount = 0;
// Try several different configurations.
try {
- testConfiguration(false, StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY,
- StreamConfiguration.SHARING_MODE_EXCLUSIVE, 44100);
- testConfiguration(StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY,
- StreamConfiguration.SHARING_MODE_EXCLUSIVE);
- testConfiguration(StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY,
- StreamConfiguration.SHARING_MODE_SHARED);
testConfiguration(StreamConfiguration.PERFORMANCE_MODE_NONE,
StreamConfiguration.SHARING_MODE_SHARED);
+ if (NativeEngine.isMMapExclusiveSupported()){
+ testConfiguration(StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY,
+ StreamConfiguration.SHARING_MODE_EXCLUSIVE);
+ }
+ testConfiguration(StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY,
+ StreamConfiguration.SHARING_MODE_SHARED);
+ testConfiguration(StreamConfiguration.PERFORMANCE_MODE_LOW_LATENCY,
+ StreamConfiguration.SHARING_MODE_SHARED, 44100);
} catch (InterruptedException e) {
log("Test CANCELLED - INVALID!");
} catch (Exception e) {
diff --git a/src/common/FilterAudioStream.h b/src/common/FilterAudioStream.h
index 2f50e3ec..18907499 100644
--- a/src/common/FilterAudioStream.h
+++ b/src/common/FilterAudioStream.h
@@ -55,9 +55,13 @@ public:
// Copy parameters that may not match builder.
mBufferCapacityInFrames = mChildStream->getBufferCapacityInFrames();
mPerformanceMode = mChildStream->getPerformanceMode();
+ mSharingMode = mChildStream->getSharingMode();
mInputPreset = mChildStream->getInputPreset();
mFramesPerBurst = mChildStream->getFramesPerBurst();
mDeviceId = mChildStream->getDeviceId();
+ mHardwareSampleRate = mChildStream->getHardwareSampleRate();
+ mHardwareChannelCount = mChildStream->getHardwareChannelCount();
+ mHardwareFormat = mChildStream->getHardwareFormat();
}
virtual ~FilterAudioStream() = default;
diff --git a/tests/testStreamOpen.cpp b/tests/testStreamOpen.cpp
index 5b4a3e4b..1c6b97f9 100644
--- a/tests/testStreamOpen.cpp
+++ b/tests/testStreamOpen.cpp
@@ -15,9 +15,11 @@
*/
#include <gtest/gtest.h>
+
+#include <aaudio/AAudioExtensions.h>
#include <oboe/Oboe.h>
-#include <android/api-level.h>
+#include <android/api-level.h>
#ifndef __ANDROID_API_S__
#define __ANDROID_API_S__ 31
#endif
@@ -389,6 +391,29 @@ TEST_F(StreamOpenOutput, LowLatencyStreamHasSmallBufferSize){
}
}
+// Make sure the parameters get copied from the child stream.
+TEST_F(StreamOpenOutput, AAudioOutputSampleRate44100FilterConfiguration) {
+ if (mBuilder.isAAudioRecommended()) {
+ mBuilder.setDirection(Direction::Output);
+ mBuilder.setPerformanceMode(PerformanceMode::LowLatency);
+ mBuilder.setSharingMode(SharingMode::Exclusive);
+ // Try to force the use of a FilterAudioStream by requesting conversion.
+ mBuilder.setSampleRate(44100);
+ mBuilder.setSampleRateConversionQuality(SampleRateConversionQuality::Medium);
+ ASSERT_TRUE(openStream());
+ if (getSdkVersion() >= __ANDROID_API_U__) {
+ ASSERT_LT(0, mStream->getHardwareSampleRate());
+ ASSERT_LT(0, mStream->getHardwareChannelCount());
+ ASSERT_LT(0, (int)mStream->getHardwareFormat());
+ }
+ // If MMAP is not supported then we cannot get an EXCLUSIVE mode stream.
+ if (!AAudioExtensions::getInstance().isMMapSupported()) {
+ ASSERT_NE(SharingMode::Exclusive, mStream->getSharingMode()); // IMPOSSIBLE
+ }
+ ASSERT_TRUE(closeStream());
+ }
+}
+
// See if sample rate conversion by Oboe is calling the callback.
TEST_F(StreamOpenOutput, AAudioOutputSampleRate44100) {
checkSampleRateConversionAdvancing(Direction::Output);