blob: 5e9ab57f1ed7b62f4ac8fb0d44788419e71b3565 [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
Ytai Ben-Tsvic5f45872020-08-18 10:39:44 -070019#include <aaudio/IAAudioService.h>
Ytai Ben-Tsvi734e3502020-08-24 14:57:36 -070020#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:
Ytai Ben-Tsvic5f45872020-08-18 10:39:44 -070033 explicit AAudioBinderAdapter(IAAudioService* delegate);
Ytai Ben-Tsvi734e3502020-08-24 14:57:36 -070034
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-Tsvic5f45872020-08-18 10:39:44 -070043 AudioEndpointParcelable& endpoint) override;
Ytai Ben-Tsvi734e3502020-08-24 14:57:36 -070044
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:
Ytai Ben-Tsvic5f45872020-08-18 10:39:44 -070061 IAAudioService* const mDelegate;
Ytai Ben-Tsvi734e3502020-08-24 14:57:36 -070062};
63
64} // namespace aaudio