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
175204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#ifndef ANDROID_AAUDIO_AAUDIO_SERVICE_MESSAGE_H
185204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#define ANDROID_AAUDIO_AAUDIO_SERVICE_MESSAGE_H
19204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
20204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk#include <stdint.h>
21204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
22a4eb0d86a29be2763be5fac51727858d5095794bPhil Burk#include <aaudio/AAudio.h>
23204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
245ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burknamespace aaudio {
25204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
263316d5e6d375a4f09c681205e9094d30a0bfc4a2Phil Burk// TODO move this to an "include" folder for the service.
27204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
28c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk// Used to send information about the HAL to the client.
295ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burkstruct AAudioMessageTimestamp {
30c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    int64_t position;     // number of frames transferred so far
31c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    int64_t deviceOffset; // add to client position to get device position
32c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    int64_t timestamp;    // time when that position was reached
33204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk};
34204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
355ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burktypedef enum aaudio_service_event_e : uint32_t {
365ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAUDIO_SERVICE_EVENT_STARTED,
375ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAUDIO_SERVICE_EVENT_PAUSED,
3871f35bb687476694882a617ba4a810a0bb56fe23Phil Burk    AAUDIO_SERVICE_EVENT_STOPPED,
395ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAUDIO_SERVICE_EVENT_FLUSHED,
405ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    AAUDIO_SERVICE_EVENT_CLOSED,
41c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    AAUDIO_SERVICE_EVENT_DISCONNECTED,
42c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    AAUDIO_SERVICE_EVENT_VOLUME
435ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} aaudio_service_event_t;
44204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
455ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burkstruct AAudioMessageEvent {
465ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk    aaudio_service_event_t event;
47c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    double                 dataDouble;
48c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk    int64_t                dataLong;
49204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk};
50204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
515ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burktypedef struct AAudioServiceMessage_s {
52204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    enum class code : uint32_t {
53204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk        NOTHING,
54204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk        TIMESTAMP,
55204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk        EVENT,
56204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    };
57204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
58204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    code what;
59204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    union {
60c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk        AAudioMessageTimestamp timestamp; // what == TIMESTAMP
61c0c70e3c7dd10bc2c0caffcab1f3f5fb406b35fbPhil Burk        AAudioMessageEvent event;         // what == EVENT
62204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk    };
635ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} AAudioServiceMessage;
64204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
655ed503c7a66c90f93759c90237a9b432dbd93f9fPhil Burk} /* namespace aaudio */
66204a163c86f357a878873fe7d4c4164f3d55c9b6Phil Burk
675204d315c6c6f53188f8d1414dd1b55b6c90142bPhil Burk#endif //ANDROID_AAUDIO_AAUDIO_SERVICE_MESSAGE_H
68