AAudioServiceDefinitions.h revision 5ed503c7a66c90f93759c90237a9b432dbd93f9f
1828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk/*
2828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Copyright (C) 2016 The Android Open Source Project
3828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *
4828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Licensed under the Apache License, Version 2.0 (the "License");
5828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * you may not use this file except in compliance with the License.
6828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * You may obtain a copy of the License at
7828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *
8828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *      http://www.apache.org/licenses/LICENSE-2.0
9828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk *
10828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * Unless required by applicable law or agreed to in writing, software
11828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * distributed under the License is distributed on an "AS IS" BASIS,
12828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * See the License for the specific language governing permissions and
14828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk * limitations under the License.
15828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk */
16828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
175ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#ifndef BINDING_AAUDIOSERVICEDEFINITIONS_H
185ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#define BINDING_AAUDIOSERVICEDEFINITIONS_H
19828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
20828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <stdint.h>
21828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <utils/RefBase.h>
22828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <binder/TextOutput.h>
23828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk#include <binder/IInterface.h>
24828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
255ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#include <aaudio/AAudio.h>
26828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
27828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::NO_ERROR;
28828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkusing android::IBinder;
29828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
30204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burknamespace android {
31204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
325ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burkenum aaudio_commands_t {
33204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    OPEN_STREAM = IBinder::FIRST_CALL_TRANSACTION,
34204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    CLOSE_STREAM,
35204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    GET_STREAM_DESCRIPTION,
36204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    START_STREAM,
37204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    PAUSE_STREAM,
38204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    FLUSH_STREAM,
39204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    REGISTER_AUDIO_THREAD,
40dec33abe3739b2116ef6fbac36f7ca5d26f9d190Phil Burk    UNREGISTER_AUDIO_THREAD
41204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk};
42204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
43204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk} // namespace android
44204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
455ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burknamespace aaudio {
46828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
475ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burkenum aaudio_commands_t {
48828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    OPEN_STREAM = IBinder::FIRST_CALL_TRANSACTION,
49828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    CLOSE_STREAM,
50828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    GET_STREAM_DESCRIPTION,
51828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    START_STREAM,
52828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    PAUSE_STREAM,
53828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    FLUSH_STREAM,
54828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    REGISTER_AUDIO_THREAD,
55dec33abe3739b2116ef6fbac36f7ca5d26f9d190Phil Burk    UNREGISTER_AUDIO_THREAD
56828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk};
57828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
58828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// TODO Expand this to include all the open parameters.
595ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burktypedef struct AAudioServiceStreamInfo_s {
60828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t             deviceId;
61828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t             samplesPerFrame;  // number of channels
625ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    aaudio_sample_rate_t  sampleRate;
635ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    aaudio_audio_format_t audioFormat;
645ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} AAudioServiceStreamInfo;
65828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
66828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// This must be a fixed width so it can be in shared memory.
67828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkenum RingbufferFlags : uint32_t {
68828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    NONE = 0,
69828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RATE_ISOCHRONOUS = 0x0001,
70828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RATE_ASYNCHRONOUS = 0x0002,
71828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    COHERENCY_DMA = 0x0004,
72828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    COHERENCY_ACQUIRE_RELEASE = 0x0008,
73828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    COHERENCY_AUTO = 0x0010,
74828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk};
75828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
76828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// This is not passed through Binder.
77828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// Client side code will convert Binder data and fill this descriptor.
78828bea5f61f3c40d24759cd8739dd95570883b56Phil Burktypedef struct RingBufferDescriptor_s {
79828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    uint8_t* dataAddress;       // offset from read or write block
80828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int64_t* writeCounterAddress;
81828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int64_t* readCounterAddress;
82828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t  bytesPerFrame;     // index is in frames
83828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t  framesPerBurst;    // for ISOCHRONOUS queues
84828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t  capacityInFrames;  // zero if unused
85828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingbufferFlags flags;
86828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk} RingBufferDescriptor;
87828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
88828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// This is not passed through Binder.
89828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// Client side code will convert Binder data and fill this descriptor.
90828bea5f61f3c40d24759cd8739dd95570883b56Phil Burktypedef struct EndpointDescriptor_s {
91828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    // Set capacityInFrames to zero if Queue is unused.
92828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferDescriptor upMessageQueueDescriptor;   // server to client
93828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferDescriptor downMessageQueueDescriptor; // client to server
94828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferDescriptor upDataQueueDescriptor;      // eg. record
95828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferDescriptor downDataQueueDescriptor;    // eg. playback
96828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk} EndpointDescriptor;
97828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
985ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} // namespace aaudio
99828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
1005ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#endif //BINDING_AAUDIOSERVICEDEFINITIONS_H
101