AAudioBinderClient.h revision c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fb
1/* 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 17#ifndef AAUDIO_AAUDIO_BINDER_CLIENT_H 18#define AAUDIO_AAUDIO_BINDER_CLIENT_H 19 20#include <aaudio/AAudioDefinitions.h> 21#include "AAudioServiceDefinitions.h" 22#include "AAudioServiceInterface.h" 23#include "binding/AAudioStreamRequest.h" 24#include "binding/AAudioStreamConfiguration.h" 25#include "binding/AudioEndpointParcelable.h" 26 27/** 28 * Implements the AAudioServiceInterface by talking to the actual service through Binder. 29 */ 30 31namespace aaudio { 32 33class AAudioBinderClient : public AAudioServiceInterface { 34 35public: 36 37 AAudioBinderClient(); 38 39 virtual ~AAudioBinderClient(); 40 41 /** 42 * @param request info needed to create the stream 43 * @param configuration contains resulting information about the created stream 44 * @return handle to the stream or a negative error 45 */ 46 aaudio_handle_t openStream(const AAudioStreamRequest &request, 47 AAudioStreamConfiguration &configurationOutput) override; 48 49 aaudio_result_t closeStream(aaudio_handle_t streamHandle) override; 50 51 /* Get an immutable description of the in-memory queues 52 * used to communicate with the underlying HAL or Service. 53 */ 54 aaudio_result_t getStreamDescription(aaudio_handle_t streamHandle, 55 AudioEndpointParcelable &parcelable) override; 56 57 /** 58 * Start the flow of data. 59 * This is asynchronous. When complete, the service will send a STARTED event. 60 */ 61 aaudio_result_t startStream(aaudio_handle_t streamHandle) override; 62 63 /** 64 * Stop the flow of data such that start() can resume without loss of data. 65 * This is asynchronous. When complete, the service will send a PAUSED event. 66 */ 67 aaudio_result_t pauseStream(aaudio_handle_t streamHandle) override; 68 69 /** 70 * Discard any data held by the underlying HAL or Service. 71 * This is asynchronous. When complete, the service will send a FLUSHED event. 72 */ 73 aaudio_result_t flushStream(aaudio_handle_t streamHandle) override; 74 75 /** 76 * Manage the specified thread as a low latency audio thread. 77 * TODO Consider passing this information as part of the startStream() call. 78 */ 79 aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle, 80 pid_t clientProcessId, 81 pid_t clientThreadId, 82 int64_t periodNanoseconds) override; 83 84 aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle, 85 pid_t clientProcessId, 86 pid_t clientThreadId) override; 87}; 88 89 90} /* namespace aaudio */ 91 92#endif //AAUDIO_AAUDIO_BINDER_CLIENT_H 93