AAudioServiceDefinitions.h revision 3316d5e6d375a4f09c681205e9094d30a0bfc4a2
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 473316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burktypedef int32_t aaudio_handle_t; 483316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk 493316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk#define AAUDIO_HANDLE_INVALID ((aaudio_handle_t) -1) 503316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk 515ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burkenum aaudio_commands_t { 52828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk OPEN_STREAM = IBinder::FIRST_CALL_TRANSACTION, 53828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk CLOSE_STREAM, 54828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk GET_STREAM_DESCRIPTION, 55828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk START_STREAM, 56828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk PAUSE_STREAM, 57828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk FLUSH_STREAM, 58828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk REGISTER_AUDIO_THREAD, 59dec33abe3739b2116ef6fbac36f7ca5d26f9d190Phil Burk UNREGISTER_AUDIO_THREAD 60828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk}; 61828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk 62828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// TODO Expand this to include all the open parameters. 635ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burktypedef struct AAudioServiceStreamInfo_s { 643316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk int32_t deviceId; 653316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk int32_t samplesPerFrame; // number of channels 663316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk int32_t sampleRate; 675ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk aaudio_audio_format_t audioFormat; 685ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} AAudioServiceStreamInfo; 69828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk 70828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// This must be a fixed width so it can be in shared memory. 71828bea5f61f3c40d24759cd8739dd95570883b56Phil Burkenum RingbufferFlags : uint32_t { 72828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk NONE = 0, 73828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk RATE_ISOCHRONOUS = 0x0001, 74828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk RATE_ASYNCHRONOUS = 0x0002, 75828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk COHERENCY_DMA = 0x0004, 76828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk COHERENCY_ACQUIRE_RELEASE = 0x0008, 77828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk COHERENCY_AUTO = 0x0010, 78828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk}; 79828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk 80828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// This is not passed through Binder. 81828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// Client side code will convert Binder data and fill this descriptor. 82828bea5f61f3c40d24759cd8739dd95570883b56Phil Burktypedef struct RingBufferDescriptor_s { 83828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk uint8_t* dataAddress; // offset from read or write block 84828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk int64_t* writeCounterAddress; 85828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk int64_t* readCounterAddress; 86828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk int32_t bytesPerFrame; // index is in frames 87828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk int32_t framesPerBurst; // for ISOCHRONOUS queues 88828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk int32_t capacityInFrames; // zero if unused 89828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk RingbufferFlags flags; 90828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk} RingBufferDescriptor; 91828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk 92828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// This is not passed through Binder. 93828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk// Client side code will convert Binder data and fill this descriptor. 94828bea5f61f3c40d24759cd8739dd95570883b56Phil Burktypedef struct EndpointDescriptor_s { 95828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk // Set capacityInFrames to zero if Queue is unused. 96828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk RingBufferDescriptor upMessageQueueDescriptor; // server to client 97828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk RingBufferDescriptor downMessageQueueDescriptor; // client to server 98828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk RingBufferDescriptor upDataQueueDescriptor; // eg. record 99828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk RingBufferDescriptor downDataQueueDescriptor; // eg. playback 100828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk} EndpointDescriptor; 101828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk 1025ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} // namespace aaudio 103828bea5f61f3c40d24759cd8739dd95570883b56Phil Burk 1045ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#endif //BINDING_AAUDIOSERVICEDEFINITIONS_H 105