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

Commit b489d8a7 authored by Bao Do's avatar Bao Do Committed by Gerrit Code Review
Browse files

Merge changes I8884ed99,I5e239bb1 into main

* changes:
  Allow BluetoothAudioPortImpl to inherit caller's thread priority.
  Add flag audio_port_binder_inherit_rt
parents ed855b4d b8519d0c
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -32,3 +32,13 @@ flag {
    }
    bug: "338079154"
}

flag {
    name: "audio_port_binder_inherit_rt"
    namespace: "bluetooth"
    description: "Allow audio port AIDL thread to inherit thread priority from its caller"
    bug: "335049159"
    metadata {
        purpose: PURPOSE_BUGFIX
    }
}
+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