blob: 21eed6ed92c0ebd6bd318dc5752e567eaac6c2f1 [file] [log] [blame]
Eric Laurent17a58b22016-08-17 13:53:12 +02001/*
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
17#define LOG_TAG "LockWatch"
18//#define LOG_NDEBUG 0
19
20#include <utils/Log.h>
21#include "LockWatch.h"
22
23namespace android {
24
25void LockWatch::onFirstRef()
26{
27 run("lock watch", ANDROID_PRIORITY_URGENT_AUDIO);
28}
29
30bool LockWatch::threadLoop()
31{
32 while (!exitPending()) {
33 // we neglect previous lock time effect on period
34 usleep(mPeriodMs * 1000);
35 if (mLock.timedLock(milliseconds(mTimeOutMs)) != NO_ERROR) {
36 LOG_ALWAYS_FATAL("LockWatch timeout for: %s", mTag.string());
37 }
38 mLock.unlock();
39 }
40 return false;
41}
42
43} // namespace android
44