Phil Burk | 5ed503c | 2017-02-01 09:38:15 -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 | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 17 | #ifndef ANDROID_AAUDIO_AAUDIO_SERVICE_MESSAGE_H |
| 18 | #define ANDROID_AAUDIO_AAUDIO_SERVICE_MESSAGE_H |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 19 | |
| 20 | #include <stdint.h> |
| 21 | |
Phil Burk | a4eb0d8 | 2017-04-12 15:44:06 -0700 | [diff] [blame] | 22 | #include <aaudio/AAudio.h> |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 23 | |
| 24 | namespace aaudio { |
| 25 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 26 | // TODO move this to an "include" folder for the service. |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 27 | |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 28 | // Used to send information about the HAL to the client. |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 29 | struct AAudioMessageTimestamp { |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 30 | int64_t position; // number of frames transferred so far |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 31 | int64_t timestamp; // time when that position was reached |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | typedef enum aaudio_service_event_e : uint32_t { |
| 35 | AAUDIO_SERVICE_EVENT_STARTED, |
| 36 | AAUDIO_SERVICE_EVENT_PAUSED, |
Phil Burk | 71f35bb | 2017-04-13 16:05:07 -0700 | [diff] [blame] | 37 | AAUDIO_SERVICE_EVENT_STOPPED, |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 38 | AAUDIO_SERVICE_EVENT_FLUSHED, |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 39 | AAUDIO_SERVICE_EVENT_DISCONNECTED, |
Phil Burk | 2329638 | 2017-11-20 15:45:11 -0800 | [diff] [blame] | 40 | AAUDIO_SERVICE_EVENT_VOLUME, |
| 41 | AAUDIO_SERVICE_EVENT_XRUN |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 42 | } aaudio_service_event_t; |
| 43 | |
| 44 | struct AAudioMessageEvent { |
| 45 | aaudio_service_event_t event; |
Phil Burk | 2329638 | 2017-11-20 15:45:11 -0800 | [diff] [blame] | 46 | union { |
Phil Burk | 3ee519e | 2020-05-06 16:56:22 -0700 | [diff] [blame] | 47 | // Align so that 32 and 64-bit code can exchange messages through shared memory. |
| 48 | alignas(8) |
Phil Burk | 2329638 | 2017-11-20 15:45:11 -0800 | [diff] [blame] | 49 | double dataDouble; |
| 50 | int64_t dataLong; |
| 51 | }; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 52 | }; |
| 53 | |
| 54 | typedef struct AAudioServiceMessage_s { |
| 55 | enum class code : uint32_t { |
| 56 | NOTHING, |
Phil Burk | 97350f9 | 2017-07-21 15:59:44 -0700 | [diff] [blame] | 57 | TIMESTAMP_SERVICE, // when frame is read or written by the service to the client |
| 58 | TIMESTAMP_HARDWARE, // when frame is at DAC or ADC |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 59 | EVENT, |
| 60 | }; |
| 61 | |
Phil Burk | 3ee519e | 2020-05-06 16:56:22 -0700 | [diff] [blame] | 62 | code what; |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 63 | union { |
Phil Burk | 3ee519e | 2020-05-06 16:56:22 -0700 | [diff] [blame] | 64 | // Align so that 32 and 64-bit code can exchange messages through shared memory. |
| 65 | alignas(8) |
Phil Burk | c0c70e3 | 2017-02-09 13:18:38 -0800 | [diff] [blame] | 66 | AAudioMessageTimestamp timestamp; // what == TIMESTAMP |
| 67 | AAudioMessageEvent event; // what == EVENT |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 68 | }; |
| 69 | } AAudioServiceMessage; |
| 70 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 71 | } /* namespace aaudio */ |
| 72 | |
Phil Burk | 5204d31 | 2017-05-04 17:16:13 -0700 | [diff] [blame] | 73 | #endif //ANDROID_AAUDIO_AAUDIO_SERVICE_MESSAGE_H |