Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 1 | /* |
| 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" |
| 31 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 32 | namespace android { |
| 33 | |
| 34 | // Interface (our AIDL) - Shared by server and client |
| 35 | class IAAudioService : public IInterface { |
| 36 | public: |
| 37 | |
| 38 | DECLARE_META_INTERFACE(AAudioService); |
| 39 | |
Phil Burk | 3df348f | 2017-02-08 11:41:55 -0800 | [diff] [blame] | 40 | /** |
| 41 | * @param request info needed to create the stream |
| 42 | * @param configuration contains information about the created stream |
| 43 | * @return handle to the stream or a negative error |
| 44 | */ |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 45 | virtual aaudio::aaudio_handle_t openStream(aaudio::AAudioStreamRequest &request, |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 46 | aaudio::AAudioStreamConfiguration &configuration) = 0; |
| 47 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 48 | virtual aaudio_result_t closeStream(aaudio::aaudio_handle_t streamHandle) = 0; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 49 | |
| 50 | /* Get an immutable description of the in-memory queues |
| 51 | * used to communicate with the underlying HAL or Service. |
| 52 | */ |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 53 | virtual aaudio_result_t getStreamDescription(aaudio::aaudio_handle_t streamHandle, |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 54 | aaudio::AudioEndpointParcelable &parcelable) = 0; |
| 55 | |
| 56 | /** |
| 57 | * Start the flow of data. |
| 58 | */ |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 59 | virtual aaudio_result_t startStream(aaudio::aaudio_handle_t streamHandle) = 0; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 60 | |
| 61 | /** |
| 62 | * Stop the flow of data such that start() can resume without loss of data. |
| 63 | */ |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 64 | virtual aaudio_result_t pauseStream(aaudio::aaudio_handle_t streamHandle) = 0; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 65 | |
| 66 | /** |
| 67 | * Discard any data held by the underlying HAL or Service. |
| 68 | */ |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 69 | virtual aaudio_result_t flushStream(aaudio::aaudio_handle_t streamHandle) = 0; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 70 | |
| 71 | /** |
| 72 | * Manage the specified thread as a low latency audio thread. |
| 73 | */ |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 74 | virtual aaudio_result_t registerAudioThread(aaudio::aaudio_handle_t streamHandle, pid_t clientThreadId, |
| 75 | int64_t periodNanoseconds) = 0; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 76 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 77 | virtual aaudio_result_t unregisterAudioThread(aaudio::aaudio_handle_t streamHandle, |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 78 | pid_t clientThreadId) = 0; |
| 79 | }; |
| 80 | |
| 81 | class BnAAudioService : public BnInterface<IAAudioService> { |
| 82 | public: |
| 83 | virtual status_t onTransact(uint32_t code, const Parcel& data, |
| 84 | Parcel* reply, uint32_t flags = 0); |
| 85 | |
| 86 | }; |
| 87 | |
| 88 | } /* namespace android */ |
| 89 | |
| 90 | #endif //BINDING_IAAUDIOSERVICE_H |