blob: 2cee65189d8f7e47f416c17b1766b5e14c03a304 [file] [log] [blame]
Phil Burk5ed503c2017-02-01 09:38:15 -08001/*
2 * Copyright (C) 2016 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
17#ifndef BINDING_IAAUDIOSERVICE_H
18#define BINDING_IAAUDIOSERVICE_H
19
20#include <stdint.h>
21#include <utils/RefBase.h>
22#include <binder/TextOutput.h>
23#include <binder/IInterface.h>
24
25#include <aaudio/AAudio.h>
26
27#include "binding/AAudioServiceDefinitions.h"
28#include "binding/AudioEndpointParcelable.h"
29#include "binding/AAudioStreamRequest.h"
30#include "binding/AAudioStreamConfiguration.h"
Phil Burkc0c70e32017-02-09 13:18:38 -080031#include "utility/HandleTracker.h"
Phil Burk5ed503c2017-02-01 09:38:15 -080032
Phil Burk5ed503c2017-02-01 09:38:15 -080033namespace android {
34
Phil Burkc0c70e32017-02-09 13:18:38 -080035#define AAUDIO_SERVICE_NAME "media.aaudio"
36
Phil Burk5ed503c2017-02-01 09:38:15 -080037// Interface (our AIDL) - Shared by server and client
38class IAAudioService : public IInterface {
39public:
40
41 DECLARE_META_INTERFACE(AAudioService);
42
Phil Burk3df348f2017-02-08 11:41:55 -080043 /**
44 * @param request info needed to create the stream
45 * @param configuration contains information about the created stream
46 * @return handle to the stream or a negative error
47 */
Phil Burkc0c70e32017-02-09 13:18:38 -080048 virtual aaudio_handle_t openStream(const aaudio::AAudioStreamRequest &request,
49 aaudio::AAudioStreamConfiguration &configurationOutput) = 0;
Phil Burk5ed503c2017-02-01 09:38:15 -080050
Phil Burk3316d5e2017-02-15 11:23:01 -080051 virtual aaudio_result_t closeStream(aaudio::aaudio_handle_t streamHandle) = 0;
Phil Burk5ed503c2017-02-01 09:38:15 -080052
53 /* Get an immutable description of the in-memory queues
54 * used to communicate with the underlying HAL or Service.
55 */
Phil Burk3316d5e2017-02-15 11:23:01 -080056 virtual aaudio_result_t getStreamDescription(aaudio::aaudio_handle_t streamHandle,
Phil Burk5ed503c2017-02-01 09:38:15 -080057 aaudio::AudioEndpointParcelable &parcelable) = 0;
58
59 /**
60 * Start the flow of data.
Phil Burkc0c70e32017-02-09 13:18:38 -080061 * This is asynchronous. When complete, the service will send a STARTED event.
Phil Burk5ed503c2017-02-01 09:38:15 -080062 */
Phil Burk3316d5e2017-02-15 11:23:01 -080063 virtual aaudio_result_t startStream(aaudio::aaudio_handle_t streamHandle) = 0;
Phil Burk5ed503c2017-02-01 09:38:15 -080064
65 /**
66 * Stop the flow of data such that start() can resume without loss of data.
Phil Burkc0c70e32017-02-09 13:18:38 -080067 * This is asynchronous. When complete, the service will send a PAUSED event.
Phil Burk5ed503c2017-02-01 09:38:15 -080068 */
Phil Burk3316d5e2017-02-15 11:23:01 -080069 virtual aaudio_result_t pauseStream(aaudio::aaudio_handle_t streamHandle) = 0;
Phil Burk5ed503c2017-02-01 09:38:15 -080070
71 /**
Phil Burk71f35bb2017-04-13 16:05:07 -070072 * Stop the flow of data such that the data currently in the buffer is played.
73 * This is asynchronous. When complete, the service will send a STOPPED event.
74 */
75 virtual aaudio_result_t stopStream(aaudio::aaudio_handle_t streamHandle) = 0;
76
77 /**
Phil Burk5ed503c2017-02-01 09:38:15 -080078 * Discard any data held by the underlying HAL or Service.
Phil Burkc0c70e32017-02-09 13:18:38 -080079 * This is asynchronous. When complete, the service will send a FLUSHED event.
Phil Burk5ed503c2017-02-01 09:38:15 -080080 */
Phil Burk3316d5e2017-02-15 11:23:01 -080081 virtual aaudio_result_t flushStream(aaudio::aaudio_handle_t streamHandle) = 0;
Phil Burk5ed503c2017-02-01 09:38:15 -080082
83 /**
84 * Manage the specified thread as a low latency audio thread.
Phil Burkc0c70e32017-02-09 13:18:38 -080085 * TODO Consider passing this information as part of the startStream() call.
Phil Burk5ed503c2017-02-01 09:38:15 -080086 */
Phil Burkc0c70e32017-02-09 13:18:38 -080087 virtual aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
88 pid_t clientProcessId,
89 pid_t clientThreadId,
Phil Burk3316d5e2017-02-15 11:23:01 -080090 int64_t periodNanoseconds) = 0;
Phil Burk5ed503c2017-02-01 09:38:15 -080091
Phil Burkc0c70e32017-02-09 13:18:38 -080092 virtual aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle,
93 pid_t clientProcessId,
Phil Burk5ed503c2017-02-01 09:38:15 -080094 pid_t clientThreadId) = 0;
95};
96
97class BnAAudioService : public BnInterface<IAAudioService> {
98public:
99 virtual status_t onTransact(uint32_t code, const Parcel& data,
100 Parcel* reply, uint32_t flags = 0);
101
102};
103
104} /* namespace android */
105
106#endif //BINDING_IAAUDIOSERVICE_H