AAudioServiceMessage.h revision 3316d5e6d375a4f09c681205e9094d30a0bfc4a2
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
175ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#ifndef AAUDIO_AAUDIO_SERVICE_MESSAGE_H
185ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#define AAUDIO_AAUDIO_SERVICE_MESSAGE_H
19204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
20204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include <stdint.h>
21204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
225ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#include <aaudio/AAudioDefinitions.h>
23204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
245ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burknamespace aaudio {
25204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
263316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk// TODO move this to an "include" folder for the service.
27204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
285ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burkstruct AAudioMessageTimestamp {
293316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int64_t    position;
303316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int64_t    deviceOffset; // add to client position to get device position
313316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int64_t    timestamp;
32204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk};
33204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
345ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burktypedef enum aaudio_service_event_e : uint32_t {
355ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAUDIO_SERVICE_EVENT_STARTED,
365ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAUDIO_SERVICE_EVENT_PAUSED,
375ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAUDIO_SERVICE_EVENT_FLUSHED,
385ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAUDIO_SERVICE_EVENT_CLOSED,
395ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAUDIO_SERVICE_EVENT_DISCONNECTED
405ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} aaudio_service_event_t;
41204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
425ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burkstruct AAudioMessageEvent {
435ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    aaudio_service_event_t event;
443316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int32_t                data1;
453316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk    int64_t                data2;
46204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk};
47204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
485ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burktypedef struct AAudioServiceMessage_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 {
575ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk        AAudioMessageTimestamp timestamp;
585ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk        AAudioMessageEvent event;
59204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    };
605ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} AAudioServiceMessage;
61204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
62204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
635ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} /* namespace aaudio */
64204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
655ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk#endif //AAUDIO_AAUDIO_SERVICE_MESSAGE_H
66