From eb794151c6dda199939654834dc11a515a86b5ba Mon Sep 17 00:00:00 2001 From: Mikhail Naganov Date: Tue, 3 Sep 2019 17:16:05 -0700 Subject: [PATCH] Audio: Ensure input stream gets closed on the audio HAL server side As IStream::close only releases internal resources of the stream, deferring actual stream closing to IStream server object destruction, which is delivered to the audio HAL server asynchronously, there is a possibility for a race condition when streams gets opened and closed in a tight loop as in the VTS test. Work around this problem by flushing RPC messages between the client and the server, and inserting a delay before opening a new stream. Bug: 139329877 Test: VtsHalAudioV5_0TargetTest#AudioPrimaryHidlTest.GetMicrophonesTest Change-Id: Id8744f6f21fd3bfa607f489364925eccbab17b5e (cherry picked from commit 26f868bb02a7264912435bde4ea21020577c1593) --- .../vts/functional/4.0/AudioPrimaryHidlHalTest.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp index 022f75e849..2814c63713 100644 --- a/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp +++ b/audio/core/all-versions/vts/functional/4.0/AudioPrimaryHidlHalTest.cpp @@ -117,6 +117,10 @@ TEST_F(AudioPrimaryHidlTest, GetMicrophonesTest) { ASSERT_NE(0U, activeMicrophones.size()); } stream->close(); + // Workaround for b/139329877. Ensures the stream gets closed on the audio hal side. + stream.clear(); + IPCThreadState::self()->flushCommands(); + usleep(1000); if (efGroup) { EventFlag::deleteEventFlag(&efGroup); }