AudioTrackShared.h revision 2729ea9262ca60d93047e984739887cfc89e82eb
1/*
2 * Copyright (C) 2007 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 ANDROID_AUDIO_TRACK_SHARED_H
18#define ANDROID_AUDIO_TRACK_SHARED_H
19
20#include <stdint.h>
21#include <sys/types.h>
22
23#include <utils/threads.h>
24
25namespace android {
26
27// ----------------------------------------------------------------------------
28
29#define MAX_SAMPLE_RATE     65535
30#define THREAD_PRIORITY_AUDIO_CLIENT (ANDROID_PRIORITY_AUDIO)
31
32struct audio_track_cblk_t
33{
34    enum {
35        SEQUENCE_MASK   = 0xFFFFFF00,
36        BUFFER_MASK     = 0x000000FF
37    };
38
39                Mutex       lock;
40                Condition   cv;
41    volatile    uint32_t    user;
42    volatile    uint32_t    server;
43    volatile    union {
44                    uint16_t    volume[2];
45                    uint32_t    volumeLR;
46                };
47                uint16_t    sampleRate;
48                uint16_t    reserved;
49
50                void*       buffers;
51                size_t      size;
52
53                            audio_track_cblk_t();
54                uint32_t    stepUser(int bufferCount);
55                bool        stepServer(int bufferCount);
56                void*       buffer(int id) const;
57};
58
59
60// ----------------------------------------------------------------------------
61
62}; // namespace android
63
64#endif // ANDROID_AUDIO_TRACK_SHARED_H
65