blob: 91dc6a6da0ca04a34e6c185047e2e3e2248022a4 [file] [log] [blame]
Ytai Ben-Tsvi734e3502020-08-24 14:57:36 -07001/*
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
19#include <binding/IAAudioService.h>
20#include <binding/AAudioServiceInterface.h>
21
22namespace 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 */
31class AAudioBinderAdapter : public AAudioServiceInterface {
32public:
33 explicit AAudioBinderAdapter(android::IAAudioService* delegate);
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,
43 AudioEndpointParcelable& parcelable) override;
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
60private:
61 android::IAAudioService* const mDelegate;
62};
63
64} // namespace aaudio