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

Commit b8519d0c authored by Bao Do's avatar Bao Do
Browse files

Allow BluetoothAudioPortImpl to inherit caller's thread priority.

This help BT HAL's function calls from AudioFlinger's writer thread to
get processed without much delay, resulting in reduced audio glitches.

Bug: 335049159
Bug: 308712263
Flag: com.android.bluetooth.flags.audio_port_binder_inherit_rt
Test: mmm packages/modules/Bluetooth/system/audio_hal_interface

Change-Id: I8884ed996945976a3c1eb7e9226ae891907b066b
parent 2d333ba0
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -17,9 +17,11 @@
#include "bluetooth_audio_port_impl.h"

#include <bluetooth/log.h>
#include <com_android_bluetooth_flags.h>

#include <vector>

#include "android/binder_ibinder_platform.h"
#include "btif/include/btif_common.h"
#include "common/stop_watch_legacy.h"

@@ -226,6 +228,17 @@ PresentationPosition::TimeSpec BluetoothAudioPortImpl::timespec_convert_to_hal(
          .tvNSec = static_cast<int64_t>(ts.tv_nsec)};
}

// Overriding create binder and inherit RT from caller.
// In our case, the caller is the AIDL session control, so we match the priority
// of the AIDL session / AudioFlinger writer thread.
ndk::SpAIBinder BluetoothAudioPortImpl::createBinder() {
  auto binder = BnBluetoothAudioPort::createBinder();
  if (com::android::bluetooth::flags::audio_port_binder_inherit_rt()) {
    AIBinder_setInheritRt(binder.get(), true);
  }
  return binder;
}

}  // namespace aidl
}  // namespace audio
}  // namespace bluetooth
+3 −1
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ class BluetoothAudioPortImpl : public BnBluetoothAudioPort {

 private:
  ndk::ScopedAStatus switchCodec(bool isLowLatency);

  ndk::SpAIBinder createBinder() override;
};

}  // namespace aidl