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 b2e28b85e..b3d485b27 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 void onSkipTest(View view) { 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 @@ private void log(String text) { mAutomatedTestRunner.log(text); } + private void flushLog() { + mAutomatedTestRunner.flushLog(); + } + private void appendFailedSummary(String text) { mAutomatedTestRunner.appendFailedSummary(text); } @@ -293,6 +297,7 @@ private void testConfiguration(boolean isInput, + ", Dev = " + actualConfig.getDeviceId() ); log(actualConfigText); + flushLog(); stream = (isInput) ? mAudioInTester.getCurrentAudioStream() @@ -345,6 +350,7 @@ private void testConfiguration(boolean isInput, // 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 @@ private void testConfiguration(boolean isInput, // 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 @@ private void testConfiguration(boolean isInput, } else { log(TEXT_SKIP); } + flushLog(); // Give hardware time to settle between tests. Thread.sleep(1000); mAutomatedTestRunner.incrementTestCount(); @@ -442,20 +450,28 @@ private void testConfiguration(int performanceMode, 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 2f50e3ec8..189074997 100644 --- a/src/common/FilterAudioStream.h +++ b/src/common/FilterAudioStream.h @@ -55,9 +55,13 @@ class FilterAudioStream : public AudioStream, AudioStreamCallback { // 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 5b4a3e4be..1c6b97f9f 100644 --- a/tests/testStreamOpen.cpp +++ b/tests/testStreamOpen.cpp @@ -15,9 +15,11 @@ */ #include + +#include #include -#include +#include #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);