blob: b74b6c2d4508f9eb9712e1f13456fdd8768cebc5 [file] [log] [blame]
Phil Burk5ed503c2017-02-01 09:38:15 -08001/*
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
Phil Burk3316d5e2017-02-15 11:23:01 -080026// TODO move this to an "include" folder for the service.
Phil Burk5ed503c2017-02-01 09:38:15 -080027
Phil Burkc0c70e32017-02-09 13:18:38 -080028// Used to send information about the HAL to the client.
Phil Burk5ed503c2017-02-01 09:38:15 -080029struct AAudioMessageTimestamp {
Phil Burkc0c70e32017-02-09 13:18:38 -080030 int64_t position; // number of frames transferred so far
31 int64_t deviceOffset; // add to client position to get device position
32 int64_t timestamp; // time when that position was reached
Phil Burk5ed503c2017-02-01 09:38:15 -080033};
34
35typedef enum aaudio_service_event_e : uint32_t {
36 AAUDIO_SERVICE_EVENT_STARTED,
37 AAUDIO_SERVICE_EVENT_PAUSED,
38 AAUDIO_SERVICE_EVENT_FLUSHED,
39 AAUDIO_SERVICE_EVENT_CLOSED,
Phil Burkc0c70e32017-02-09 13:18:38 -080040 AAUDIO_SERVICE_EVENT_DISCONNECTED,
41 AAUDIO_SERVICE_EVENT_VOLUME
Phil Burk5ed503c2017-02-01 09:38:15 -080042} aaudio_service_event_t;
43
44struct AAudioMessageEvent {
45 aaudio_service_event_t event;
Phil Burkc0c70e32017-02-09 13:18:38 -080046 double dataDouble;
47 int64_t dataLong;
Phil Burk5ed503c2017-02-01 09:38:15 -080048};
49
50typedef struct AAudioServiceMessage_s {
51 enum class code : uint32_t {
52 NOTHING,
53 TIMESTAMP,
54 EVENT,
55 };
56
57 code what;
58 union {
Phil Burkc0c70e32017-02-09 13:18:38 -080059 AAudioMessageTimestamp timestamp; // what == TIMESTAMP
60 AAudioMessageEvent event; // what == EVENT
Phil Burk5ed503c2017-02-01 09:38:15 -080061 };
62} AAudioServiceMessage;
63
Phil Burk5ed503c2017-02-01 09:38:15 -080064} /* namespace aaudio */
65
66#endif //AAUDIO_AAUDIO_SERVICE_MESSAGE_H