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

Commit 7c4f3e9f authored by Mikhail Naganov's avatar Mikhail Naganov Committed by Gerrit Code Review
Browse files

Merge "Effects: add a method to retrieve audio configuration"

parents 79cfb001 59984dbb
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -302,12 +302,26 @@ aidl_interface {
    double_loadable: true,
    vendor_available: true,
    srcs: [
        "aidl/android/media/EffectConfig.aidl",
        "aidl/android/media/IEffect.aidl",
        "aidl/android/media/IEffectClient.aidl",
    ],
    imports: [
        "android.media.audio.common.types-V1",
        "shared-file-region-aidl",
    ],
    backend: {
        cpp: {
            min_sdk_version: "29",
            apex_available: [
                "//apex_available:platform",
                "com.android.media",
            ],
        },
        java: {
            sdk_version: "module_current",
        },
    },
}

aidl_interface {
+30 −0
Original line number Diff line number Diff line
@@ -527,6 +527,36 @@ status_t AudioEffect::getParameter(effect_param_t *param)
    return status;
}

status_t AudioEffect::getConfigs(
        audio_config_base_t *inputCfg, audio_config_base_t *outputCfg)
{
    if (mProbe) {
        return INVALID_OPERATION;
    }
    if (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS) {
        return mStatus;
    }
    if (inputCfg == NULL || outputCfg == NULL) {
        return BAD_VALUE;
    }
    status_t status;
    media::EffectConfig cfg;
    Status bs = mIEffect->getConfig(&cfg, &status);
    if (!bs.isOk()) {
        status = statusTFromBinderStatus(bs);
        ALOGW("%s received status %d from binder transaction", __func__, status);
        return status;
    }
    if (status == NO_ERROR) {
        *inputCfg = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioConfigBase_audio_config_base_t(
                        cfg.inputCfg, cfg.isOnInputStream));
        *outputCfg = VALUE_OR_RETURN_STATUS(aidl2legacy_AudioConfigBase_audio_config_base_t(
                        cfg.outputCfg, cfg.isOnInputStream));
    } else {
        ALOGW("%s received status %d from the effect", __func__, status);
    }
    return status;
}

// -------------------------------------------------------------------------

+38 −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.
 */

package android.media;

import android.media.audio.common.AudioConfigBase;

/**
 * Describes configuration of an audio effect. Input and output
 * audio configurations are described separately because the effect
 * can perform transformations on channel layouts, for example.
 *
 * {@hide}
 */
parcelable EffectConfig {
    /** Configuration of the audio input of the effect. */
    AudioConfigBase inputCfg;
    /** Configuration of the audio output of the effect. */
    AudioConfigBase outputCfg;
    /**
     * Specifies whether the effect is instantiated on an input stream,
     * e.g. on the input from a microphone.
     */
    boolean isOnInputStream;
}
+9 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@

package android.media;

import android.media.EffectConfig;
import android.media.SharedFileRegion;

/**
@@ -63,6 +64,14 @@ interface IEffect {
     */
    SharedFileRegion getCblk();

    /**
     * Provides audio configurations for effect's input and output,
     * see EffectConfig parcelable for more details.
     *
     * @return a status_t code.
     */
    int getConfig(out EffectConfig config);

    // When adding a new method, please review and update
    // Effects.cpp AudioFlinger::EffectHandle::onTransact()
    // Effects.cpp IEFFECT_BINDER_METHOD_MACRO_LIST
+19 −0
Original line number Diff line number Diff line
@@ -578,6 +578,25 @@ public:
                              uint32_t *replySize,
                              void *replyData);

    /* Retrieves the configuration of the effect.
     *
     * Parameters:
     *      inputCfg:  pointer to audio_config_base_t structure receiving input
     *          configuration of the effect
     *      outputCfg: pointer to audio_config_base_t structure receiving output
     *          configuration of the effect
     *
     * Channel masks of the returned configs are "input" or "output" depending
     * on the direction of the stream that the effect is attached to.
     *
     * Returned status (from utils/Errors.h) can be:
     *  - NO_ERROR: successful operation.
     *  - INVALID_OPERATION: the AudioEffect was not successfully initialized.
     *  - BAD_VALUE: null config pointers
     *  - DEAD_OBJECT: the effect engine has been deleted.
     */
     virtual status_t   getConfigs(audio_config_base_t *inputCfg,
                                   audio_config_base_t *outputCfg);

     /*
      * Utility functions.
Loading