From da47b49df4d73101416bc31a38bbe742c9e81cfc Mon Sep 17 00:00:00 2001 From: Robert Wu <85952307+robertwu1@users.noreply.github.com> Date: Tue, 1 Mar 2022 10:45:31 -0800 Subject: [PATCH 1/6] add testStreamStopWrite tests --- src/aaudio/AudioStreamAAudio.cpp | 2 + tests/CMakeLists.txt | 1 + tests/testStreamStopWrite.cpp | 115 +++++++++++++++++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 tests/testStreamStopWrite.cpp diff --git a/src/aaudio/AudioStreamAAudio.cpp b/src/aaudio/AudioStreamAAudio.cpp index 5ce0dc4a8..8e61d7dae 100644 --- a/src/aaudio/AudioStreamAAudio.cpp +++ b/src/aaudio/AudioStreamAAudio.cpp @@ -472,6 +472,7 @@ Result AudioStreamAAudio::requestStop_l(AAudioStream *stream) { ResultWithValue AudioStreamAAudio::write(const void *buffer, int32_t numFrames, int64_t timeoutNanoseconds) { + std::shared_lock lock(mAAudioStreamLock); AAudioStream *stream = mAAudioStream.load(); if (stream != nullptr) { int32_t result = mLibLoader->stream_write(mAAudioStream, buffer, @@ -485,6 +486,7 @@ ResultWithValue AudioStreamAAudio::write(const void *buffer, ResultWithValue AudioStreamAAudio::read(void *buffer, int32_t numFrames, int64_t timeoutNanoseconds) { + std::shared_lock lock(mAAudioStreamLock); AAudioStream *stream = mAAudioStream.load(); if (stream != nullptr) { int32_t result = mLibLoader->stream_read(mAAudioStream, buffer, diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f73db44e9..ffda081e5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -36,6 +36,7 @@ add_executable( testStreamStates.cpp testStreamFramesProcessed.cpp testReturnStop.cpp + testStreamStopWrite.cpp ) target_link_libraries(testOboe gtest oboe) diff --git a/tests/testStreamStopWrite.cpp b/tests/testStreamStopWrite.cpp new file mode 100644 index 000000000..ef8a4d370 --- /dev/null +++ b/tests/testStreamStopWrite.cpp @@ -0,0 +1,115 @@ +/* + * Copyright 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include + +#include + +using namespace oboe; + +class TestStreamStopWrite : public ::testing::Test { + +protected: + + void SetUp(){ + mBuilder.setPerformanceMode(PerformanceMode::None); + mBuilder.setDirection(Direction::Output); + } + + bool openStream(Direction direction, PerformanceMode perfMode) { + mBuilder.setDirection(direction); + mBuilder.setPerformanceMode(perfMode); + Result r = mBuilder.openStream(&mStream); + EXPECT_EQ(r, Result::OK) << "Failed to open stream " << convertToText(r); + if (r != Result::OK) + return false; + + Direction d = mStream->getDirection(); + EXPECT_EQ(d, direction) << convertToText(mStream->getDirection()); + return (d == direction); + } + + bool openStream(AudioStreamBuilder &builder) { + Result r = builder.openStream(&mStream); + EXPECT_EQ(r, Result::OK) << "Failed to open stream " << convertToText(r); + return (r == Result::OK); + } + + bool closeStream() { + Result r = mStream->close(); + EXPECT_TRUE(r == Result::OK || r == Result::ErrorClosed) << + "Failed to close stream. " << convertToText(r); + return (r == Result::OK || r == Result::ErrorClosed); + } + + void stopWhileWritingLargeBuffer() { + StreamState next = StreamState::Unknown; + auto r = mStream->requestStart(); + EXPECT_EQ(r, Result::OK); + r = mStream->waitForStateChange(StreamState::Starting, &next, kTimeoutInNanos); + EXPECT_EQ(r, Result::OK); + EXPECT_EQ(next, StreamState::Started) << "next = " << convertToText(next); + + AudioStream *str = mStream; + std::thread stopper([str] { + usleep(2 * 1000); + str->requestStop(); + }); + + int16_t buffer[100000] = {}; + r = mStream->write(&buffer, 100000, kTimeoutInNanos); + if (r != Result::OK) { + FAIL() << "Could not write to audio stream"; + } + + r = mStream->waitForStateChange(StreamState::Started, &next, + 1000 * kNanosPerMillisecond); + stopper.join(); + EXPECT_EQ(r, Result::OK); + // May have caught in stopping transition. Wait for full stop. + if (next == StreamState::Stopping) { + r = mStream->waitForStateChange(StreamState::Stopping, &next, + 1000 * kNanosPerMillisecond); + EXPECT_EQ(r, Result::OK); + } + ASSERT_EQ(next, StreamState::Stopped) << "next = " << convertToText(next); + } + + AudioStreamBuilder mBuilder; + AudioStream *mStream = nullptr; + static constexpr int kTimeoutInNanos = 1000 * kNanosPerMillisecond; + +}; + +TEST_F(TestStreamStopWrite, OutputLowLatency) { + ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::LowLatency)); + stopWhileWritingLargeBuffer(); + ASSERT_TRUE(closeStream()); +} + +TEST_F(TestStreamStopWrite, OutputNone) { + ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::None)); + stopWhileWritingLargeBuffer(); + ASSERT_TRUE(closeStream()); +} + +TEST_F(TestStreamStopWrite, OutputPowerSavings) { + ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::PowerSaving)); + stopWhileWritingLargeBuffer(); + ASSERT_TRUE(closeStream()); +} \ No newline at end of file From 7d24b59dbf4758e31056915fd2b5505b8a3382a9 Mon Sep 17 00:00:00 2001 From: Robert Wu <85952307+robertwu1@users.noreply.github.com> Date: Wed, 2 Mar 2022 16:40:33 -0800 Subject: [PATCH 2/6] add aaudio stream locks around read and write --- tests/CMakeLists.txt | 2 +- tests/UnitTestRunner/app/build.gradle | 7 +- .../app/src/main/AndroidManifest.xml | 2 +- .../tests/unittestrunner/MainActivity.java | 4 ++ tests/UnitTestRunner/build.gradle | 22 ++++--- .../gradle/wrapper/gradle-wrapper.properties | 2 +- tests/testStreamOpen.cpp | 4 ++ ...StreamStopWrite.cpp => testStreamStop.cpp} | 64 +++++++++++-------- 8 files changed, 68 insertions(+), 39 deletions(-) rename tests/{testStreamStopWrite.cpp => testStreamStop.cpp} (66%) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ffda081e5..ccf23bc08 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -36,7 +36,7 @@ add_executable( testStreamStates.cpp testStreamFramesProcessed.cpp testReturnStop.cpp - testStreamStopWrite.cpp + testStreamStop.cpp ) target_link_libraries(testOboe gtest oboe) diff --git a/tests/UnitTestRunner/app/build.gradle b/tests/UnitTestRunner/app/build.gradle index e44a5ecde..842d54652 100644 --- a/tests/UnitTestRunner/app/build.gradle +++ b/tests/UnitTestRunner/app/build.gradle @@ -15,10 +15,15 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } + externalNativeBuild { + cmake { + path file('../../CMakeLists.txt') + } + } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'androidx.appcompat:appcompat:1.0.0-rc02' + implementation 'androidx.appcompat:appcompat:1.1.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' } diff --git a/tests/UnitTestRunner/app/src/main/AndroidManifest.xml b/tests/UnitTestRunner/app/src/main/AndroidManifest.xml index 252be005d..c9d19a74e 100644 --- a/tests/UnitTestRunner/app/src/main/AndroidManifest.xml +++ b/tests/UnitTestRunner/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:roundIcon="@mipmap/ic_launcher_round" android:supportsRtl="true" android:theme="@style/AppTheme"> - + diff --git a/tests/UnitTestRunner/app/src/main/java/com/google/oboe/tests/unittestrunner/MainActivity.java b/tests/UnitTestRunner/app/src/main/java/com/google/oboe/tests/unittestrunner/MainActivity.java index fee482998..ac695735e 100644 --- a/tests/UnitTestRunner/app/src/main/java/com/google/oboe/tests/unittestrunner/MainActivity.java +++ b/tests/UnitTestRunner/app/src/main/java/com/google/oboe/tests/unittestrunner/MainActivity.java @@ -60,6 +60,10 @@ private String executeBinary() { StringBuffer output = new StringBuffer(); String abi = Build.CPU_ABI; + String extraStringForDebugBuilds = "-hwasan"; + if (abi.endsWith(extraStringForDebugBuilds)) { + abi = abi.substring(0, abi.length() - extraStringForDebugBuilds.length()); + } String filesDir = getFilesDir().getPath(); String testBinaryPath = abi + "/" + TEST_BINARY_FILEANAME; diff --git a/tests/UnitTestRunner/build.gradle b/tests/UnitTestRunner/build.gradle index 7a70682e6..11309e787 100644 --- a/tests/UnitTestRunner/build.gradle +++ b/tests/UnitTestRunner/build.gradle @@ -1,24 +1,26 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { - repositories { - google() - jcenter() + mavenCentral() + maven { + url 'https://maven.google.com/' + name 'Google' + } } - dependencies { - classpath 'com.android.tools.build:gradle:4.2.0' - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files + dependencies { + classpath 'com.android.tools.build:gradle:7.1.1' } } allprojects { repositories { - google() - jcenter() + mavenCentral() + maven { + url 'https://maven.google.com/' + name 'Google' + } } } diff --git a/tests/UnitTestRunner/gradle/wrapper/gradle-wrapper.properties b/tests/UnitTestRunner/gradle/wrapper/gradle-wrapper.properties index 8cccbca0f..1f10e877d 100644 --- a/tests/UnitTestRunner/gradle/wrapper/gradle-wrapper.properties +++ b/tests/UnitTestRunner/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-all.zip diff --git a/tests/testStreamOpen.cpp b/tests/testStreamOpen.cpp index 863595b46..03b8e903e 100644 --- a/tests/testStreamOpen.cpp +++ b/tests/testStreamOpen.cpp @@ -18,6 +18,10 @@ #include #include +#ifndef __ANDROID_API_S__ +#define __ANDROID_API_S__ 31 +#endif + using namespace oboe; class CallbackSizeMonitor : public AudioStreamCallback { diff --git a/tests/testStreamStopWrite.cpp b/tests/testStreamStop.cpp similarity index 66% rename from tests/testStreamStopWrite.cpp rename to tests/testStreamStop.cpp index ef8a4d370..03d46c029 100644 --- a/tests/testStreamStopWrite.cpp +++ b/tests/testStreamStop.cpp @@ -22,7 +22,7 @@ using namespace oboe; -class TestStreamStopWrite : public ::testing::Test { +class TestStreamStop : public ::testing::Test { protected: @@ -57,7 +57,7 @@ class TestStreamStopWrite : public ::testing::Test { return (r == Result::OK || r == Result::ErrorClosed); } - void stopWhileWritingLargeBuffer() { + void stopWhileUsingLargeBuffer(bool shouldWrite) { StreamState next = StreamState::Unknown; auto r = mStream->requestStart(); EXPECT_EQ(r, Result::OK); @@ -66,50 +66,64 @@ class TestStreamStopWrite : public ::testing::Test { EXPECT_EQ(next, StreamState::Started) << "next = " << convertToText(next); AudioStream *str = mStream; + + int16_t buffer[kFramesToWrite * 4] = {}; + std::thread stopper([str] { - usleep(2 * 1000); - str->requestStop(); + usleep(3 * 1000); // 3 ms + str->close(); }); - int16_t buffer[100000] = {}; - r = mStream->write(&buffer, 100000, kTimeoutInNanos); + if (shouldWrite) { + r = mStream->write(&buffer, kFramesToWrite, kTimeoutInNanos); + } else { + r = mStream->read(&buffer, kFramesToWrite, kTimeoutInNanos); + } if (r != Result::OK) { - FAIL() << "Could not write to audio stream"; + FAIL() << "Could not write to audio stream: " << static_cast(r); } + stopper.join(); r = mStream->waitForStateChange(StreamState::Started, &next, 1000 * kNanosPerMillisecond); - stopper.join(); - EXPECT_EQ(r, Result::OK); - // May have caught in stopping transition. Wait for full stop. - if (next == StreamState::Stopping) { - r = mStream->waitForStateChange(StreamState::Stopping, &next, - 1000 * kNanosPerMillisecond); - EXPECT_EQ(r, Result::OK); + if ((r != Result::ErrorClosed) && (r != Result::OK)) { + FAIL() << "Wrong closed result type: " << static_cast(r); } - ASSERT_EQ(next, StreamState::Stopped) << "next = " << convertToText(next); } AudioStreamBuilder mBuilder; AudioStream *mStream = nullptr; static constexpr int kTimeoutInNanos = 1000 * kNanosPerMillisecond; + static constexpr int kFramesToWrite = 10000; }; -TEST_F(TestStreamStopWrite, OutputLowLatency) { +TEST_F(TestStreamStop, OutputLowLatency) { ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::LowLatency)); - stopWhileWritingLargeBuffer(); - ASSERT_TRUE(closeStream()); + stopWhileUsingLargeBuffer(true /* write */); +} + +TEST_F(TestStreamStop, OutputPowerSavings) { + ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::PowerSaving)); + stopWhileUsingLargeBuffer(true /* write */); } -TEST_F(TestStreamStopWrite, OutputNone) { +TEST_F(TestStreamStop, OutputNone) { ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::None)); - stopWhileWritingLargeBuffer(); - ASSERT_TRUE(closeStream()); + stopWhileUsingLargeBuffer(true /* write */); } -TEST_F(TestStreamStopWrite, OutputPowerSavings) { - ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::PowerSaving)); - stopWhileWritingLargeBuffer(); - ASSERT_TRUE(closeStream()); +TEST_F(TestStreamStop, InputLowLatency) { + ASSERT_TRUE(openStream(Direction::Input, PerformanceMode::LowLatency)); + stopWhileUsingLargeBuffer(false /* read */); +} + +TEST_F(TestStreamStop, InputPowerSavings) { + ASSERT_TRUE(openStream(Direction::Input, PerformanceMode::PowerSaving)); + stopWhileUsingLargeBuffer(false /* read */); +} + +TEST_F(TestStreamStop, InputNone) { + ASSERT_TRUE(openStream(Direction::Input, PerformanceMode::None)); + stopWhileUsingLargeBuffer(false /* read */); } \ No newline at end of file From c9353c3e1a872706d04c12ac78036762a0fa1ebf Mon Sep 17 00:00:00 2001 From: Robert Wu <85952307+robertwu1@users.noreply.github.com> Date: Wed, 2 Mar 2022 17:01:29 -0800 Subject: [PATCH 3/6] test opensl es as well --- tests/testStreamStop.cpp | 65 +++++++++++++++++++--------------------- 1 file changed, 30 insertions(+), 35 deletions(-) diff --git a/tests/testStreamStop.cpp b/tests/testStreamStop.cpp index 03d46c029..c5f28db1e 100644 --- a/tests/testStreamStop.cpp +++ b/tests/testStreamStop.cpp @@ -22,7 +22,10 @@ using namespace oboe; -class TestStreamStop : public ::testing::Test { +using TestStreamStopParams = std::tuple; + +class TestStreamStop : public ::testing::Test, + public ::testing::WithParamInterface { protected: @@ -31,8 +34,9 @@ class TestStreamStop : public ::testing::Test { mBuilder.setDirection(Direction::Output); } - bool openStream(Direction direction, PerformanceMode perfMode) { + bool openStream(Direction direction, AudioApi audioApi, PerformanceMode perfMode) { mBuilder.setDirection(direction); + mBuilder.setAudioApi(audioApi); mBuilder.setPerformanceMode(perfMode); Result r = mBuilder.openStream(&mStream); EXPECT_EQ(r, Result::OK) << "Failed to open stream " << convertToText(r); @@ -50,13 +54,6 @@ class TestStreamStop : public ::testing::Test { return (r == Result::OK); } - bool closeStream() { - Result r = mStream->close(); - EXPECT_TRUE(r == Result::OK || r == Result::ErrorClosed) << - "Failed to close stream. " << convertToText(r); - return (r == Result::OK || r == Result::ErrorClosed); - } - void stopWhileUsingLargeBuffer(bool shouldWrite) { StreamState next = StreamState::Unknown; auto r = mStream->requestStart(); @@ -98,32 +95,30 @@ class TestStreamStop : public ::testing::Test { }; -TEST_F(TestStreamStop, OutputLowLatency) { - ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::LowLatency)); - stopWhileUsingLargeBuffer(true /* write */); -} - -TEST_F(TestStreamStop, OutputPowerSavings) { - ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::PowerSaving)); - stopWhileUsingLargeBuffer(true /* write */); -} - -TEST_F(TestStreamStop, OutputNone) { - ASSERT_TRUE(openStream(Direction::Output, PerformanceMode::None)); - stopWhileUsingLargeBuffer(true /* write */); -} - -TEST_F(TestStreamStop, InputLowLatency) { - ASSERT_TRUE(openStream(Direction::Input, PerformanceMode::LowLatency)); - stopWhileUsingLargeBuffer(false /* read */); -} +TEST_P(TestStreamStop, VerifyTestStreamStop) { + const Direction direction = std::get<0>(GetParam()); + const AudioApi audioApi = std::get<1>(GetParam()); + const PerformanceMode performanceMode = std::get<2>(GetParam()); -TEST_F(TestStreamStop, InputPowerSavings) { - ASSERT_TRUE(openStream(Direction::Input, PerformanceMode::PowerSaving)); - stopWhileUsingLargeBuffer(false /* read */); + ASSERT_TRUE(openStream(direction, audioApi, performanceMode)); + stopWhileUsingLargeBuffer(direction == Direction::Output); } -TEST_F(TestStreamStop, InputNone) { - ASSERT_TRUE(openStream(Direction::Input, PerformanceMode::None)); - stopWhileUsingLargeBuffer(false /* read */); -} \ No newline at end of file +INSTANTIATE_TEST_SUITE_P( + TestStreamStopTest, + TestStreamStop, + ::testing::Values( + TestStreamStopParams({Direction::Output, AudioApi::AAudio, PerformanceMode::LowLatency}), + TestStreamStopParams({Direction::Output, AudioApi::AAudio, PerformanceMode::None}), + TestStreamStopParams({Direction::Output, AudioApi::AAudio, PerformanceMode::PowerSaving}), + TestStreamStopParams({Direction::Output, AudioApi::OpenSLES, PerformanceMode::LowLatency}), + TestStreamStopParams({Direction::Output, AudioApi::OpenSLES, PerformanceMode::None}), + TestStreamStopParams({Direction::Output, AudioApi::OpenSLES, PerformanceMode::PowerSaving}), + TestStreamStopParams({Direction::Input, AudioApi::AAudio, PerformanceMode::LowLatency}), + TestStreamStopParams({Direction::Input, AudioApi::AAudio, PerformanceMode::None}), + TestStreamStopParams({Direction::Input, AudioApi::AAudio, PerformanceMode::PowerSaving}), + TestStreamStopParams({Direction::Input, AudioApi::OpenSLES, PerformanceMode::LowLatency}), + TestStreamStopParams({Direction::Input, AudioApi::OpenSLES, PerformanceMode::None}), + TestStreamStopParams({Direction::Input, AudioApi::OpenSLES, PerformanceMode::PowerSaving}) + ) +); \ No newline at end of file From 3b7659a7725b3a6092c4afd086161c97e2e851c8 Mon Sep 17 00:00:00 2001 From: Robert Wu <85952307+robertwu1@users.noreply.github.com> Date: Thu, 3 Mar 2022 11:54:44 -0800 Subject: [PATCH 4/6] address Phil'c comments --- tests/testStreamStop.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/tests/testStreamStop.cpp b/tests/testStreamStop.cpp index c5f28db1e..1a3ff8d1f 100644 --- a/tests/testStreamStop.cpp +++ b/tests/testStreamStop.cpp @@ -38,6 +38,8 @@ class TestStreamStop : public ::testing::Test, mBuilder.setDirection(direction); mBuilder.setAudioApi(audioApi); mBuilder.setPerformanceMode(perfMode); + mBuilder.setChannelCount(1); + mBuilder.setFormat(AudioFormat::I16); Result r = mBuilder.openStream(&mStream); EXPECT_EQ(r, Result::OK) << "Failed to open stream " << convertToText(r); if (r != Result::OK) @@ -64,20 +66,21 @@ class TestStreamStop : public ::testing::Test, AudioStream *str = mStream; - int16_t buffer[kFramesToWrite * 4] = {}; + int16_t buffer[kFramesToWrite] = {}; std::thread stopper([str] { - usleep(3 * 1000); // 3 ms + int64_t estimatedCompletionTimeUs = kSecondsPerMicroSecond * kFramesToWrite / str->getSampleRate(); + usleep(estimatedCompletionTimeUs / 2); // Stop halfway during the read/write str->close(); }); - if (shouldWrite) { + if (mBuilder.getDirection() == Direction::Output) { r = mStream->write(&buffer, kFramesToWrite, kTimeoutInNanos); } else { r = mStream->read(&buffer, kFramesToWrite, kTimeoutInNanos); } if (r != Result::OK) { - FAIL() << "Could not write to audio stream: " << static_cast(r); + FAIL() << "Could not read/write to audio stream: " << static_cast(r); } stopper.join(); @@ -91,6 +94,7 @@ class TestStreamStop : public ::testing::Test, AudioStreamBuilder mBuilder; AudioStream *mStream = nullptr; static constexpr int kTimeoutInNanos = 1000 * kNanosPerMillisecond; + static constexpr int64_t kSecondsPerMicroSecond = 1000000; static constexpr int kFramesToWrite = 10000; }; @@ -121,4 +125,4 @@ INSTANTIATE_TEST_SUITE_P( TestStreamStopParams({Direction::Input, AudioApi::OpenSLES, PerformanceMode::None}), TestStreamStopParams({Direction::Input, AudioApi::OpenSLES, PerformanceMode::PowerSaving}) ) -); \ No newline at end of file +); From 7cc5af60885830c46ec770d0253473a98c9edc23 Mon Sep 17 00:00:00 2001 From: Robert Wu <85952307+robertwu1@users.noreply.github.com> Date: Thu, 3 Mar 2022 11:57:13 -0800 Subject: [PATCH 5/6] remove extra input --- tests/testStreamStop.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testStreamStop.cpp b/tests/testStreamStop.cpp index 1a3ff8d1f..4a8e4dec8 100644 --- a/tests/testStreamStop.cpp +++ b/tests/testStreamStop.cpp @@ -56,7 +56,7 @@ class TestStreamStop : public ::testing::Test, return (r == Result::OK); } - void stopWhileUsingLargeBuffer(bool shouldWrite) { + void stopWhileUsingLargeBuffer() { StreamState next = StreamState::Unknown; auto r = mStream->requestStart(); EXPECT_EQ(r, Result::OK); @@ -105,7 +105,7 @@ TEST_P(TestStreamStop, VerifyTestStreamStop) { const PerformanceMode performanceMode = std::get<2>(GetParam()); ASSERT_TRUE(openStream(direction, audioApi, performanceMode)); - stopWhileUsingLargeBuffer(direction == Direction::Output); + stopWhileUsingLargeBuffer(); } INSTANTIATE_TEST_SUITE_P( From 5a896628b6574794d9299fd1397ae48bb4edb85f Mon Sep 17 00:00:00 2001 From: Robert Wu <85952307+robertwu1@users.noreply.github.com> Date: Thu, 17 Mar 2022 09:16:41 -0700 Subject: [PATCH 6/6] microsec to second --- tests/testStreamStop.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testStreamStop.cpp b/tests/testStreamStop.cpp index 4a8e4dec8..54fb4464d 100644 --- a/tests/testStreamStop.cpp +++ b/tests/testStreamStop.cpp @@ -69,7 +69,7 @@ class TestStreamStop : public ::testing::Test, int16_t buffer[kFramesToWrite] = {}; std::thread stopper([str] { - int64_t estimatedCompletionTimeUs = kSecondsPerMicroSecond * kFramesToWrite / str->getSampleRate(); + int64_t estimatedCompletionTimeUs = kMicroSecondsPerSecond * kFramesToWrite / str->getSampleRate(); usleep(estimatedCompletionTimeUs / 2); // Stop halfway during the read/write str->close(); }); @@ -94,7 +94,7 @@ class TestStreamStop : public ::testing::Test, AudioStreamBuilder mBuilder; AudioStream *mStream = nullptr; static constexpr int kTimeoutInNanos = 1000 * kNanosPerMillisecond; - static constexpr int64_t kSecondsPerMicroSecond = 1000000; + static constexpr int64_t kMicroSecondsPerSecond = 1000000; static constexpr int kFramesToWrite = 10000; };