1 /*
2  * Copyright (C) 2008 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 #include <stdint.h>
18 
19 /*
20  * The following definitions are copied from the android sources. Only the
21  * relevant enum member and values needed are copied.
22  */
23 
24 /*
25  * From https://android.googlesource.com/platform/frameworks/base/+/android-2.2.3_r2.1/include/utils/Errors.h
26  */
27 typedef int32_t status_t;
28 
29 /*
30  * From https://android.googlesource.com/platform/frameworks/base/+/android-2.2.3_r2.1/include/media/AudioTrack.h
31  */
32 struct Buffer {
33   uint32_t    flags;
34   int         channelCount;
35   int         format;
36   size_t      frameCount;
37   size_t      size;
38   union {
39     void*       raw;
40     short*      i16;
41     int8_t*     i8;
42   };
43 };
44 
45 enum event_type {
46   EVENT_MORE_DATA = 0,
47   EVENT_UNDERRUN = 1,
48   EVENT_LOOP_END = 2,
49   EVENT_MARKER = 3,
50   EVENT_NEW_POS = 4,
51   EVENT_BUFFER_END = 5
52 };
53 
54 /**
55  * From https://android.googlesource.com/platform/frameworks/base/+/android-2.2.3_r2.1/include/media/AudioSystem.h
56  * and
57  * https://android.googlesource.com/platform/system/core/+/android-4.2.2_r1/include/system/audio.h
58  */
59 
60 #define AUDIO_STREAM_TYPE_MUSIC 3
61 
62 enum {
63   AUDIO_CHANNEL_OUT_FRONT_LEFT_ICS  = 0x1,
64   AUDIO_CHANNEL_OUT_FRONT_RIGHT_ICS = 0x2,
65   AUDIO_CHANNEL_OUT_MONO_ICS     = AUDIO_CHANNEL_OUT_FRONT_LEFT_ICS,
66   AUDIO_CHANNEL_OUT_STEREO_ICS   = (AUDIO_CHANNEL_OUT_FRONT_LEFT_ICS | AUDIO_CHANNEL_OUT_FRONT_RIGHT_ICS)
67 } AudioTrack_ChannelMapping_ICS;
68 
69 enum {
70   AUDIO_CHANNEL_OUT_FRONT_LEFT_Legacy = 0x4,
71   AUDIO_CHANNEL_OUT_FRONT_RIGHT_Legacy = 0x8,
72   AUDIO_CHANNEL_OUT_MONO_Legacy = AUDIO_CHANNEL_OUT_FRONT_LEFT_Legacy,
73   AUDIO_CHANNEL_OUT_STEREO_Legacy = (AUDIO_CHANNEL_OUT_FRONT_LEFT_Legacy | AUDIO_CHANNEL_OUT_FRONT_RIGHT_Legacy)
74 } AudioTrack_ChannelMapping_Legacy;
75 
76 typedef enum {
77   AUDIO_FORMAT_PCM = 0x00000000,
78   AUDIO_FORMAT_PCM_SUB_16_BIT = 0x1,
79   AUDIO_FORMAT_PCM_16_BIT = (AUDIO_FORMAT_PCM | AUDIO_FORMAT_PCM_SUB_16_BIT),
80 } AudioTrack_SampleType;
81 
82