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

Commit 4e8ecbb9 authored by Chen Chen's avatar Chen Chen Committed by Automerger Merge Worker
Browse files

Merge "Spatial Audio: Add setLatencyMode and setCodecType API with empty...

Merge "Spatial Audio: Add setLatencyMode and setCodecType API with empty implementation" am: c29097a7 am: 136cd434 am: 982113ba

Original change: https://android-review.googlesource.com/c/platform/hardware/interfaces/+/1976127

Change-Id: I09657285405a47b90d397c43bc0833a06e40920f
parents e9af7355 982113ba
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -40,4 +40,6 @@ interface IBluetoothAudioPort {
  void suspendStream();
  void updateSourceMetadata(in android.hardware.audio.common.SourceMetadata sourceMetadata);
  void updateSinkMetadata(in android.hardware.audio.common.SinkMetadata sinkMetadata);
  void setLatencyMode(in android.hardware.bluetooth.audio.LatencyMode latencyMode);
  void setCodecType(in android.hardware.bluetooth.audio.CodecType codecType);
}
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
///////////////////////////////////////////////////////////////////////////////
// THIS FILE IS IMMUTABLE. DO NOT EDIT IN ANY CASE.                          //
///////////////////////////////////////////////////////////////////////////////

// This file is a snapshot of an AIDL file. Do not edit it manually. There are
// two cases:
// 1). this is a frozen version file - do not edit this in any case.
// 2). this is a 'current' file. If you make a backwards compatible change to
//     the interface (from the latest frozen version), the build system will
//     prompt you to update this file with `m <name>-update-api`.
//
// You must not make a backward incompatible change to any AIDL file built
// with the aidl_interface module type with versions property set. The module
// type is used to build AIDL files in a way that they can be used across
// independently updatable components of the system. If a device is shipped
// with such a backward incompatible change, it has a high risk of breaking
// later when a module using the interface is updated, e.g., Mainline modules.

package android.hardware.bluetooth.audio;
@Backing(type="int") @VintfStability
enum LatencyMode {
  UNKNOWN = 0,
  LOW_LATENCY = 1,
  FREE = 2,
}
+16 −0
Original line number Diff line number Diff line
@@ -18,6 +18,8 @@ package android.hardware.bluetooth.audio;

import android.hardware.audio.common.SinkMetadata;
import android.hardware.audio.common.SourceMetadata;
import android.hardware.bluetooth.audio.CodecType;
import android.hardware.bluetooth.audio.LatencyMode;
import android.hardware.bluetooth.audio.PresentationPosition;

/**
@@ -78,4 +80,18 @@ interface IBluetoothAudioPort {
     * @param sinkMetadata as passed from Audio Framework
     */
    void updateSinkMetadata(in SinkMetadata sinkMetadata);

    /**
     * Called when latency mode is changed.
     *
     * @param latencyMode latency mode from audio
     */
    void setLatencyMode(in LatencyMode latencyMode);

    /**
     * Called when codec type is changed.
     *
     * @param codecType codec type from audio
     */
    void setCodecType(in CodecType codecType);
}
+25 −0
Original line number Diff line number Diff line
/*
 * Copyright 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.hardware.bluetooth.audio;

@VintfStability
@Backing(type="int")
enum LatencyMode {
    UNKNOWN,
    LOW_LATENCY,
    FREE,
}
+30 −0
Original line number Diff line number Diff line
@@ -508,6 +508,36 @@ void BluetoothAudioSession::UpdateSinkMetadata(
  }
}

void BluetoothAudioSession::SetLatencyMode(LatencyMode latency_mode) {
  std::lock_guard<std::recursive_mutex> guard(mutex_);
  if (!IsSessionReady()) {
    LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_)
               << " has NO session";
    return;
  }

  auto hal_retval = stack_iface_->setLatencyMode(latency_mode);
  if (!hal_retval.isOk()) {
    LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
                 << toString(session_type_) << " failed";
  }
}

void BluetoothAudioSession::SetCodecType(CodecType codec_type) {
  std::lock_guard<std::recursive_mutex> guard(mutex_);
  if (!IsSessionReady()) {
    LOG(DEBUG) << __func__ << " - SessionType=" << toString(session_type_)
               << " has NO session";
    return;
  }

  auto hal_retval = stack_iface_->setCodecType(codec_type);
  if (!hal_retval.isOk()) {
    LOG(WARNING) << __func__ << " - IBluetoothAudioPort SessionType="
                 << toString(session_type_) << " failed";
  }
}

bool BluetoothAudioSession::IsAidlAvailable() {
  if (is_aidl_checked) return is_aidl_available;
  is_aidl_available =
Loading