aboutsummaryrefslogtreecommitdiff
path: root/tests/src/pcm_loopback_test.cc
diff options
context:
space:
mode:
authordvdli <dvdli@google.com>2021-06-02 22:05:01 +0800
committerdvdli <dvdli@google.com>2021-06-02 23:11:36 +0800
commitea4546b237269915e832fd74a9883a2dadf46093 (patch)
tree7cf42df6c5c17b207be376eb00fe91d42bd9e352 /tests/src/pcm_loopback_test.cc
parent36f9078ef5410279725207daa00943ee48b05253 (diff)
force pcm_open to open device with the non-blocking flag
When a client opens a PCM device whose substreams are all occupied without the non-blocking flag, the open function would be blocked in the kernel until the previous opened ones are closed. This would cause deadlock if they try to hold the same lock. Most of the ALSA PCM drivers on embedded systems are implemented with the ALSA SOC framework. Each PCM device has only one substream. This problem would happen frequently. To force pcm_open to open PCM devices with non-blocking flag is beneficial to resolve this problem. It returns the control to clients to try again later. The reason why we don't call pcm_open with PCM_NONBLOCK is that the PCM_NONBLOCK also affects the read and write behaviors. I also add a test case to test whether the pcm_open would be blocked.
Diffstat (limited to 'tests/src/pcm_loopback_test.cc')
-rw-r--r--tests/src/pcm_loopback_test.cc8
1 files changed, 0 insertions, 8 deletions
diff --git a/tests/src/pcm_loopback_test.cc b/tests/src/pcm_loopback_test.cc
index d48b319..3da3231 100644
--- a/tests/src/pcm_loopback_test.cc
+++ b/tests/src/pcm_loopback_test.cc
@@ -193,10 +193,6 @@ class PcmLoopbackTest : public ::testing::Test {
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
- static constexpr unsigned int kDefaultChannels = 2;
- static constexpr unsigned int kDefaultSamplingRate = 48000;
- static constexpr unsigned int kDefaultPeriodSize = 1024;
- static constexpr unsigned int kDefaultPeriodCount = 3;
static constexpr unsigned int kDefaultPeriodTimeInMs =
kDefaultPeriodSize * 1000 / kDefaultSamplingRate;
static constexpr pcm_format kPcmForamt = F::kFormat;
@@ -212,10 +208,6 @@ using Formats = ::testing::Types<S16bitlePcmFormat, FloatPcmFormat>;
TYPED_TEST_SUITE(PcmLoopbackTest, Formats);
TYPED_TEST(PcmLoopbackTest, Loopback) {
- static constexpr unsigned int kDefaultChannels = this->kDefaultChannels;
- static constexpr unsigned int kDefaultSamplingRate = this->kDefaultSamplingRate;
- static constexpr unsigned int kDefaultPeriodSize = this->kDefaultPeriodSize;
- // static constexpr unsigned int kDefaultPeriodCount = this->kDefaultPeriodCount;
static constexpr unsigned int kDefaultPeriodTimeInMs = this->kDefaultPeriodTimeInMs;
static constexpr pcm_format kPcmForamt = this->kPcmForamt;
pcm *pcm_in = this->pcm_in;