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,
3871f35bb687476694882a617ba4a810a0bb56fe23Phil Burk    STOP_STREAM,
39204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    FLUSH_STREAM,
40204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    REGISTER_AUDIO_THREAD,
41dec33abe3739b2116ef6fbac36f7ca5d26f9d190Phil Burk    UNREGISTER_AUDIO_THREAD
42204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk};
43204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
44204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk} // namespace android
45204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
465ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burknamespace aaudio {
47828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
483316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burktypedef int32_t  aaudio_handle_t;
493316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk
503316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk#define AAUDIO_HANDLE_INVALID  ((aaudio_handle_t) -1)
513316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk
52828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// This must be a fixed width so it can be in shared memory.
53828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkenum RingbufferFlags : uint32_t {
54828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    NONE = 0,
55828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RATE_ISOCHRONOUS = 0x0001,
56828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RATE_ASYNCHRONOUS = 0x0002,
57828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    COHERENCY_DMA = 0x0004,
58828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    COHERENCY_ACQUIRE_RELEASE = 0x0008,
59828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    COHERENCY_AUTO = 0x0010,
60828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk};
61828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
62828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// This is not passed through Binder.
63828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// Client side code will convert Binder data and fill this descriptor.
64828bea5f61f3c40d24759cd8739dd95570883b56Phil Burktypedef struct RingBufferDescriptor_s {
65828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    uint8_t* dataAddress;       // offset from read or write block
66828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int64_t* writeCounterAddress;
67828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int64_t* readCounterAddress;
68828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t  bytesPerFrame;     // index is in frames
69828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t  framesPerBurst;    // for ISOCHRONOUS queues
70828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    int32_t  capacityInFrames;  // zero if unused
71828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingbufferFlags flags;
72828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk} RingBufferDescriptor;
73828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
74828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// This is not passed through Binder.
75828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// Client side code will convert Binder data and fill this descriptor.
76828bea5f61f3c40d24759cd8739dd95570883b56Phil Burktypedef struct EndpointDescriptor_s {
77828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    // Set capacityInFrames to zero if Queue is unused.
78828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferDescriptor upMessageQueueDescriptor;   // server to client
79828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk    RingBufferDescriptor downMessageQueueDescriptor; // client to server
8087c9f646a94259d7c321c3b3d5947fa1778f5ac2Phil Burk    RingBufferDescriptor dataQueueDescriptor;    // playback or capture
81828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk} EndpointDescriptor;
82828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
835ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} // namespace aaudio
84828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk
855ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#endif //BINDING_AAUDIOSERVICEDEFINITIONS_H
86