blob: bbca7da74cfd4c92bd47c82546e7e5cd1b81f25b [file] [log] [blame]
Glenn Kasten045ee7e2015-02-17 16:22:04 -08001/*
2 * Copyright (C) 2014 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_THREAD_DUMP_STATE_H
18#define ANDROID_AUDIO_FAST_THREAD_DUMP_STATE_H
19
20#include "Configuration.h"
21#include "FastThreadState.h"
22
23namespace android {
24
25// FIXME extract common part of comment at FastMixerDumpState
26struct FastThreadDumpState {
27 FastThreadDumpState();
28 /*virtual*/ ~FastThreadDumpState();
29
30 FastThreadState::Command mCommand; // current command
31 uint32_t mUnderruns; // total number of underruns
32 uint32_t mOverruns; // total number of overruns
33 struct timespec mMeasuredWarmupTs; // measured warmup time
34 uint32_t mWarmupCycles; // number of loop cycles required to warmup
35
Glenn Kasten214b4062015-03-02 14:15:47 -080036#ifdef FAST_THREAD_STATISTICS
Glenn Kasten045ee7e2015-02-17 16:22:04 -080037 // Recently collected samples of per-cycle monotonic time, thread CPU time, and CPU frequency.
38 // kSamplingN is max size of sampling frame (statistics), and must be a power of 2 <= 0x8000.
39 // The sample arrays are virtually allocated based on this compile-time constant,
40 // but are only initialized and used based on the runtime parameter mSamplingN.
41 static const uint32_t kSamplingN = 0x8000;
Glenn Kastenfbdb2ac2015-03-02 14:47:19 -080042 // Compile-time constant for a "low RAM device", must be a power of 2 <= kSamplingN.
43 // This value was chosen such that each array uses 1 small page (4 Kbytes).
44 static const uint32_t kSamplingNforLowRamDevice = 0x400;
Glenn Kasten045ee7e2015-02-17 16:22:04 -080045 // Corresponding runtime maximum size of sample arrays, must be a power of 2 <= kSamplingN.
46 uint32_t mSamplingN;
47 // The bounds define the interval of valid samples, and are represented as follows:
48 // newest open (excluded) endpoint = lower 16 bits of bounds, modulo N
49 // oldest closed (included) endpoint = upper 16 bits of bounds, modulo N
50 // Number of valid samples is newest - oldest.
51 uint32_t mBounds; // bounds for mMonotonicNs, mThreadCpuNs, and mCpukHz
52 // The elements in the *Ns arrays are in units of nanoseconds <= 3999999999.
53 uint32_t mMonotonicNs[kSamplingN]; // delta monotonic (wall clock) time
54 uint32_t mLoadNs[kSamplingN]; // delta CPU load in time
55#ifdef CPU_FREQUENCY_STATISTICS
56 uint32_t mCpukHz[kSamplingN]; // absolute CPU clock frequency in kHz, bits 0-3 are CPU#
57#endif
Glenn Kastenfbdb2ac2015-03-02 14:47:19 -080058
59 // Increase sampling window after construction, must be a power of 2 <= kSamplingN
60 void increaseSamplingN(uint32_t samplingN);
Glenn Kasten045ee7e2015-02-17 16:22:04 -080061#endif
62
63}; // struct FastThreadDumpState
64
65} // android
66
67#endif // ANDROID_AUDIO_FAST_THREAD_DUMP_STATE_H