1 /* 2 * Copyright (C) 2020 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 package aaudio; 18 19 import aaudio.Endpoint; 20 import aaudio.IAAudioClient; 21 import aaudio.StreamParameters; 22 import aaudio.StreamRequest; 23 24 interface IAAudioService { 25 /** 26 * Register an object to receive audio input/output change and track notifications. 27 * For a given calling pid, AAudio service disregards any registrations after the first. 28 * Thus the IAAudioClient must be a singleton per process. 29 */ registerClient(IAAudioClient client)30 void registerClient(IAAudioClient client); 31 32 /** 33 * @param request info needed to create the stream 34 * @param paramsOut contains information about the created stream 35 * @return handle to the stream or a negative error 36 */ openStream(in StreamRequest request, out StreamParameters paramsOut)37 int openStream(in StreamRequest request, 38 out StreamParameters paramsOut); 39 closeStream(int streamHandle)40 int closeStream(int streamHandle); 41 42 /* 43 * Get an immutable description of the in-memory queues 44 * used to communicate with the underlying HAL or Service. 45 */ getStreamDescription(int streamHandle, out Endpoint endpoint)46 int getStreamDescription(int streamHandle, out Endpoint endpoint); 47 48 /** 49 * Start the flow of data. 50 * This is asynchronous. When complete, the service will send a STARTED event. 51 */ startStream(int streamHandle)52 int startStream(int streamHandle); 53 54 /** 55 * Stop the flow of data such that start() can resume without loss of data. 56 * This is asynchronous. When complete, the service will send a PAUSED event. 57 */ pauseStream(int streamHandle)58 int pauseStream(int streamHandle); 59 60 /** 61 * Stop the flow of data such that the data currently in the buffer is played. 62 * This is asynchronous. When complete, the service will send a STOPPED event. 63 */ stopStream(int streamHandle)64 int stopStream(int streamHandle); 65 66 /** 67 * Discard any data held by the underlying HAL or Service. 68 * This is asynchronous. When complete, the service will send a FLUSHED event. 69 */ flushStream(int streamHandle)70 int flushStream(int streamHandle); 71 72 /** 73 * Manage the specified thread as a low latency audio thread. 74 */ registerAudioThread(int streamHandle, int clientThreadId, long periodNanoseconds)75 int registerAudioThread(int streamHandle, 76 int clientThreadId, 77 long periodNanoseconds); 78 unregisterAudioThread(int streamHandle, int clientThreadId)79 int unregisterAudioThread(int streamHandle, 80 int clientThreadId); 81 exitStandby(int streamHandle, out Endpoint endpoint)82 int exitStandby(int streamHandle, out Endpoint endpoint); 83 } 84