AAudioServiceDefinitions.h revision c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fb
1/* 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 17#ifndef BINDING_AAUDIOSERVICEDEFINITIONS_H 18#define BINDING_AAUDIOSERVICEDEFINITIONS_H 19 20#include <stdint.h> 21#include <utils/RefBase.h> 22#include <binder/TextOutput.h> 23#include <binder/IInterface.h> 24 25#include <aaudio/AAudio.h> 26 27using android::NO_ERROR; 28using android::IBinder; 29 30namespace android { 31 32enum aaudio_commands_t { 33 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, 40 UNREGISTER_AUDIO_THREAD 41}; 42 43} // namespace android 44 45namespace aaudio { 46 47typedef int32_t aaudio_handle_t; 48 49#define AAUDIO_HANDLE_INVALID ((aaudio_handle_t) -1) 50 51// This must be a fixed width so it can be in shared memory. 52enum RingbufferFlags : uint32_t { 53 NONE = 0, 54 RATE_ISOCHRONOUS = 0x0001, 55 RATE_ASYNCHRONOUS = 0x0002, 56 COHERENCY_DMA = 0x0004, 57 COHERENCY_ACQUIRE_RELEASE = 0x0008, 58 COHERENCY_AUTO = 0x0010, 59}; 60 61// This is not passed through Binder. 62// Client side code will convert Binder data and fill this descriptor. 63typedef struct RingBufferDescriptor_s { 64 uint8_t* dataAddress; // offset from read or write block 65 int64_t* writeCounterAddress; 66 int64_t* readCounterAddress; 67 int32_t bytesPerFrame; // index is in frames 68 int32_t framesPerBurst; // for ISOCHRONOUS queues 69 int32_t capacityInFrames; // zero if unused 70 RingbufferFlags flags; 71} RingBufferDescriptor; 72 73// This is not passed through Binder. 74// Client side code will convert Binder data and fill this descriptor. 75typedef struct EndpointDescriptor_s { 76 // Set capacityInFrames to zero if Queue is unused. 77 RingBufferDescriptor upMessageQueueDescriptor; // server to client 78 RingBufferDescriptor downMessageQueueDescriptor; // client to server 79 RingBufferDescriptor upDataQueueDescriptor; // eg. record 80 RingBufferDescriptor downDataQueueDescriptor; // eg. playback 81} EndpointDescriptor; 82 83} // namespace aaudio 84 85#endif //BINDING_AAUDIOSERVICEDEFINITIONS_H 86