blob: 72ed28145ae8056848ea7f01db4f2d3351e5b3a5 [file] [log] [blame]
The Android Open Source Project2729ea92008-10-21 07:00:00 -07001/*
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{
The Android Open Source Project2729ea92008-10-21 07:00:00 -070034
The Android Open Source Project7b5eb022008-12-17 18:05:43 -080035 // The data members are grouped so that members accessed frequently and in the same context
36 // are in the same line of data cache.
The Android Open Source Project2729ea92008-10-21 07:00:00 -070037 Mutex lock;
38 Condition cv;
39 volatile uint32_t user;
40 volatile uint32_t server;
The Android Open Source Project7b5eb022008-12-17 18:05:43 -080041 uint32_t userBase;
42 uint32_t serverBase;
43 void* buffers;
44 uint32_t frameCount;
45 // Cache line boundary
46 uint32_t loopStart;
47 uint32_t loopEnd;
48 int loopCount;
The Android Open Source Project2729ea92008-10-21 07:00:00 -070049 volatile union {
50 uint16_t volume[2];
51 uint32_t volumeLR;
52 };
53 uint16_t sampleRate;
The Android Open Source Project7b5eb022008-12-17 18:05:43 -080054 uint16_t channels;
55 int16_t flowControlFlag; // underrun (out) or overrrun (in) indication
56 uint8_t out; // out equals 1 for AudioTrack and 0 for AudioRecord
57 uint8_t forceReady;
58 // Padding ensuring that data buffer starts on a cache line boundary (32 bytes).
59 // See AudioFlinger::TrackBase constructor
60 int32_t Padding[4];
61
The Android Open Source Project2729ea92008-10-21 07:00:00 -070062 audio_track_cblk_t();
The Android Open Source Project7b5eb022008-12-17 18:05:43 -080063 uint32_t stepUser(uint32_t frameCount);
64 bool stepServer(uint32_t frameCount);
65 void* buffer(uint32_t offset) const;
66 uint32_t framesAvailable();
67 uint32_t framesAvailable_l();
68 uint32_t framesReady();
The Android Open Source Project2729ea92008-10-21 07:00:00 -070069};
70
71
72// ----------------------------------------------------------------------------
73
74}; // namespace android
75
76#endif // ANDROID_AUDIO_TRACK_SHARED_H