/*
 * 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.media.bufferpool@1.0;

/**
 * A connection to a buffer pool which handles requests from a buffer pool
 * client. The connection must be made in order to receive buffers from
 * other buffer pool clients.
 */
interface IConnection {

    /**
     * Retrieves a buffer using bufferId. The method must be called from
     * receiving side of buffer during transferring only when the specified
     * buffer is neither cached nor used. This fails if the specified
     * transaction is not valid.
     *
     * @param transactionId Unique transaction id for buffer transferring.
     * @param bufferId Id of the buffer to be fetched.
     * @return status The status of the call.
     *     OK               - A buffer was fetched successfully.
     *     NO_MEMORY        - Memory allocation failure occurred.
     *     NOT_FOUND        - A buffer was not found due to invalidation.
     *     CRITICAL_ERROR   - Other errors.
     * @return buffer The actual buffer which is specified with bufferId.
     */
    fetch(uint64_t transactionId, uint32_t bufferId) generates
        (ResultStatus status, Buffer buffer);
};
