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

Commit fd96ddce authored by Raj Goparaju's avatar Raj Goparaju
Browse files

Adding support for dynamic audio gain config



Automotive OEMs need a mechanism to update vehicle-based
audio port configurations during run-time. This can be
achieved mostly through core audio hal aidl interface,
namely IModule::getAudioPorts(). However it also limits the
ability of audio hal since it is expected to maintan unchanged
configuration for given audio device ports and have it
available before audio framework initializes, which is
not always the case.

The following usecases are under consideration for this
feature:
1. Audio gain stages updated at end-of-line/factories as
   runtime configurations.
2. Audio gain stages  are stored outside of android partition
   (example - an external amplifier) and needs dynamic query
   post boot up. Availability at service init is not  guaranteed
   since ECU lifecycles are not necessarily synchronized.
3. Audio gain stage updates based on user subscriptions
   to enable advanced signal processing capabilities.

This change:
- Adds a new set-api for callback to report changes to
  audio hardware module. It is expected that in future the
  same interface can serve as callback to multiple categories
  of configs (other than audio gain stages).
- Adds a new clear to remove callbacks.
- Adds a new callback interface for changes to audio port
  configs. For the time being, car framework shall only support
  changes to audio gain stages.

Bug: 261647905
Test: VTS test

Change-Id: I5891e324f2d909a9c5fe30c47ad30e23e74ec6c4
Signed-off-by: default avatarRaj Goparaju <rajgoparaju@google.com>
parent 4ff44567
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -46,4 +46,6 @@ interface IAudioControl {
  oneway void onAudioFocusChangeWithMetaData(in android.hardware.audio.common.PlaybackTrackMetadata playbackMetaData, in int zoneId, in android.hardware.automotive.audiocontrol.AudioFocusChange focusChange);
  oneway void setAudioDeviceGainsChanged(in android.hardware.automotive.audiocontrol.Reasons[] reasons, in android.hardware.automotive.audiocontrol.AudioGainConfigInfo[] gains);
  oneway void registerGainCallback(in android.hardware.automotive.audiocontrol.IAudioGainCallback callback);
  void setModuleChangeCallback(in android.hardware.automotive.audiocontrol.IModuleChangeCallback callback);
  void clearModuleChangeCallback();
}
+38 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.automotive.audiocontrol;
@VintfStability
interface IModuleChangeCallback {
  oneway void onAudioPortsChanged(in android.media.audio.common.AudioPort[] audioPorts);
}
+23 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import android.hardware.automotive.audiocontrol.AudioGainConfigInfo;
import android.hardware.automotive.audiocontrol.DuckingInfo;
import android.hardware.automotive.audiocontrol.IAudioGainCallback;
import android.hardware.automotive.audiocontrol.IFocusListener;
import android.hardware.automotive.audiocontrol.IModuleChangeCallback;
import android.hardware.automotive.audiocontrol.MutingInfo;
import android.hardware.automotive.audiocontrol.Reasons;

@@ -183,4 +184,26 @@ interface IAudioControl {
     *                 interface.
     */
    oneway void registerGainCallback(in IAudioGainCallback callback);

    /**
     * Sets callback with HAL for notifying changes to hardware module (that is:
     * {@link android.hardware.audio.core.IModule}) configurations.
     *
     * @param callback The {@link android.hardware.automotive.audiocontrol.IModuleChangeCallback}
     *                 interface to use use when new updates are available for
     *                 {@link android.hardware.audio.core.IModule} configs
     * @throws EX_UNSUPPORTED_OPERATION if dynamic audio configs are not supported.
     * @throws EX_ILLEGAL_STATE if a callback already exists
     * @throws EX_ILLEGAL_ARGUMENT if the passed callback is (@code null}
     */
    void setModuleChangeCallback(in IModuleChangeCallback callback);

    /**
     * Clears module change callback
     *
     * If no callback is registered previously, then this call should be a no-op.
     *
     * @throws EX_UNSUPPORTED_OPERATION if dynamic audio configs are not supported.
     */
    void clearModuleChangeCallback();
}
+61 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2023 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.automotive.audiocontrol;

import android.media.audio.common.AudioPort;

/**
 * Interface definition for asynchronous changes to audio configs defined
 * for a hardware {@link android.hardware.audio.core.IModule}.
 */
@VintfStability
oneway interface IModuleChangeCallback {
    /**
     * Used to indicate that one or more {@link android.media.audio.common.AudioPort}
     * configs have changed. Implementations MUST return at least one AudioPort.
     *
     * Notes for AudioPort:
     * 1. For V3, the support will be limited to configurable AudioGain stages - per
     *    car audio framework support.
     * 2. For automotive 'bus' devices, the expected settings are
     *     AudioDevice {
     *        AudioDeviceDescription {type: IN/OUT_DEVICE, connection: CONNECTION_BUS}
     *        AudioDeviceAddress {id: string}}
     *
     * Notes for AudioGain:
     * 1. Car audio framework only supports AudioGainMode::JOINT. Any other mode
     *    selection will be ignored.
     *    See {@link android.media.audio.common.AudioGainMode}
     * 2. Implementations MUST ensure that the gain stages are identical for buses
     *    that map to the same volume group. Any inconsistencies will result in
     *    inferior volume-change experience to the users.
     * 3. Implementations MUST ensure that the new gain stages are subset (do not
     *    exceed) of the gain stage definitions provided to audio policy. If they
     *    exceed, it can result in failure when setting value over the range
     *    allowed by the audio policy.
     *
     * Other notes:
     * 1. In case of AudioControl  service restart or resume, the implementations MUST
     *    issue an immediate callback following registration.
     * 2. In case of client restart, the AudioControl service MUST clear all stale
     *    callbacks.
     *
     * @param audioPorts list of {@link android.media.audio.common.AudioPort} that
     *                   are updated
     */
    void onAudioPortsChanged(in AudioPort[] audioPorts);
}