Ytai Ben-Tsvi | 734e350 | 2020-08-24 14:57:36 -0700 | [diff] [blame] | 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 | #pragma once |
| 18 | |
Ytai Ben-Tsvi | c5f4587 | 2020-08-18 10:39:44 -0700 | [diff] [blame] | 19 | #include <aaudio/IAAudioService.h> |
Ytai Ben-Tsvi | 734e350 | 2020-08-24 14:57:36 -0700 | [diff] [blame] | 20 | #include <binding/AAudioServiceInterface.h> |
| 21 | |
| 22 | namespace aaudio { |
| 23 | |
| 24 | /** |
| 25 | * An adapter that takes in an underlying IAAudioService and exposes an |
| 26 | * AAudioServiceInterface. |
| 27 | * |
| 28 | * This class is abstract: the client is expected to inherit from this class and implement those |
| 29 | * methods from AAudioServiceInterface that don't have counterparts in IAAudioService. |
| 30 | */ |
| 31 | class AAudioBinderAdapter : public AAudioServiceInterface { |
| 32 | public: |
Ytai Ben-Tsvi | c5f4587 | 2020-08-18 10:39:44 -0700 | [diff] [blame] | 33 | explicit AAudioBinderAdapter(IAAudioService* delegate); |
Ytai Ben-Tsvi | 734e350 | 2020-08-24 14:57:36 -0700 | [diff] [blame] | 34 | |
| 35 | void registerClient(const android::sp<IAAudioClient>& client) override; |
| 36 | |
| 37 | aaudio_handle_t openStream(const AAudioStreamRequest& request, |
| 38 | AAudioStreamConfiguration& configuration) override; |
| 39 | |
| 40 | aaudio_result_t closeStream(aaudio_handle_t streamHandle) override; |
| 41 | |
| 42 | aaudio_result_t getStreamDescription(aaudio_handle_t streamHandle, |
Ytai Ben-Tsvi | c5f4587 | 2020-08-18 10:39:44 -0700 | [diff] [blame] | 43 | AudioEndpointParcelable& endpoint) override; |
Ytai Ben-Tsvi | 734e350 | 2020-08-24 14:57:36 -0700 | [diff] [blame] | 44 | |
| 45 | aaudio_result_t startStream(aaudio_handle_t streamHandle) override; |
| 46 | |
| 47 | aaudio_result_t pauseStream(aaudio_handle_t streamHandle) override; |
| 48 | |
| 49 | aaudio_result_t stopStream(aaudio_handle_t streamHandle) override; |
| 50 | |
| 51 | aaudio_result_t flushStream(aaudio_handle_t streamHandle) override; |
| 52 | |
| 53 | aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle, |
| 54 | pid_t clientThreadId, |
| 55 | int64_t periodNanoseconds) override; |
| 56 | |
| 57 | aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle, |
| 58 | pid_t clientThreadId) override; |
| 59 | |
| 60 | private: |
Ytai Ben-Tsvi | c5f4587 | 2020-08-18 10:39:44 -0700 | [diff] [blame] | 61 | IAAudioService* const mDelegate; |
Ytai Ben-Tsvi | 734e350 | 2020-08-24 14:57:36 -0700 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | } // namespace aaudio |