blob: ca637efa18ee245baf7c2e83cb6c177dc55bb649 [file] [log] [blame]
Phil Burk828bea52017-01-03 17:22:09 -08001/*
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
Phil Burk5ed503c2017-02-01 09:38:15 -080017#ifndef BINDING_AAUDIOSERVICEDEFINITIONS_H
18#define BINDING_AAUDIOSERVICEDEFINITIONS_H
Phil Burk828bea52017-01-03 17:22:09 -080019
20#include <stdint.h>
21#include <utils/RefBase.h>
22#include <binder/TextOutput.h>
23#include <binder/IInterface.h>
24
Phil Burk5ed503c2017-02-01 09:38:15 -080025#include <aaudio/AAudio.h>
Phil Burk828bea52017-01-03 17:22:09 -080026
27using android::NO_ERROR;
28using android::IBinder;
29
Phil Burk204a1632017-01-03 17:23:43 -080030namespace android {
31
Phil Burk5ed503c2017-02-01 09:38:15 -080032enum aaudio_commands_t {
Phil Burk204a1632017-01-03 17:23:43 -080033 OPEN_STREAM = IBinder::FIRST_CALL_TRANSACTION,
34 CLOSE_STREAM,
35 GET_STREAM_DESCRIPTION,
36 START_STREAM,
37 PAUSE_STREAM,
38 FLUSH_STREAM,
39 REGISTER_AUDIO_THREAD,
Phil Burkdec33ab2017-01-17 14:48:16 -080040 UNREGISTER_AUDIO_THREAD
Phil Burk204a1632017-01-03 17:23:43 -080041};
42
43} // namespace android
44
Phil Burk5ed503c2017-02-01 09:38:15 -080045namespace aaudio {
Phil Burk828bea52017-01-03 17:22:09 -080046
Phil Burk5ed503c2017-02-01 09:38:15 -080047enum aaudio_commands_t {
Phil Burk828bea52017-01-03 17:22:09 -080048 OPEN_STREAM = IBinder::FIRST_CALL_TRANSACTION,
49 CLOSE_STREAM,
50 GET_STREAM_DESCRIPTION,
51 START_STREAM,
52 PAUSE_STREAM,
53 FLUSH_STREAM,
54 REGISTER_AUDIO_THREAD,
Phil Burkdec33ab2017-01-17 14:48:16 -080055 UNREGISTER_AUDIO_THREAD
Phil Burk828bea52017-01-03 17:22:09 -080056};
57
58// TODO Expand this to include all the open parameters.
Phil Burk5ed503c2017-02-01 09:38:15 -080059typedef struct AAudioServiceStreamInfo_s {
Phil Burk828bea52017-01-03 17:22:09 -080060 int32_t deviceId;
61 int32_t samplesPerFrame; // number of channels
Phil Burk5ed503c2017-02-01 09:38:15 -080062 aaudio_sample_rate_t sampleRate;
63 aaudio_audio_format_t audioFormat;
64} AAudioServiceStreamInfo;
Phil Burk828bea52017-01-03 17:22:09 -080065
66// This must be a fixed width so it can be in shared memory.
67enum RingbufferFlags : uint32_t {
68 NONE = 0,
69 RATE_ISOCHRONOUS = 0x0001,
70 RATE_ASYNCHRONOUS = 0x0002,
71 COHERENCY_DMA = 0x0004,
72 COHERENCY_ACQUIRE_RELEASE = 0x0008,
73 COHERENCY_AUTO = 0x0010,
74};
75
76// This is not passed through Binder.
77// Client side code will convert Binder data and fill this descriptor.
78typedef struct RingBufferDescriptor_s {
79 uint8_t* dataAddress; // offset from read or write block
80 int64_t* writeCounterAddress;
81 int64_t* readCounterAddress;
82 int32_t bytesPerFrame; // index is in frames
83 int32_t framesPerBurst; // for ISOCHRONOUS queues
84 int32_t capacityInFrames; // zero if unused
85 RingbufferFlags flags;
86} RingBufferDescriptor;
87
88// This is not passed through Binder.
89// Client side code will convert Binder data and fill this descriptor.
90typedef struct EndpointDescriptor_s {
91 // Set capacityInFrames to zero if Queue is unused.
92 RingBufferDescriptor upMessageQueueDescriptor; // server to client
93 RingBufferDescriptor downMessageQueueDescriptor; // client to server
94 RingBufferDescriptor upDataQueueDescriptor; // eg. record
95 RingBufferDescriptor downDataQueueDescriptor; // eg. playback
96} EndpointDescriptor;
97
Phil Burk5ed503c2017-02-01 09:38:15 -080098} // namespace aaudio
Phil Burk828bea52017-01-03 17:22:09 -080099
Phil Burk5ed503c2017-02-01 09:38:15 -0800100#endif //BINDING_AAUDIOSERVICEDEFINITIONS_H