Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 19e38f8d authored by Mikhail Naganov's avatar Mikhail Naganov Committed by gitbuildkicker
Browse files

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
(cherry picked from commit 23feba25)
parent 932aab60
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -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(const sp<IDevice>& device)
}

DeviceHalHidl::~DeviceHalHidl() {
    if (mDevice != 0) {
        mDevice.clear();
        hardware::IPCThreadState::self()->flushCommands();
    }
}

status_t DeviceHalHidl::getSupportedDevices(uint32_t*) {
+6 −1
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@
#define LOG_TAG "EffectHalHidl"
//#define LOG_NDEBUG 0

#include <hwbinder/IPCThreadState.h>
#include <media/EffectsFactoryApi.h>
#include <utils/Log.h>

@@ -44,7 +45,11 @@ EffectHalHidl::EffectHalHidl(const sp<IEffect>& effect, uint64_t effectId)
}

EffectHalHidl::~EffectHalHidl() {
    if (mEffect != 0) {
        close();
        mEffect.clear();
        hardware::IPCThreadState::self()->flushCommands();
    }
}

// static
+5 −0
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
//#define LOG_NDEBUG 0

#include <android/hardware/audio/2.0/IStreamOutCallback.h>
#include <hwbinder/IPCThreadState.h>
#include <mediautils/SchedulingPolicyService.h>
#include <utils/Log.h>

@@ -263,8 +264,10 @@ StreamOutHalHidl::~StreamOutHalHidl() {
            processReturn("clearCallback", mStream->clearCallback());
        }
        processReturn("close", mStream->close());
        mStream.clear();
    }
    mCallback.clear();
    hardware::IPCThreadState::self()->flushCommands();
    if (mEfGroup) {
        EventFlag::deleteEventFlag(&mEfGroup);
    }
@@ -538,6 +541,8 @@ StreamInHalHidl::StreamInHalHidl(const sp<IStreamIn>& stream)
StreamInHalHidl::~StreamInHalHidl() {
    if (mStream != 0) {
        processReturn("close", mStream->close());
        mStream.clear();
        hardware::IPCThreadState::self()->flushCommands();
    }
    if (mEfGroup) {
        EventFlag::deleteEventFlag(&mEfGroup);