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

Commit 913a0158 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

leaudio: Add missing locks

Fixing obvious issue

Bug: 150670922
Test: Compile
Change-Id: Ibec3a111410573f265ce15db5df973680c41fc18
parent 5251d18a
Loading
Loading
Loading
Loading
+5 −0
Original line number Original line Diff line number Diff line
@@ -394,6 +394,7 @@ static jboolean disconnectLeAudioNative(JNIEnv* env, jobject object,


static jboolean groupAddNodeNative(JNIEnv* env, jobject object, jint group_id,
static jboolean groupAddNodeNative(JNIEnv* env, jobject object, jint group_id,
                                   jbyteArray address) {
                                   jbyteArray address) {
  std::shared_lock<std::shared_timed_mutex> lock(interface_mutex);
  jbyte* addr = env->GetByteArrayElements(address, nullptr);
  jbyte* addr = env->GetByteArrayElements(address, nullptr);


  if (!sLeAudioClientInterface) {
  if (!sLeAudioClientInterface) {
@@ -415,6 +416,7 @@ static jboolean groupAddNodeNative(JNIEnv* env, jobject object, jint group_id,


static jboolean groupRemoveNodeNative(JNIEnv* env, jobject object,
static jboolean groupRemoveNodeNative(JNIEnv* env, jobject object,
                                      jint group_id, jbyteArray address) {
                                      jint group_id, jbyteArray address) {
  std::shared_lock<std::shared_timed_mutex> lock(interface_mutex);
  if (!sLeAudioClientInterface) {
  if (!sLeAudioClientInterface) {
    LOG(ERROR) << __func__ << ": Failed to get the Bluetooth LeAudio Interface";
    LOG(ERROR) << __func__ << ": Failed to get the Bluetooth LeAudio Interface";
    return JNI_FALSE;
    return JNI_FALSE;
@@ -434,6 +436,7 @@ static jboolean groupRemoveNodeNative(JNIEnv* env, jobject object,


static void groupSetActiveNative(JNIEnv* env, jobject object, jint group_id) {
static void groupSetActiveNative(JNIEnv* env, jobject object, jint group_id) {
  LOG(INFO) << __func__;
  LOG(INFO) << __func__;
  std::shared_lock<std::shared_timed_mutex> lock(interface_mutex);


  if (!sLeAudioClientInterface) {
  if (!sLeAudioClientInterface) {
    LOG(ERROR) << __func__ << ": Failed to get the Bluetooth LeAudio Interface";
    LOG(ERROR) << __func__ << ": Failed to get the Bluetooth LeAudio Interface";
@@ -447,6 +450,8 @@ static void setCodecConfigPreferenceNative(JNIEnv* env, jobject object,
                                           jint group_id,
                                           jint group_id,
                                           jobject inputCodecConfig,
                                           jobject inputCodecConfig,
                                           jobject outputCodecConfig) {
                                           jobject outputCodecConfig) {
  std::shared_lock<std::shared_timed_mutex> lock(interface_mutex);

  if (!env->IsInstanceOf(inputCodecConfig,
  if (!env->IsInstanceOf(inputCodecConfig,
                         android_bluetooth_BluetoothLeAudioCodecConfig.clazz) ||
                         android_bluetooth_BluetoothLeAudioCodecConfig.clazz) ||
      !env->IsInstanceOf(outputCodecConfig,
      !env->IsInstanceOf(outputCodecConfig,