1c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk/*
2c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * Copyright (C) 2017 The Android Open Source Project
3c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk *
4c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * Licensed under the Apache License, Version 2.0 (the "License");
5c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * you may not use this file except in compliance with the License.
6c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * You may obtain a copy of the License at
7c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk *
8c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk *      http://www.apache.org/licenses/LICENSE-2.0
9c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk *
10c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * Unless required by applicable law or agreed to in writing, software
11c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * distributed under the License is distributed on an "AS IS" BASIS,
12c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * See the License for the specific language governing permissions and
14c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * limitations under the License.
15c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk */
16c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
175204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#ifndef ANDROID_AAUDIO_BINDING_AAUDIO_SERVICE_INTERFACE_H
185204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#define ANDROID_AAUDIO_BINDING_AAUDIO_SERVICE_INTERFACE_H
19c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
20c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk#include "binding/AAudioServiceDefinitions.h"
21c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk#include "binding/AAudioStreamRequest.h"
22c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk#include "binding/AAudioStreamConfiguration.h"
23c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk#include "binding/AudioEndpointParcelable.h"
24c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
25c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk/**
26c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * This has the same methods as IAAudioService but without the Binder features.
27c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk *
28c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * It allows us to abstract the Binder interface and use an AudioStreamInternal
29c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk * both in the client and in the service.
30c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk */
31c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burknamespace aaudio {
32c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
33c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burkclass AAudioServiceInterface {
34c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burkpublic:
35c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
36c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    AAudioServiceInterface() {};
37c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    virtual ~AAudioServiceInterface() = default;
38c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
39c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    /**
40c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     * @param request info needed to create the stream
41c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     * @param configuration contains information about the created stream
42c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     * @return handle to the stream or a negative error
43c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     */
44c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    virtual aaudio_handle_t openStream(const AAudioStreamRequest &request,
45c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk                                       AAudioStreamConfiguration &configuration) = 0;
46c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
47c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    virtual aaudio_result_t closeStream(aaudio_handle_t streamHandle) = 0;
48c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
49c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    /* Get an immutable description of the in-memory queues
50c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    * used to communicate with the underlying HAL or Service.
51c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    */
52c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    virtual aaudio_result_t getStreamDescription(aaudio_handle_t streamHandle,
53c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk                                                 AudioEndpointParcelable &parcelable) = 0;
54c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
55c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    /**
56c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     * Start the flow of data.
57c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     */
58c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    virtual aaudio_result_t startStream(aaudio_handle_t streamHandle) = 0;
59c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
60c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    /**
61c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     * Stop the flow of data such that start() can resume without loss of data.
62c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     */
63c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    virtual aaudio_result_t pauseStream(aaudio_handle_t streamHandle) = 0;
64c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
65c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    /**
6671f35bb687476694882a617ba4a810a0bb56fe23Phil Burk     * Stop the flow of data after data currently inthe buffer has played.
6771f35bb687476694882a617ba4a810a0bb56fe23Phil Burk     */
6871f35bb687476694882a617ba4a810a0bb56fe23Phil Burk    virtual aaudio_result_t stopStream(aaudio_handle_t streamHandle) = 0;
6971f35bb687476694882a617ba4a810a0bb56fe23Phil Burk
7071f35bb687476694882a617ba4a810a0bb56fe23Phil Burk    /**
71c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     *  Discard any data held by the underlying HAL or Service.
72c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     */
73c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    virtual aaudio_result_t flushStream(aaudio_handle_t streamHandle) = 0;
74c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
75c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    /**
76c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     * Manage the specified thread as a low latency audio thread.
77c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk     */
78c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
79c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk                                                pid_t clientProcessId,
80c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk                                                pid_t clientThreadId,
81c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk                                                int64_t periodNanoseconds) = 0;
82c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
83c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle,
84c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk                                                  pid_t clientProcessId,
85c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk                                                  pid_t clientThreadId) = 0;
86c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk};
87c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
88c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk} /* namespace aaudio */
89c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk
905204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#endif //ANDROID_AAUDIO_BINDING_AAUDIO_SERVICE_INTERFACE_H
91