Loading media/utils/MethodStatistics.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ namespace android::mediautils { // Repository for MethodStatistics Objects // It's important to have the HAL class name defined with suffix "Hidl/Aidl" because // TimerThread::isRequestFromHal use this string to match binder call to/from hal. std::shared_ptr<std::vector<std::string>> getStatisticsClassesForModule(std::string_view moduleName) { static const std::map<std::string, std::shared_ptr<std::vector<std::string>>, Loading @@ -34,6 +36,15 @@ getStatisticsClassesForModule(std::string_view moduleName) { "StreamOutHalHidl", }) }, { METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL, std::shared_ptr<std::vector<std::string>>( new std::vector<std::string>{ "DeviceHalAidl", "EffectHalAidl", "StreamHalAidl", }) }, }; auto it = m.find(moduleName); if (it == m.end()) return {}; Loading Loading @@ -61,6 +72,9 @@ getStatisticsForClass(std::string_view className) { addClassesToMap( getStatisticsClassesForModule(METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL), m); addClassesToMap( getStatisticsClassesForModule(METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL), m); return m; }(); Loading media/utils/TimerThread.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -104,11 +104,16 @@ std::string TimerThread::SnapshotAnalysis::toString() const { // /* static */ bool TimerThread::isRequestFromHal(const std::shared_ptr<const Request>& request) { const size_t hidlPos = request->tag.asStringView().find("Hidl"); if (hidlPos == std::string::npos) return false; // should be a separator afterwards Hidl which indicates the string was in the class. const size_t separatorPos = request->tag.asStringView().find("::", hidlPos); return separatorPos != std::string::npos; for (const auto& s : {"Hidl", "Aidl"}) { const auto& tagSV = request->tag.asStringView(); const size_t halStrPos = tagSV.find(s); // should be a separator afterwards Hidl/Aidl which indicates the string was in the class. if (halStrPos != std::string::npos && tagSV.find("::", halStrPos) != std::string::npos) { return true; } } return false; } struct TimerThread::SnapshotAnalysis TimerThread::getSnapshotAnalysis(size_t retiredCount) const { Loading media/utils/include/mediautils/MethodStatistics.h +1 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,7 @@ private: // Managed Statistics support. // Supported Modules #define METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL "AudioHidl" #define METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL "AudioAidl" // Returns a vector of class names for the module, or a nullptr if module not found. std::shared_ptr<std::vector<std::string>> Loading services/audioflinger/AudioFlinger.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -859,12 +859,15 @@ NO_THREAD_SAFETY_ANALYSIS // conditional try lock dprintf(fd, "\nIEffect binder call profile:\n"); write(fd, timeCheckStats.c_str(), timeCheckStats.size()); // Automatically fetch HIDL statistics. std::shared_ptr<std::vector<std::string>> hidlClassNames = mediautils::getStatisticsClassesForModule( METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL); if (hidlClassNames) { for (const auto& className : *hidlClassNames) { // Automatically fetch HIDL or AIDL statistics. const std::string_view halType = (mDevicesFactoryHal->getHalVersion().getType() == AudioHalVersionInfo::Type::HIDL) ? METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL : METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL; const std::shared_ptr<std::vector<std::string>> halClassNames = mediautils::getStatisticsClassesForModule(halType); if (halClassNames) { for (const auto& className : *halClassNames) { auto stats = mediautils::getStatisticsForClass(className); if (stats) { timeCheckStats = stats->dump(); Loading Loading
media/utils/MethodStatistics.cpp +14 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,8 @@ namespace android::mediautils { // Repository for MethodStatistics Objects // It's important to have the HAL class name defined with suffix "Hidl/Aidl" because // TimerThread::isRequestFromHal use this string to match binder call to/from hal. std::shared_ptr<std::vector<std::string>> getStatisticsClassesForModule(std::string_view moduleName) { static const std::map<std::string, std::shared_ptr<std::vector<std::string>>, Loading @@ -34,6 +36,15 @@ getStatisticsClassesForModule(std::string_view moduleName) { "StreamOutHalHidl", }) }, { METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL, std::shared_ptr<std::vector<std::string>>( new std::vector<std::string>{ "DeviceHalAidl", "EffectHalAidl", "StreamHalAidl", }) }, }; auto it = m.find(moduleName); if (it == m.end()) return {}; Loading Loading @@ -61,6 +72,9 @@ getStatisticsForClass(std::string_view className) { addClassesToMap( getStatisticsClassesForModule(METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL), m); addClassesToMap( getStatisticsClassesForModule(METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL), m); return m; }(); Loading
media/utils/TimerThread.cpp +10 −5 Original line number Diff line number Diff line Loading @@ -104,11 +104,16 @@ std::string TimerThread::SnapshotAnalysis::toString() const { // /* static */ bool TimerThread::isRequestFromHal(const std::shared_ptr<const Request>& request) { const size_t hidlPos = request->tag.asStringView().find("Hidl"); if (hidlPos == std::string::npos) return false; // should be a separator afterwards Hidl which indicates the string was in the class. const size_t separatorPos = request->tag.asStringView().find("::", hidlPos); return separatorPos != std::string::npos; for (const auto& s : {"Hidl", "Aidl"}) { const auto& tagSV = request->tag.asStringView(); const size_t halStrPos = tagSV.find(s); // should be a separator afterwards Hidl/Aidl which indicates the string was in the class. if (halStrPos != std::string::npos && tagSV.find("::", halStrPos) != std::string::npos) { return true; } } return false; } struct TimerThread::SnapshotAnalysis TimerThread::getSnapshotAnalysis(size_t retiredCount) const { Loading
media/utils/include/mediautils/MethodStatistics.h +1 −0 Original line number Diff line number Diff line Loading @@ -124,6 +124,7 @@ private: // Managed Statistics support. // Supported Modules #define METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL "AudioHidl" #define METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL "AudioAidl" // Returns a vector of class names for the module, or a nullptr if module not found. std::shared_ptr<std::vector<std::string>> Loading
services/audioflinger/AudioFlinger.cpp +9 −6 Original line number Diff line number Diff line Loading @@ -859,12 +859,15 @@ NO_THREAD_SAFETY_ANALYSIS // conditional try lock dprintf(fd, "\nIEffect binder call profile:\n"); write(fd, timeCheckStats.c_str(), timeCheckStats.size()); // Automatically fetch HIDL statistics. std::shared_ptr<std::vector<std::string>> hidlClassNames = mediautils::getStatisticsClassesForModule( METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL); if (hidlClassNames) { for (const auto& className : *hidlClassNames) { // Automatically fetch HIDL or AIDL statistics. const std::string_view halType = (mDevicesFactoryHal->getHalVersion().getType() == AudioHalVersionInfo::Type::HIDL) ? METHOD_STATISTICS_MODULE_NAME_AUDIO_HIDL : METHOD_STATISTICS_MODULE_NAME_AUDIO_AIDL; const std::shared_ptr<std::vector<std::string>> halClassNames = mediautils::getStatisticsClassesForModule(halType); if (halClassNames) { for (const auto& className : *halClassNames) { auto stats = mediautils::getStatisticsForClass(className); if (stats) { timeCheckStats = stats->dump(); Loading