diff --git a/include/media/EventLog.h b/include/media/EventLog.h new file mode 120000 index 0000000000..9b2c4bfb80 --- /dev/null +++ b/include/media/EventLog.h @@ -0,0 +1 @@ +../../media/utils/include/mediautils/EventLog.h \ No newline at end of file diff --git a/include/media/TimeCheck.h b/include/media/TimeCheck.h index e3ef134404..85e17f91c2 120000 --- a/include/media/TimeCheck.h +++ b/include/media/TimeCheck.h @@ -1 +1 @@ -../../media/libmedia/include/media/TimeCheck.h \ No newline at end of file +../../media/utils/include/mediautils/TimeCheck.h \ No newline at end of file diff --git a/media/libaudioclient/IAudioFlinger.cpp b/media/libaudioclient/IAudioFlinger.cpp index 37c62a81dd..84e8beef17 100644 --- a/media/libaudioclient/IAudioFlinger.cpp +++ b/media/libaudioclient/IAudioFlinger.cpp @@ -949,7 +949,8 @@ status_t BnAudioFlinger::onTransact( break; } - TimeCheck check("IAudioFlinger"); + std::string tag("IAudioFlinger command " + std::to_string(code)); + TimeCheck check(tag.c_str()); switch (code) { case CREATE_TRACK: { diff --git a/media/libaudioclient/IAudioPolicyService.cpp b/media/libaudioclient/IAudioPolicyService.cpp index 9d77376d89..e229f4c7b0 100644 --- a/media/libaudioclient/IAudioPolicyService.cpp +++ b/media/libaudioclient/IAudioPolicyService.cpp @@ -935,7 +935,8 @@ status_t BnAudioPolicyService::onTransact( break; } - TimeCheck check("IAudioPolicyService"); + std::string tag("IAudioPolicyService command " + std::to_string(code)); + TimeCheck check(tag.c_str()); switch (code) { case SET_DEVICE_CONNECTION_STATE: { diff --git a/media/libmedia/Android.bp b/media/libmedia/Android.bp index a22819a688..e6d6b3e45f 100644 --- a/media/libmedia/Android.bp +++ b/media/libmedia/Android.bp @@ -20,7 +20,7 @@ cc_library { vndk: { enabled: true, }, - srcs: ["AudioParameter.cpp", "TypeConverter.cpp", "TimeCheck.cpp"], + srcs: ["AudioParameter.cpp", "TypeConverter.cpp"], cflags: [ "-Werror", "-Wno-error=deprecated-declarations", diff --git a/media/utils/Android.bp b/media/utils/Android.bp index de8e46a016..13b66ed950 100644 --- a/media/utils/Android.bp +++ b/media/utils/Android.bp @@ -22,6 +22,7 @@ cc_library { "ProcessInfo.cpp", "SchedulingPolicyService.cpp", "ServiceUtilities.cpp", + "TimeCheck.cpp", ], shared_libs: [ "libbinder", @@ -31,6 +32,8 @@ cc_library { "libmemunreachable", ], + logtags: ["EventLogTags.logtags"], + cflags: [ "-Wall", "-Wextra", diff --git a/media/utils/EventLogTags.logtags b/media/utils/EventLogTags.logtags new file mode 100644 index 0000000000..67f0ea8cdb --- /dev/null +++ b/media/utils/EventLogTags.logtags @@ -0,0 +1,41 @@ +# The entries in this file map a sparse set of log tag numbers to tag names. +# This is installed on the device, in /system/etc, and parsed by logcat. +# +# Tag numbers are decimal integers, from 0 to 2^31. (Let's leave the +# negative values alone for now.) +# +# Tag names are one or more ASCII letters and numbers or underscores, i.e. +# "[A-Z][a-z][0-9]_". Do not include spaces or punctuation (the former +# impacts log readability, the latter makes regex searches more annoying). +# +# Tag numbers and names are separated by whitespace. Blank lines and lines +# starting with '#' are ignored. +# +# Optionally, after the tag names can be put a description for the value(s) +# of the tag. Description are in the format +# (|data type[|data unit]) +# Multiple values are separated by commas. +# +# The data type is a number from the following values: +# 1: int +# 2: long +# 3: string +# 4: list +# +# The data unit is a number taken from the following list: +# 1: Number of objects +# 2: Number of bytes +# 3: Number of milliseconds +# 4: Number of allocations +# 5: Id +# 6: Percent +# Default value for data of type int/long is 2 (bytes). +# +# See system/core/logcat/event.logtags for the master copy of the tags. + +# 61000 - 61199 reserved for audioserver + +61000 audioserver_binder_timeout (command|3) + +# NOTE - the range 1000000-2000000 is reserved for partners and others who +# want to define their own log tags without conflicting with the core platform. diff --git a/media/libmedia/TimeCheck.cpp b/media/utils/TimeCheck.cpp similarity index 92% rename from media/libmedia/TimeCheck.cpp rename to media/utils/TimeCheck.cpp index dab5d4f336..59cf4ef393 100644 --- a/media/libmedia/TimeCheck.cpp +++ b/media/utils/TimeCheck.cpp @@ -15,7 +15,9 @@ */ +#include #include +#include namespace android { @@ -81,7 +83,10 @@ bool TimeCheck::TimeCheckThread::threadLoop() status = mCond.waitRelative(mMutex, waitTimeNs); } } - LOG_ALWAYS_FATAL_IF(status != NO_ERROR, "TimeCheck timeout for %s", tag); + if (status != NO_ERROR) { + LOG_EVENT_STRING(LOGTAG_AUDIO_BINDER_TIMEOUT, tag); + LOG_ALWAYS_FATAL("TimeCheck timeout for %s", tag); + } return true; } diff --git a/media/utils/include/mediautils/EventLog.h b/media/utils/include/mediautils/EventLog.h new file mode 100644 index 0000000000..553d3bda20 --- /dev/null +++ b/media/utils/include/mediautils/EventLog.h @@ -0,0 +1,28 @@ +/* + * Copyright (C) 2018 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#ifndef ANDROID_AUDIO_EVENT_LOG_H_ +#define ANDROID_AUDIO_EVENT_LOG_H_ + +namespace android { + +// keep values in sync with frameworks/av/media/utils/EventLogTags.logtags +enum { + LOGTAG_AUDIO_BINDER_TIMEOUT = 61000, +}; + +} // namespace android + +#endif // ANDROID_AUDIO_EVENT_LOG_H_ diff --git a/media/libmedia/include/media/TimeCheck.h b/media/utils/include/mediautils/TimeCheck.h similarity index 100% rename from media/libmedia/include/media/TimeCheck.h rename to media/utils/include/mediautils/TimeCheck.h