blob: e223376847f7dcac61b298859d538ed6d6150729 [file] [log] [blame]
Phil Burkc0c70e32017-02-09 13:18:38 -08001/*
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
Phil Burk5204d312017-05-04 17:16:13 -070017#ifndef ANDROID_AAUDIO_AAUDIO_BINDER_CLIENT_H
18#define ANDROID_AAUDIO_AAUDIO_BINDER_CLIENT_H
Phil Burkc0c70e32017-02-09 13:18:38 -080019
Phil Burk9b3f8ef2017-05-16 11:37:43 -070020#include <utils/Singleton.h>
21
Phil Burka4eb0d82017-04-12 15:44:06 -070022#include <aaudio/AAudio.h>
Phil Burkc0c70e32017-02-09 13:18:38 -080023#include "AAudioServiceDefinitions.h"
24#include "AAudioServiceInterface.h"
25#include "binding/AAudioStreamRequest.h"
26#include "binding/AAudioStreamConfiguration.h"
27#include "binding/AudioEndpointParcelable.h"
28
29/**
30 * Implements the AAudioServiceInterface by talking to the actual service through Binder.
31 */
32
33namespace aaudio {
34
Phil Burk9b3f8ef2017-05-16 11:37:43 -070035class AAudioBinderClient : public AAudioServiceInterface
36 , public android::Singleton<AAudioBinderClient> {
Phil Burkc0c70e32017-02-09 13:18:38 -080037
38public:
39
40 AAudioBinderClient();
41
42 virtual ~AAudioBinderClient();
43
44 /**
45 * @param request info needed to create the stream
46 * @param configuration contains resulting information about the created stream
47 * @return handle to the stream or a negative error
48 */
49 aaudio_handle_t openStream(const AAudioStreamRequest &request,
50 AAudioStreamConfiguration &configurationOutput) override;
51
52 aaudio_result_t closeStream(aaudio_handle_t streamHandle) override;
53
54 /* Get an immutable description of the in-memory queues
55 * used to communicate with the underlying HAL or Service.
56 */
57 aaudio_result_t getStreamDescription(aaudio_handle_t streamHandle,
58 AudioEndpointParcelable &parcelable) override;
59
60 /**
61 * Start the flow of data.
62 * This is asynchronous. When complete, the service will send a STARTED event.
63 */
64 aaudio_result_t startStream(aaudio_handle_t streamHandle) override;
65
66 /**
67 * Stop the flow of data such that start() can resume without loss of data.
68 * This is asynchronous. When complete, the service will send a PAUSED event.
69 */
70 aaudio_result_t pauseStream(aaudio_handle_t streamHandle) override;
71
Phil Burk71f35bb2017-04-13 16:05:07 -070072 aaudio_result_t stopStream(aaudio_handle_t streamHandle) override;
73
Phil Burkc0c70e32017-02-09 13:18:38 -080074 /**
75 * Discard any data held by the underlying HAL or Service.
76 * This is asynchronous. When complete, the service will send a FLUSHED event.
77 */
78 aaudio_result_t flushStream(aaudio_handle_t streamHandle) override;
79
80 /**
81 * Manage the specified thread as a low latency audio thread.
82 * TODO Consider passing this information as part of the startStream() call.
83 */
84 aaudio_result_t registerAudioThread(aaudio_handle_t streamHandle,
85 pid_t clientProcessId,
86 pid_t clientThreadId,
87 int64_t periodNanoseconds) override;
88
89 aaudio_result_t unregisterAudioThread(aaudio_handle_t streamHandle,
90 pid_t clientProcessId,
91 pid_t clientThreadId) override;
92};
93
94
95} /* namespace aaudio */
96
Phil Burk5204d312017-05-04 17:16:13 -070097#endif //ANDROID_AAUDIO_AAUDIO_BINDER_CLIENT_H