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

Commit ebebc9c2 authored by Hayden Gomes's avatar Hayden Gomes
Browse files

Adding v2 of audiocontrol hal

- Removes deprecated getBusForContext
- Adds APIs for enabling HAL to request and abandon audio focus

Bug: 148098383
Test: vts-tradefed -module VtsHalAudioControlV2_0TargetTest
Change-Id: I353bbd8ea7708ffb59831a8e1008951146798034
parent ec34c7ff
Loading
Loading
Loading
Loading
+20 −0
Original line number Diff line number Diff line
// This file is autogenerated by hidl-gen -Landroidbp.

hidl_interface {
    name: "android.hardware.automotive.audiocontrol@2.0",
    root: "android.hardware",
    vndk: {
        enabled: true,
    },
    srcs: [
        "types.hal",
        "IAudioControl.hal",
        "ICloseHandle.hal",
        "IFocusListener.hal",
    ],
    interfaces: [
        "android.hidl.base@1.0",
        "android.hardware.audio.common@6.0",
    ],
    gen_java: true,
}
+78 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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@2.0;

import ICloseHandle;
import IFocusListener;
import android.hardware.audio.common@6.0::AudioUsage;

/**
 * Interacts with the car's audio subsystem to manage audio sources and volumes
 */
interface IAudioControl {
    /**
     * Registers focus listener to be used by HAL for requesting and abandoning audio focus.
     *
     * It is expected that there will only ever be a single focus listener registered. If the
     * observer dies, the HAL implementation must unregister observer automatically. If called when
     * a listener is already registered, the existing one should be unregistered and replaced with
     * the new listener.
     *
     * @param listener the listener interface
     * @return closeHandle A handle to unregister observer.
     */
    registerFocusListener(IFocusListener listener) generates (ICloseHandle closeHandle);

    /**
     * Notifies HAL of changes in audio focus status for focuses requested or abandoned by the HAL.
     *
     * This will be called in response to IFocusListener's requestAudioFocus and
     * abandonAudioFocus, as well as part of any change in focus being held by the HAL due focus
     * request from other activities or services.
     *
     * The HAL is not required to wait for an callback of AUDIOFOCUS_GAIN before playing audio, nor
     * is it required to stop playing audio in the event of a AUDIOFOCUS_LOSS callback is received.
     *
     * @param usage The audio usage associated with the focus change {@code AttributeUsage}
     * @param zoneId The identifier for the audio zone that the HAL is playing the stream in
     * @param focusChange the AudioFocusChange that has occurred
     */
    oneway onAudioFocusChange(bitfield<AudioUsage> usage, int32_t zoneId,
        bitfield<AudioFocusChange> focusChange);

    /**
     * Control the right/left balance setting of the car speakers.
     *
     * This is intended to shift the speaker volume toward the right (+) or left (-) side of
     * the car. 0.0 means "centered". +1.0 means fully right. -1.0 means fully left.
     *
     * A value outside the range -1 to 1 must be clamped by the implementation to the -1 to 1
     * range.
     */
    oneway setBalanceTowardRight(float value);

    /**
     * Control the fore/aft fade setting of the car speakers.
     *
     * This is intended to shift the speaker volume toward the front (+) or back (-) of the car.
     * 0.0 means "centered". +1.0 means fully forward. -1.0 means fully rearward.
     *
     * A value outside the range -1 to 1 must be clamped by the implementation to the -1 to 1
     * range.
     */
    oneway setFadeTowardFront(float value);
};
+34 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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@2.0;

/**
 * Represents a generic close handle to remove a callback that doesn't need
 * active interface.
 *
 * When close() is called OR when the interface is released, the underlying
 * resources must be freed.
 */
interface ICloseHandle {
    /**
     * Closes the handle.
     *
     * The call must not fail and must be issued by the client at most once.
     * Otherwise, the server must ignore subsequent calls.
     */
    close();
};
+55 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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@2.0;

import android.hardware.audio.common@6.0::AudioUsage;

/**
 * Callback interface for audio focus listener.
 *
 * For typical configuration, the listener the car audio service.
 */
interface IFocusListener {
    /**
     * Called whenever HAL is requesting focus as it is starting to play audio of a given usage in a
     * specified zone.
     *
     * In response, IAudioControl#onAudioFocusChange will be called with focusChange status. This
     * interaction is oneway to avoid blocking HAL so that it is not required to wait for a response
     * before playing audio.
     *
     * @param usage The audio usage associated with the focus request {@code AttributeUsage}
     * @param zoneId The identifier for the audio zone where the HAL is requesting focus
     * @param focusGain The AudioFocusChange associated with this request. Should be one of the
     * following: GAIN, GAIN_TRANSIENT, GAIN_TRANSIENT_MAY_DUCK, GAIN_TRANSIENT_EXCLUSIVE.
     */
    oneway requestAudioFocus(bitfield<AudioUsage> usage, int32_t zoneId,
        bitfield<AudioFocusChange> focusGain);

    /**
     * Called whenever HAL is abandoning focus as it is finished playing audio of a given usage in a
     * specific zone.
     *
     * In response, IAudioControl#onAudioFocusChange will be called with focusChange status. This
     * interaction is oneway to avoid blocking HAL so that it is not required to wait for a response
     * before stopping audio playback.
     *
     * @param usage The audio usage for which the HAL is abandoning focus {@code AttributeUsage}
     * @param zoneId The identifier for the audio zone that the HAL abandoning focus
     */
    oneway abandonAudioFocus(bitfield<AudioUsage> usage, int32_t zoneId);
};
+39 −0
Original line number Diff line number Diff line
// Copyright (C) 2020 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.

cc_binary {
    name: "android.hardware.automotive.audiocontrol@2.0-service",
    defaults: ["hidl_defaults"],
    vendor: true,
    relative_install_path: "hw",
    srcs: [
        "AudioControl.cpp",
        "service.cpp",
        "CloseHandle.cpp",
    ],
    init_rc: ["android.hardware.automotive.audiocontrol@2.0-service.rc"],

    shared_libs: [
        "android.hardware.automotive.audiocontrol@2.0",
        "libbase",
        "libhidlbase",
        "liblog",
        "libutils",
    ],
    vintf_fragments: ["audiocontrol2_manifest.xml"],
    cflags: [
        "-O0",
        "-g",
    ],
}
Loading