AAudioServiceMessage.h revision 204a163c86f357a878873fe7d4c4164f3d55c9b6
1204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk/*
2204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * Copyright (C) 2016 The Android Open Source Project
3204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk *
4204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * Licensed under the Apache License, Version 2.0 (the "License");
5204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * you may not use this file except in compliance with the License.
6204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * You may obtain a copy of the License at
7204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk *
8204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk *      http://www.apache.org/licenses/LICENSE-2.0
9204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk *
10204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * Unless required by applicable law or agreed to in writing, software
11204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * distributed under the License is distributed on an "AS IS" BASIS,
12204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * See the License for the specific language governing permissions and
14204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk * limitations under the License.
15204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk */
16204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
17204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#ifndef OBOE_OBOE_SERVICE_MESSAGE_H
18204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#define OBOE_OBOE_SERVICE_MESSAGE_H
19204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
20204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include <stdint.h>
21204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
22204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include <oboe/OboeDefinitions.h>
23204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
24204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burknamespace oboe {
25204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
26204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk// TODO move this an "include" folder for the service.
27204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
28204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkstruct OboeMessageTimestamp {
29204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    oboe_position_frames_t position;
30204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    int64_t                deviceOffset; // add to client position to get device position
31204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    oboe_nanoseconds_t     timestamp;
32204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk};
33204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
34204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burktypedef enum oboe_service_event_e : uint32_t {
35204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    OBOE_SERVICE_EVENT_STARTED,
36204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    OBOE_SERVICE_EVENT_PAUSED,
37204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    OBOE_SERVICE_EVENT_FLUSHED,
38204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    OBOE_SERVICE_EVENT_CLOSED,
39204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    OBOE_SERVICE_EVENT_DISCONNECTED
40204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk} oboe_service_event_t;
41204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
42204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burkstruct OboeMessageEvent {
43204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    oboe_service_event_t event;
44204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    int32_t data1;
45204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    int64_t data2;
46204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk};
47204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
48204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burktypedef struct OboeServiceMessage_s {
49204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    enum class code : uint32_t {
50204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk        NOTHING,
51204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk        TIMESTAMP,
52204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk        EVENT,
53204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    };
54204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
55204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    code what;
56204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    union {
57204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk        OboeMessageTimestamp timestamp;
58204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk        OboeMessageEvent event;
59204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    };
60204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk} OboeServiceMessage;
61204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
62204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
63204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk} /* namespace oboe */
64204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
65204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#endif //OBOE_OBOE_SERVICE_MESSAGE_H
66