• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 ANDROID_AAUDIO_AAUDIO_SERVICE_MESSAGE_H
18 #define ANDROID_AAUDIO_AAUDIO_SERVICE_MESSAGE_H
19 
20 #include <stdint.h>
21 
22 #include <aaudio/AAudio.h>
23 
24 namespace aaudio {
25 
26 // TODO move this to an "include" folder for the service.
27 
28 // Used to send information about the HAL to the client.
29 struct AAudioMessageTimestamp {
30     int64_t position;     // number of frames transferred so far
31     int64_t timestamp;    // time when that position was reached
32 };
33 
34 typedef enum aaudio_service_event_e : uint32_t {
35     AAUDIO_SERVICE_EVENT_STARTED,
36     AAUDIO_SERVICE_EVENT_PAUSED,
37     AAUDIO_SERVICE_EVENT_STOPPED,
38     AAUDIO_SERVICE_EVENT_FLUSHED,
39     AAUDIO_SERVICE_EVENT_DISCONNECTED,
40     AAUDIO_SERVICE_EVENT_VOLUME,
41     AAUDIO_SERVICE_EVENT_XRUN
42 } aaudio_service_event_t;
43 
44 struct AAudioMessageEvent {
45     aaudio_service_event_t event;
46     union {
47         double  dataDouble;
48         int64_t dataLong;
49     };
50 };
51 
52 typedef struct AAudioServiceMessage_s {
53     enum class code : uint32_t {
54         NOTHING,
55         TIMESTAMP_SERVICE, // when frame is read or written by the service to the client
56         TIMESTAMP_HARDWARE, // when frame is at DAC or ADC
57         EVENT,
58     };
59 
60     code what;
61     union {
62         AAudioMessageTimestamp timestamp; // what == TIMESTAMP
63         AAudioMessageEvent event;         // what == EVENT
64     };
65 } AAudioServiceMessage;
66 
67 } /* namespace aaudio */
68 
69 #endif //ANDROID_AAUDIO_AAUDIO_SERVICE_MESSAGE_H
70