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

Commit 30301a42 authored by Mikhail Naganov's avatar Mikhail Naganov
Browse files

audio: Add non-blocking I/O stream operations

Introduce IStreamCallback interface for non-blocking I/O. Add 2
new stream states: TRANSFERRING and TRANSFER_PAUSED, and define
state machines for the async case. Add DrainMode as in previous
HAL versions.

Note that non-blocking input is not fully implemented because it
did not exist in previous HAL versions, and the corresponding
AudioInputFlag does not exist yet.

Enhance VTS state machine tests to allow waiting for an async
event.

Bug: 205884982
Test: atest VtsHalAudioCoreTargetTest
Change-Id: I0a18a6d930dee5941f769e08083817d41ff941e6
parent e467e013
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -96,6 +96,7 @@ aidl_interface {
        "android/hardware/audio/core/AudioRoute.aidl",
        "android/hardware/audio/core/IConfig.aidl",
        "android/hardware/audio/core/IModule.aidl",
        "android/hardware/audio/core/IStreamCallback.aidl",
        "android/hardware/audio/core/IStreamIn.aidl",
        "android/hardware/audio/core/IStreamOut.aidl",
        "android/hardware/audio/core/ITelephony.aidl",
+1 −0
Original line number Diff line number Diff line
@@ -76,6 +76,7 @@ interface IModule {
    android.hardware.audio.common.SourceMetadata sourceMetadata;
    @nullable android.media.audio.common.AudioOffloadInfo offloadInfo;
    long bufferSizeFrames;
    @nullable android.hardware.audio.core.IStreamCallback callback;
  }
  @VintfStability
  parcelable OpenOutputStreamReturn {
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 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.audio.core;
@VintfStability
interface IStreamCallback {
  oneway void onTransferReady();
  oneway void onError();
  oneway void onDrainReady();
}
+9 −1
Original line number Diff line number Diff line
@@ -54,15 +54,23 @@ parcelable StreamDescriptor {
    PAUSED = 4,
    DRAINING = 5,
    DRAIN_PAUSED = 6,
    TRANSFERRING = 7,
    TRANSFER_PAUSED = 8,
    ERROR = 100,
  }
  @Backing(type="byte") @VintfStability
  enum DrainMode {
    DRAIN_UNSPECIFIED = 0,
    DRAIN_ALL = 1,
    DRAIN_EARLY_NOTIFY = 2,
  }
  @FixedSize @VintfStability
  union Command {
    int halReservedExit;
    android.media.audio.common.Void getStatus;
    android.media.audio.common.Void start;
    int burst;
    android.media.audio.common.Void drain;
    android.hardware.audio.core.StreamDescriptor.DrainMode drain;
    android.media.audio.common.Void standby;
    android.media.audio.common.Void pause;
    android.media.audio.common.Void flush;
+12 −3
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.hardware.audio.common.SourceMetadata;
import android.hardware.audio.core.AudioMode;
import android.hardware.audio.core.AudioPatch;
import android.hardware.audio.core.AudioRoute;
import android.hardware.audio.core.IStreamCallback;
import android.hardware.audio.core.IStreamIn;
import android.hardware.audio.core.IStreamOut;
import android.hardware.audio.core.ITelephony;
@@ -320,9 +321,13 @@ interface IModule {
     * 'setAudioPortConfig' method. Existence of an audio patch involving this
     * port configuration is not required for successful opening of a stream.
     *
     * If the port configuration has 'COMPRESS_OFFLOAD' output flag set,
     * the framework must provide additional information about the encoded
     * audio stream in 'offloadInfo' argument.
     * If the port configuration has the 'COMPRESS_OFFLOAD' output flag set,
     * the client must provide additional information about the encoded
     * audio stream in the 'offloadInfo' argument.
     *
     * If the port configuration has the 'NON_BLOCKING' output flag set,
     * the client must provide a callback for asynchronous notifications
     * in the 'callback' argument.
     *
     * The requested buffer size is expressed in frames, thus the actual size
     * in bytes depends on the audio port configuration. Also, the HAL module
@@ -358,6 +363,8 @@ interface IModule {
     *                             - If the offload info is not provided for an offload
     *                               port configuration.
     *                             - If a buffer of the requested size can not be provided.
     *                             - If the callback is not provided for a non-blocking
     *                               port configuration.
     * @throws EX_ILLEGAL_STATE In the following cases:
     *                          - If the port config already has a stream opened on it.
     *                          - If the limit on the open stream count for the port has
@@ -376,6 +383,8 @@ interface IModule {
        @nullable AudioOffloadInfo offloadInfo;
        /** Requested audio I/O buffer minimum size, in frames. */
        long bufferSizeFrames;
        /** Client callback interface for the non-blocking output mode. */
        @nullable IStreamCallback callback;
    }
    @VintfStability
    parcelable OpenOutputStreamReturn {
Loading