blob: 7368062b713cadf89c0ac0ad8927e63d38de9b34 [file] [log] [blame]
Phil Burkc0c70e32017-02-09 13:18:38 -08001/*
2 * Copyright (C) 2017 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Phil Burk5204d312017-05-04 17:16:13 -070017#ifndef ANDROID_AAUDIO_BINDING_AAUDIO_SERVICE_INTERFACE_H
18#define ANDROID_AAUDIO_BINDING_AAUDIO_SERVICE_INTERFACE_H
Phil Burkc0c70e32017-02-09 13:18:38 -080019
Phil Burk11e8d332017-05-24 09:59:02 -070020#include <utils/StrongPointer.h>
21
Phil Burkc0c70e32017-02-09 13:18:38 -080022#include "binding/AAudioServiceDefinitions.h"
23#include "binding/AAudioStreamRequest.h"
24#include "binding/AAudioStreamConfiguration.h"
25#include "binding/AudioEndpointParcelable.h"
Phil Burk11e8d332017-05-24 09:59:02 -070026#include "binding/IAAudioClient.h"
Phil Burkc0c70e32017-02-09 13:18:38 -080027
28/**
29 * This has the same methods as IAAudioService but without the Binder features.
30 *
31 * It allows us to abstract the Binder interface and use an AudioStreamInternal
32 * both in the client and in the service.
33 */
34namespace aaudio {
35
36class AAudioServiceInterface {
37public:
38
39 AAudioServiceInterface() {};
40 virtual ~AAudioServiceInterface() = default;
41
Phil Burk11e8d332017-05-24 09:59:02 -070042 virtual void registerClient(const android::sp<android::IAAudioClient>& client) = 0;
43
Phil Burkc0c70e32017-02-09 13:18:38 -080044 /**
45 * @param request info needed to create the stream
46 * @param configuration contains information about the created stream
47 * @return handle to the stream or a negative error
48 */
49 virtual aaudio_handle_t openStream(const AAudioStreamRequest &request,
50 AAudioStreamConfiguration &configuration) = 0;
51
52 virtual aaudio_result_t closeStream(aaudio_handle_t streamHandle) = 0;
53
54 /* Get an immutable description of the in-memory queues
55 * used to communicate with the underlying HAL or Service.
56 */
57 virtual aaudio_result_t getStreamDescription(aaudio_handle_t streamHandle,
58 AudioEndpointParcelable &parcelable) = 0;
59
60 /**
61 * Start the flow of data.
62 */
63 virtual aaudio_result_t startStream(aaudio_handle_t streamHandle) = 0;
64
65 /**
66 * Stop the flow of data such that start() can resume without loss of data.
67 */
68 virtual aaudio_result_t pauseStream(aaudio_handle_t streamHandle) = 0;
69
70 /**
Phil Burk71f35bb2017-04-13 16:05:07 -070071 * Stop the flow of data after data currently inthe buffer has played.
72 */
73 virtual aaudio_result_t stopStream(aaudio_handle_t streamHandle) = 0;
74
75 /**
Phil Burkc0c70e32017-02-09 13:18:38 -080076 * Discard any data held by the underlying HAL or Service.
77 */
78 virtual aaudio_result_t flushStream(aaudio_handle_t streamHandle) = 0;
79
80 /**
81 * Manage the specified thread as a low latency audio thread.
82 */
83 virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
Phil Burkc0c70e32017-02-09 13:18:38 -080084 pid_t clientThreadId,
85 int64_t periodNanoseconds) = 0;
86
87 virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle,
Phil Burkc0c70e32017-02-09 13:18:38 -080088 pid_t clientThreadId) = 0;
89};
90
91} /* namespace aaudio */
92
Phil Burk5204d312017-05-04 17:16:13 -070093#endif //ANDROID_AAUDIO_BINDING_AAUDIO_SERVICE_INTERFACE_H