/*
 * Copyright (C) 2018 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.audio.effect@5.0;

import android.hardware.audio.common@5.0;
import IEffect;

interface IEffectsFactory {
    /**
     * Returns descriptors of different effects in all loaded libraries.
     *
     * @return retval operation completion status.
     * @return result list of effect descriptors.
     */
    getAllDescriptors() generates(Result retval, vec<EffectDescriptor> result);

    /**
     * Returns a descriptor of a particular effect.
     *
     * @return retval operation completion status.
     * @return result effect descriptor.
     */
    getDescriptor(Uuid uid) generates(Result retval, EffectDescriptor result);

    /**
     * Creates an effect engine of the specified type.  To release the effect
     * engine, it is necessary to release references to the returned effect
     * object.
     *
     * @param uid effect uuid.
     * @param session audio session to which this effect instance will be
     *                attached.  All effects created with the same session ID
     *                are connected in series and process the same signal
     *                stream.
     * @param ioHandle identifies the output or input stream this effect is
     *                 directed to in audio HAL.
     * @return retval operation completion status.
     * @return result the interface for the created effect.
     * @return effectId the unique ID of the effect to be used with
     *                  IStream::addEffect and IStream::removeEffect methods.
     */
    createEffect(Uuid uid, AudioSession session, AudioIoHandle ioHandle)
        generates (Result retval, IEffect result, uint64_t effectId);
};
