audiohal: Enforce flush of hwbinder commands queue after cleaning client refs
In binderized mode, the exact time of destroying the server object
is not defined. Enforce destruction by flusing hwbinder commands
queue after releasing the last client reference.
Bug: 35394629
Test: capture trace while following repro steps, verify that server-side object
gets destroyed
Change-Id: Id2756cab0f36ed4eaf290d3f5a1c750c9c75b1d3
diff --git a/media/libaudiohal/DeviceHalHidl.cpp b/media/libaudiohal/DeviceHalHidl.cpp
index dcedfd3..71fbd98 100644
--- a/media/libaudiohal/DeviceHalHidl.cpp
+++ b/media/libaudiohal/DeviceHalHidl.cpp
@@ -21,6 +21,7 @@
#include <android/hardware/audio/2.0/IPrimaryDevice.h>
#include <cutils/native_handle.h>
+#include <hwbinder/IPCThreadState.h>
#include <utils/Log.h>
#include "DeviceHalHidl.h"
@@ -101,6 +102,10 @@
}
DeviceHalHidl::~DeviceHalHidl() {
+ if (mDevice != 0) {
+ mDevice.clear();
+ hardware::IPCThreadState::self()->flushCommands();
+ }
}
status_t DeviceHalHidl::getSupportedDevices(uint32_t*) {