aaudio: teardown stream based on a port handle
Needed for silencing specific input streams.
Pass AAudioService reference into AAudioServiceEndpointMMAP.
Use it to find a specific stream by PortHandle then
stop it and disconnect it.
Bug: 72134552
Test: b/72134552#comment10
Change-Id: Ibdf242f834c83b47c967c3cc634ed1083b019d4a
diff --git a/services/oboeservice/AAudioServiceEndpoint.cpp b/services/oboeservice/AAudioServiceEndpoint.cpp
index 96e621a..0349034 100644
--- a/services/oboeservice/AAudioServiceEndpoint.cpp
+++ b/services/oboeservice/AAudioServiceEndpoint.cpp
@@ -78,6 +78,17 @@
return result.str();
}
+// @return true if stream found
+bool AAudioServiceEndpoint::isStreamRegistered(audio_port_handle_t portHandle) {
+ std::lock_guard<std::mutex> lock(mLockStreams);
+ for (const auto stream : mRegisteredStreams) {
+ if (stream->getPortHandle() == portHandle) {
+ return true;
+ }
+ }
+ return false;
+}
+
void AAudioServiceEndpoint::disconnectRegisteredStreams() {
std::lock_guard<std::mutex> lock(mLockStreams);
mConnected.store(false);