Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 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 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 17 | #ifndef BINDING_AAUDIOSERVICEDEFINITIONS_H |
| 18 | #define BINDING_AAUDIOSERVICEDEFINITIONS_H |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | #include <utils/RefBase.h> |
| 22 | #include <binder/TextOutput.h> |
| 23 | #include <binder/IInterface.h> |
| 24 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 25 | #include <aaudio/AAudio.h> |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 26 | |
| 27 | using android::NO_ERROR; |
| 28 | using android::IBinder; |
| 29 | |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 30 | namespace android { |
| 31 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 32 | enum aaudio_commands_t { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 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, |
Phil Burk | dec33ab | 2017-01-17 14:48:16 -0800 | [diff] [blame] | 40 | UNREGISTER_AUDIO_THREAD |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 41 | }; |
| 42 | |
| 43 | } // namespace android |
| 44 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 45 | namespace aaudio { |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 46 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 47 | typedef int32_t aaudio_handle_t; |
| 48 | |
| 49 | #define AAUDIO_HANDLE_INVALID ((aaudio_handle_t) -1) |
| 50 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 51 | enum aaudio_commands_t { |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 52 | OPEN_STREAM = IBinder::FIRST_CALL_TRANSACTION, |
| 53 | CLOSE_STREAM, |
| 54 | GET_STREAM_DESCRIPTION, |
| 55 | START_STREAM, |
| 56 | PAUSE_STREAM, |
| 57 | FLUSH_STREAM, |
| 58 | REGISTER_AUDIO_THREAD, |
Phil Burk | dec33ab | 2017-01-17 14:48:16 -0800 | [diff] [blame] | 59 | UNREGISTER_AUDIO_THREAD |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 60 | }; |
| 61 | |
| 62 | // TODO Expand this to include all the open parameters. |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 63 | typedef struct AAudioServiceStreamInfo_s { |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame^] | 64 | int32_t deviceId; |
| 65 | int32_t samplesPerFrame; // number of channels |
| 66 | int32_t sampleRate; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 67 | aaudio_audio_format_t audioFormat; |
| 68 | } AAudioServiceStreamInfo; |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 69 | |
| 70 | // This must be a fixed width so it can be in shared memory. |
| 71 | enum RingbufferFlags : uint32_t { |
| 72 | NONE = 0, |
| 73 | RATE_ISOCHRONOUS = 0x0001, |
| 74 | RATE_ASYNCHRONOUS = 0x0002, |
| 75 | COHERENCY_DMA = 0x0004, |
| 76 | COHERENCY_ACQUIRE_RELEASE = 0x0008, |
| 77 | COHERENCY_AUTO = 0x0010, |
| 78 | }; |
| 79 | |
| 80 | // This is not passed through Binder. |
| 81 | // Client side code will convert Binder data and fill this descriptor. |
| 82 | typedef struct RingBufferDescriptor_s { |
| 83 | uint8_t* dataAddress; // offset from read or write block |
| 84 | int64_t* writeCounterAddress; |
| 85 | int64_t* readCounterAddress; |
| 86 | int32_t bytesPerFrame; // index is in frames |
| 87 | int32_t framesPerBurst; // for ISOCHRONOUS queues |
| 88 | int32_t capacityInFrames; // zero if unused |
| 89 | RingbufferFlags flags; |
| 90 | } RingBufferDescriptor; |
| 91 | |
| 92 | // This is not passed through Binder. |
| 93 | // Client side code will convert Binder data and fill this descriptor. |
| 94 | typedef struct EndpointDescriptor_s { |
| 95 | // Set capacityInFrames to zero if Queue is unused. |
| 96 | RingBufferDescriptor upMessageQueueDescriptor; // server to client |
| 97 | RingBufferDescriptor downMessageQueueDescriptor; // client to server |
| 98 | RingBufferDescriptor upDataQueueDescriptor; // eg. record |
| 99 | RingBufferDescriptor downDataQueueDescriptor; // eg. playback |
| 100 | } EndpointDescriptor; |
| 101 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 102 | } // namespace aaudio |
Phil Burk | 828bea5 | 2017-01-03 17:22:09 -0800 | [diff] [blame] | 103 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 104 | #endif //BINDING_AAUDIOSERVICEDEFINITIONS_H |