AAudioServiceMessage.h revision 3316d5e6d375a4f09c681205e9094d30a0bfc4a2
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 AAUDIO_AAUDIO_SERVICE_MESSAGE_H
18#define AAUDIO_AAUDIO_SERVICE_MESSAGE_H
19
20#include <stdint.h>
21
22#include <aaudio/AAudioDefinitions.h>
23
24namespace aaudio {
25
26// TODO move this to an "include" folder for the service.
27
28struct AAudioMessageTimestamp {
29    int64_t    position;
30    int64_t    deviceOffset; // add to client position to get device position
31    int64_t    timestamp;
32};
33
34typedef enum aaudio_service_event_e : uint32_t {
35    AAUDIO_SERVICE_EVENT_STARTED,
36    AAUDIO_SERVICE_EVENT_PAUSED,
37    AAUDIO_SERVICE_EVENT_FLUSHED,
38    AAUDIO_SERVICE_EVENT_CLOSED,
39    AAUDIO_SERVICE_EVENT_DISCONNECTED
40} aaudio_service_event_t;
41
42struct AAudioMessageEvent {
43    aaudio_service_event_t event;
44    int32_t                data1;
45    int64_t                data2;
46};
47
48typedef struct AAudioServiceMessage_s {
49    enum class code : uint32_t {
50        NOTHING,
51        TIMESTAMP,
52        EVENT,
53    };
54
55    code what;
56    union {
57        AAudioMessageTimestamp timestamp;
58        AAudioMessageEvent event;
59    };
60} AAudioServiceMessage;
61
62
63} /* namespace aaudio */
64
65#endif //AAUDIO_AAUDIO_SERVICE_MESSAGE_H
66