StreamHalHidl: Minor cleanup on destructor
Move binder command flush to base class destructor.
Test: Basic audio works
Bug: 177278988
Change-Id: I0f942a76355f4c63b56cbc2b270a4cbb254241e5
diff --git a/media/libaudiohal/impl/StreamHalHidl.h b/media/libaudiohal/impl/StreamHalHidl.h
index 8b1c3d3..95855fe 100644
--- a/media/libaudiohal/impl/StreamHalHidl.h
+++ b/media/libaudiohal/impl/StreamHalHidl.h
@@ -101,6 +101,8 @@
// Subclasses can not be constructed directly by clients.
explicit StreamHalHidl(IStream *stream);
+ ~StreamHalHidl() override;
+
status_t getCachedBufferSize(size_t *size);
bool requestHalThreadPriority(pid_t threadPid, pid_t threadId);
@@ -182,13 +184,6 @@
typedef MessageQueue<uint8_t, hardware::kSynchronizedReadWrite> DataMQ;
typedef MessageQueue<WriteStatus, hardware::kSynchronizedReadWrite> StatusMQ;
- // Do not move the Defer. This should be the first member variable in the class;
- // thus the last member destructor called upon instance destruction.
- //
- // The last step is to flush all binder commands so that the AudioFlinger
- // may recognize the deletion of IStreamOut (mStream) with less delay. See b/35394629.
- mediautils::Defer mLast{[]() { hardware::IPCThreadState::self()->flushCommands(); }};
-
mediautils::atomic_wp<StreamOutHalInterfaceCallback> mCallback;
mediautils::atomic_wp<StreamOutHalInterfaceEventCallback> mEventCallback;
const sp<IStreamOut> mStream;
@@ -247,13 +242,6 @@
typedef MessageQueue<uint8_t, hardware::kSynchronizedReadWrite> DataMQ;
typedef MessageQueue<ReadStatus, hardware::kSynchronizedReadWrite> StatusMQ;
- // Do not move the Defer. This should be the first member variable in the class;
- // thus the last member destructor called upon instance destruction.
- //
- // The last step is to flush all binder commands so that the AudioFlinger
- // may recognize the deletion of IStreamIn (mStream) with less delay. See b/35394629.
- mediautils::Defer mLast{[]() { hardware::IPCThreadState::self()->flushCommands(); }};
-
const sp<IStreamIn> mStream;
std::unique_ptr<CommandMQ> mCommandMQ;
std::unique_ptr<DataMQ> mDataMQ;