blob: b24f2eb4a4a6f392b05ce7ad5678d4375ae4b1cd [file] [log] [blame]
Glenn Kasten97b5d0d2012-03-23 18:54:19 -07001/*
2 * Copyright (C) 2012 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_FAST_MIXER_H
18#define ANDROID_AUDIO_FAST_MIXER_H
19
20#include <utils/Thread.h>
21extern "C" {
22#include "../private/bionic_futex.h"
23}
24#include "StateQueue.h"
25#include "FastMixerState.h"
26
27namespace android {
28
29typedef StateQueue<FastMixerState> FastMixerStateQueue;
30
31class FastMixer : public Thread {
32
33public:
34 FastMixer() : Thread(false /*canCallJava*/) { }
35 virtual ~FastMixer() { }
36
37 FastMixerStateQueue* sq() { return &mSQ; }
38
39private:
40 virtual bool threadLoop();
41 FastMixerStateQueue mSQ;
42
43}; // class FastMixer
44
45// The FastMixerDumpState keeps a cache of FastMixer statistics that can be logged by dumpsys.
46// Since used non-atomically, only POD types are permitted, and the contents can't be trusted.
47// It has a different lifetime than the FastMixer, and so it can't be a member of FastMixer.
48struct FastMixerDumpState {
49 FastMixerDumpState();
50 /*virtual*/ ~FastMixerDumpState();
51
52 void dump(int fd);
53
54 FastMixerState::Command mCommand; // current command
55 uint32_t mWriteSequence; // incremented before and after each write()
56 uint32_t mFramesWritten; // total number of frames written successfully
57 uint32_t mNumTracks; // total number of active fast tracks
58 uint32_t mWriteErrors; // total number of write() errors
59 uint32_t mUnderruns; // total number of underruns
60 uint32_t mOverruns; // total number of overruns
61#ifdef FAST_MIXER_STATISTICS
62 // cycle times in seconds
63 float mMean;
64 float mMinimum;
65 float mMaximum;
66 float mStddev;
67#endif
68};
69
70} // namespace android
71
72#endif // ANDROID_AUDIO_FAST_MIXER_H