libaudiohal@aidl: Handle postponed streams closing
Since APM disconnects external devices independently
of AF closing HAL streams, a situation can occur when
APM is trying to disconnect a device port for which
streams still exist. To accommodate this case, allow
postponing of external device disconnection until
the corresponding stream was closed.
Bug: 298175108
Test: atest audiosystem_tests
Change-Id: Ia786822b9b57e4140f75b88b802399975e42b93c
diff --git a/media/libaudiohal/impl/DeviceHalAidl.h b/media/libaudiohal/impl/DeviceHalAidl.h
index 2e393c7..329adba 100644
--- a/media/libaudiohal/impl/DeviceHalAidl.h
+++ b/media/libaudiohal/impl/DeviceHalAidl.h
@@ -257,6 +257,7 @@
const ::aidl::android::media::audio::common::AudioConfig& config,
const std::optional<::aidl::android::media::audio::common::AudioIoFlags>& flags,
int32_t ioHandle);
+ bool isPortHeldByAStream(int32_t portId);
status_t prepareToOpenStream(
int32_t aidlHandle,
const ::aidl::android::media::audio::common::AudioDevice& aidlDevice,
@@ -312,6 +313,7 @@
std::mutex mLock;
std::map<void*, Callbacks> mCallbacks GUARDED_BY(mLock);
std::set<audio_port_handle_t> mDeviceDisconnectionNotified;
+ std::set<int32_t> mConnectedPortIdsHeldByStreams;
};
} // namespace android