Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 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 | |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 17 | #define LOG_TAG "IsochronousClockModel" |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 18 | //#define LOG_NDEBUG 0 |
Tom Cherry | 357552e | 2017-07-12 13:48:26 -0700 | [diff] [blame] | 19 | #include <log/log.h> |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 20 | |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 21 | #define __STDC_FORMAT_MACROS |
| 22 | #include <inttypes.h> |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 23 | #include <stdint.h> |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 24 | #include <algorithm> |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 25 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 26 | #include "utility/AudioClock.h" |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 27 | #include "utility/AAudioUtilities.h" |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 28 | #include "IsochronousClockModel.h" |
| 29 | |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 30 | using namespace aaudio; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 31 | |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 32 | using namespace android::audio_utils; |
| 33 | |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 34 | #ifndef ICM_LOG_DRIFT |
| 35 | #define ICM_LOG_DRIFT 0 |
| 36 | #endif // ICM_LOG_DRIFT |
| 37 | |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 38 | // To enable the timestamp histogram, enter this before opening the stream: |
| 39 | // adb root |
| 40 | // adb shell setprop aaudio.log_mask 1 |
| 41 | // A histogram of the lateness of the timestamps will be cleared when the stream is started. |
| 42 | // It will be updated when the model is stable and receives a timestamp, |
| 43 | // and dumped to the log when the stream is stopped. |
| 44 | |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 45 | IsochronousClockModel::IsochronousClockModel() |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 46 | : mMarkerFramePosition(0) |
| 47 | , mMarkerNanoTime(0) |
| 48 | , mSampleRate(48000) |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 49 | , mFramesPerBurst(48) |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 50 | , mMaxMeasuredLatenessNanos(0) |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 51 | , mLatenessForDriftNanos(kInitialLatenessForDriftNanos) |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 52 | , mState(STATE_STOPPED) |
| 53 | { |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 54 | if ((AAudioProperty_getLogMask() & AAUDIO_LOG_CLOCK_MODEL_HISTOGRAM) != 0) { |
| 55 | mHistogramMicros = std::make_unique<Histogram>(kHistogramBinCount, |
| 56 | kHistogramBinWidthMicros); |
| 57 | } |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | IsochronousClockModel::~IsochronousClockModel() { |
| 61 | } |
| 62 | |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 63 | void IsochronousClockModel::setPositionAndTime(int64_t framePosition, int64_t nanoTime) { |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 64 | ALOGV("setPositionAndTime, %lld, %lld", (long long) framePosition, (long long) nanoTime); |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 65 | mMarkerFramePosition = framePosition; |
| 66 | mMarkerNanoTime = nanoTime; |
| 67 | } |
| 68 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 69 | void IsochronousClockModel::start(int64_t nanoTime) { |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 70 | ALOGV("start(nanos = %lld)\n", (long long) nanoTime); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 71 | mMarkerNanoTime = nanoTime; |
| 72 | mState = STATE_STARTING; |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 73 | if (mHistogramMicros) { |
| 74 | mHistogramMicros->clear(); |
| 75 | } |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 76 | } |
| 77 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 78 | void IsochronousClockModel::stop(int64_t nanoTime) { |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 79 | ALOGD("stop(nanos = %lld) max lateness = %d micros\n", |
| 80 | (long long) nanoTime, |
| 81 | (int) (mMaxMeasuredLatenessNanos / 1000)); |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 82 | setPositionAndTime(convertTimeToPosition(nanoTime), nanoTime); |
| 83 | // TODO should we set position? |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 84 | mState = STATE_STOPPED; |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 85 | if (mHistogramMicros) { |
| 86 | dumpHistogram(); |
| 87 | } |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 88 | } |
| 89 | |
Phil Burk | 377c1c2 | 2018-12-12 16:06:54 -0800 | [diff] [blame] | 90 | bool IsochronousClockModel::isStarting() const { |
Phil Burk | bcc3674 | 2017-08-31 17:24:51 -0700 | [diff] [blame] | 91 | return mState == STATE_STARTING; |
| 92 | } |
| 93 | |
Phil Burk | 377c1c2 | 2018-12-12 16:06:54 -0800 | [diff] [blame] | 94 | bool IsochronousClockModel::isRunning() const { |
| 95 | return mState == STATE_RUNNING; |
| 96 | } |
| 97 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 98 | void IsochronousClockModel::processTimestamp(int64_t framePosition, int64_t nanoTime) { |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 99 | mTimestampCount++; |
| 100 | // Log position and time in CSV format so we can import it easily into spreadsheets. |
| 101 | //ALOGD("%s() CSV, %d, %lld, %lld", __func__, |
| 102 | //mTimestampCount, (long long)framePosition, (long long)nanoTime); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 103 | int64_t framesDelta = framePosition - mMarkerFramePosition; |
| 104 | int64_t nanosDelta = nanoTime - mMarkerNanoTime; |
| 105 | if (nanosDelta < 1000) { |
| 106 | return; |
| 107 | } |
| 108 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 109 | // ALOGD("processTimestamp() - mMarkerFramePosition = %lld at mMarkerNanoTime %llu", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 110 | // (long long)mMarkerFramePosition, |
| 111 | // (long long)mMarkerNanoTime); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 112 | |
| 113 | int64_t expectedNanosDelta = convertDeltaPositionToTime(framesDelta); |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 114 | // ALOGD("processTimestamp() - expectedNanosDelta = %lld, nanosDelta = %llu", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 115 | // (long long)expectedNanosDelta, |
| 116 | // (long long)nanosDelta); |
| 117 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 118 | // ALOGD("processTimestamp() - mSampleRate = %d", mSampleRate); |
| 119 | // ALOGD("processTimestamp() - mState = %d", mState); |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 120 | int64_t latenessNanos = nanosDelta - expectedNanosDelta; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 121 | switch (mState) { |
| 122 | case STATE_STOPPED: |
| 123 | break; |
| 124 | case STATE_STARTING: |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 125 | setPositionAndTime(framePosition, nanoTime); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 126 | mState = STATE_SYNCING; |
| 127 | break; |
| 128 | case STATE_SYNCING: |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 129 | // This will handle a burst of rapid transfer at the beginning. |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 130 | if (latenessNanos < 0) { |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 131 | setPositionAndTime(framePosition, nanoTime); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 132 | } else { |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 133 | // ALOGD("processTimestamp() - advance to STATE_RUNNING"); |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 134 | mState = STATE_RUNNING; |
| 135 | } |
| 136 | break; |
| 137 | case STATE_RUNNING: |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 138 | if (mHistogramMicros) { |
| 139 | mHistogramMicros->add(latenessNanos / AAUDIO_NANOS_PER_MICROSECOND); |
| 140 | } |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 141 | // Modify estimated position based on lateness. |
| 142 | // This affects the "early" side of the window, which controls output glitches. |
| 143 | if (latenessNanos < 0) { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 144 | // Earlier than expected timestamp. |
Phil Burk | 1815a76 | 2019-05-24 08:52:27 -0700 | [diff] [blame] | 145 | // This data is probably more accurate, so use it. |
| 146 | // Or we may be drifting due to a fast HW clock. |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 147 | setPositionAndTime(framePosition, nanoTime); |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 148 | #if ICM_LOG_DRIFT |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 149 | int earlyDeltaMicros = (int) ((expectedNanosDelta - nanosDelta)/ 1000); |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 150 | ALOGD("%s() - STATE_RUNNING - #%d, %4d micros EARLY", |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 151 | __func__, mTimestampCount, earlyDeltaMicros); |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 152 | #endif |
| 153 | } else if (latenessNanos > mLatenessForDriftNanos) { |
| 154 | // When we are on the late side, it may be because of preemption in the kernel, |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 155 | // or timing jitter caused by resampling in the DSP, |
| 156 | // or we may be drifting due to a slow HW clock. |
| 157 | // We add slight drift value just in case there is actual long term drift |
| 158 | // forward caused by a slower clock. |
| 159 | // If the clock is faster than the model will get pushed earlier |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 160 | // by the code in the earlier branch. |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 161 | // The two opposing forces should allow the model to track the real clock |
| 162 | // over a long time. |
| 163 | int64_t driftingTime = mMarkerNanoTime + expectedNanosDelta + kDriftNanos; |
| 164 | setPositionAndTime(framePosition, driftingTime); |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 165 | #if ICM_LOG_DRIFT |
| 166 | ALOGD("%s() - STATE_RUNNING - #%d, DRIFT, lateness = %d micros", |
| 167 | __func__, |
| 168 | mTimestampCount, |
| 169 | (int) (latenessNanos / 1000)); |
| 170 | #endif |
| 171 | } |
| 172 | |
| 173 | // Modify mMaxMeasuredLatenessNanos. |
| 174 | // This affects the "late" side of the window, which controls input glitches. |
| 175 | if (latenessNanos > mMaxMeasuredLatenessNanos) { // increase |
| 176 | #if ICM_LOG_DRIFT |
| 177 | ALOGD("%s() - STATE_RUNNING - #%d, newmax %d - oldmax %d = %4d micros LATE", |
| 178 | __func__, |
| 179 | mTimestampCount, |
| 180 | (int) (latenessNanos / 1000), |
| 181 | mMaxMeasuredLatenessNanos / 1000, |
| 182 | (int) ((latenessNanos - mMaxMeasuredLatenessNanos) / 1000) |
| 183 | ); |
| 184 | #endif |
| 185 | mMaxMeasuredLatenessNanos = (int32_t) latenessNanos; |
| 186 | // Calculate upper region that will trigger a drift forwards. |
| 187 | mLatenessForDriftNanos = mMaxMeasuredLatenessNanos - (mMaxMeasuredLatenessNanos >> 4); |
| 188 | } else { // decrease |
| 189 | // If these is an outlier in lateness then mMaxMeasuredLatenessNanos can go high |
| 190 | // and stay there. So we slowly reduce mMaxMeasuredLatenessNanos for better |
| 191 | // long term stability. The two opposing forces will keep mMaxMeasuredLatenessNanos |
| 192 | // within a reasonable range. |
| 193 | mMaxMeasuredLatenessNanos -= kDriftNanos; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 194 | } |
| 195 | break; |
| 196 | default: |
| 197 | break; |
| 198 | } |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | void IsochronousClockModel::setSampleRate(int32_t sampleRate) { |
| 202 | mSampleRate = sampleRate; |
| 203 | update(); |
| 204 | } |
| 205 | |
| 206 | void IsochronousClockModel::setFramesPerBurst(int32_t framesPerBurst) { |
| 207 | mFramesPerBurst = framesPerBurst; |
| 208 | update(); |
| 209 | } |
| 210 | |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 211 | // Update expected lateness based on sampleRate and framesPerBurst |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 212 | void IsochronousClockModel::update() { |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 213 | mBurstPeriodNanos = convertDeltaPositionToTime(mFramesPerBurst); // uses mSampleRate |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 214 | } |
| 215 | |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 216 | int64_t IsochronousClockModel::convertDeltaPositionToTime(int64_t framesDelta) const { |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 217 | return (AAUDIO_NANOS_PER_SECOND * framesDelta) / mSampleRate; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 218 | } |
| 219 | |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 220 | int64_t IsochronousClockModel::convertDeltaTimeToPosition(int64_t nanosDelta) const { |
Phil Burk | 5ed503c | 2017-02-01 09:38:15 -0800 | [diff] [blame] | 221 | return (mSampleRate * nanosDelta) / AAUDIO_NANOS_PER_SECOND; |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 222 | } |
| 223 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 224 | int64_t IsochronousClockModel::convertPositionToTime(int64_t framePosition) const { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 225 | if (mState == STATE_STOPPED) { |
| 226 | return mMarkerNanoTime; |
| 227 | } |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 228 | int64_t nextBurstIndex = (framePosition + mFramesPerBurst - 1) / mFramesPerBurst; |
| 229 | int64_t nextBurstPosition = mFramesPerBurst * nextBurstIndex; |
| 230 | int64_t framesDelta = nextBurstPosition - mMarkerFramePosition; |
| 231 | int64_t nanosDelta = convertDeltaPositionToTime(framesDelta); |
Phil Burk | fd34a93 | 2017-07-19 07:03:52 -0700 | [diff] [blame] | 232 | int64_t time = mMarkerNanoTime + nanosDelta; |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 233 | // ALOGD("convertPositionToTime: pos = %llu --> time = %llu", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 234 | // (unsigned long long)framePosition, |
| 235 | // (unsigned long long)time); |
| 236 | return time; |
| 237 | } |
| 238 | |
Phil Burk | 87c9f64 | 2017-05-17 07:22:39 -0700 | [diff] [blame] | 239 | int64_t IsochronousClockModel::convertTimeToPosition(int64_t nanoTime) const { |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 240 | if (mState == STATE_STOPPED) { |
| 241 | return mMarkerFramePosition; |
| 242 | } |
Phil Burk | 3316d5e | 2017-02-15 11:23:01 -0800 | [diff] [blame] | 243 | int64_t nanosDelta = nanoTime - mMarkerNanoTime; |
| 244 | int64_t framesDelta = convertDeltaTimeToPosition(nanosDelta); |
| 245 | int64_t nextBurstPosition = mMarkerFramePosition + framesDelta; |
| 246 | int64_t nextBurstIndex = nextBurstPosition / mFramesPerBurst; |
| 247 | int64_t position = nextBurstIndex * mFramesPerBurst; |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 248 | // ALOGD("convertTimeToPosition: time = %llu --> pos = %llu", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 249 | // (unsigned long long)nanoTime, |
| 250 | // (unsigned long long)position); |
Phil Burk | fbf031e | 2017-10-12 15:58:31 -0700 | [diff] [blame] | 251 | // ALOGD("convertTimeToPosition: framesDelta = %llu, mFramesPerBurst = %d", |
Phil Burk | 204a163 | 2017-01-03 17:23:43 -0800 | [diff] [blame] | 252 | // (long long) framesDelta, mFramesPerBurst); |
| 253 | return position; |
| 254 | } |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 255 | |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 256 | int32_t IsochronousClockModel::getLateTimeOffsetNanos() const { |
Phil Burk | 34e2d2d | 2019-09-26 12:46:10 -0700 | [diff] [blame] | 257 | return mMaxMeasuredLatenessNanos + kExtraLatenessNanos; |
Phil Burk | fceeee7 | 2019-06-14 11:18:45 -0700 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | int64_t IsochronousClockModel::convertPositionToLatestTime(int64_t framePosition) const { |
| 261 | return convertPositionToTime(framePosition) + getLateTimeOffsetNanos(); |
| 262 | } |
| 263 | |
| 264 | int64_t IsochronousClockModel::convertLatestTimeToPosition(int64_t nanoTime) const { |
| 265 | return convertTimeToPosition(nanoTime - getLateTimeOffsetNanos()); |
| 266 | } |
| 267 | |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 268 | void IsochronousClockModel::dump() const { |
Phil Burk | ef34be5 | 2019-09-26 13:45:25 -0700 | [diff] [blame] | 269 | ALOGD("mMarkerFramePosition = %" PRIu64, mMarkerFramePosition); |
| 270 | ALOGD("mMarkerNanoTime = %" PRIu64, mMarkerNanoTime); |
| 271 | ALOGD("mSampleRate = %6d", mSampleRate); |
| 272 | ALOGD("mFramesPerBurst = %6d", mFramesPerBurst); |
| 273 | ALOGD("mMaxMeasuredLatenessNanos = %6d", mMaxMeasuredLatenessNanos); |
| 274 | ALOGD("mState = %6d", mState); |
| 275 | } |
| 276 | |
| 277 | void IsochronousClockModel::dumpHistogram() const { |
| 278 | if (!mHistogramMicros) return; |
| 279 | std::istringstream istr(mHistogramMicros->dump()); |
| 280 | std::string line; |
| 281 | while (std::getline(istr, line)) { |
| 282 | ALOGD("lateness, %s", line.c_str()); |
| 283 | } |
Phil Burk | ec89b2e | 2017-06-20 15:05:06 -0700 | [diff] [blame] | 284 | } |