Loading services/mediametrics/AudioAnalytics.cpp +18 −11 Original line number Original line Diff line number Diff line Loading @@ -140,7 +140,6 @@ static constexpr const char * const AudioDeviceConnectionFields[] = { static constexpr const char * const AAudioStreamFields[] { static constexpr const char * const AAudioStreamFields[] { "mediametrics_aaudiostream_reported", "mediametrics_aaudiostream_reported", "caller_name", "path", "path", "direction", "direction", "frames_per_burst", "frames_per_burst", Loading @@ -156,6 +155,8 @@ static constexpr const char * const AAudioStreamFields[] { "format_app", "format_app", "format_device", "format_device", "log_session_id", "log_session_id", "sample_rate", "content_type", }; }; /** /** Loading Loading @@ -932,12 +933,6 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( const std::shared_ptr<const android::mediametrics::Item> &item, CallerPath path) const { const std::shared_ptr<const android::mediametrics::Item> &item, CallerPath path) const { const std::string& key = item->getKey(); const std::string& key = item->getKey(); std::string callerNameStr; mAudioAnalytics.mAnalyticsState->timeMachine().get( key, AMEDIAMETRICS_PROP_CALLERNAME, &callerNameStr); const auto callerName = types::lookup<types::CALLER_NAME, int32_t>(callerNameStr); std::string directionStr; std::string directionStr; mAudioAnalytics.mAnalyticsState->timeMachine().get( mAudioAnalytics.mAnalyticsState->timeMachine().get( key, AMEDIAMETRICS_PROP_DIRECTION, &directionStr); key, AMEDIAMETRICS_PROP_DIRECTION, &directionStr); Loading Loading @@ -994,8 +989,16 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( std::string logSessionId; std::string logSessionId; // TODO: log logSessionId // TODO: log logSessionId int32_t sampleRate = 0; mAudioAnalytics.mAnalyticsState->timeMachine().get( key, AMEDIAMETRICS_PROP_SAMPLERATE, &sampleRate); std::string contentTypeStr; mAudioAnalytics.mAnalyticsState->timeMachine().get( key, AMEDIAMETRICS_PROP_CONTENTTYPE, &contentTypeStr); const auto contentType = types::lookup<types::CONTENT_TYPE, int32_t>(contentTypeStr); LOG(LOG_LEVEL) << "key:" << key LOG(LOG_LEVEL) << "key:" << key << " caller_name:" << callerName << "(" << callerNameStr << ")" << " path:" << path << " path:" << path << " direction:" << direction << "(" << directionStr << ")" << " direction:" << direction << "(" << directionStr << ")" << " frames_per_burst:" << framesPerBurst << " frames_per_burst:" << framesPerBurst Loading @@ -1010,14 +1013,15 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( << " device_type:" << serializedDeviceTypes << " device_type:" << serializedDeviceTypes << " format_app:" << formatApp << " format_app:" << formatApp << " format_device: " << formatDevice << "(" << formatDeviceStr << ")" << " format_device: " << formatDevice << "(" << formatDeviceStr << ")" << " log_session_id: " << logSessionId; << " log_session_id: " << logSessionId << " sample_rate: " << sampleRate << " content_type: " << contentType << "(" << contentTypeStr << ")"; if (mAudioAnalytics.mDeliverStatistics) { if (mAudioAnalytics.mDeliverStatistics) { android::util::BytesField bf_serialized( android::util::BytesField bf_serialized( serializedDeviceTypes.c_str(), serializedDeviceTypes.size()); serializedDeviceTypes.c_str(), serializedDeviceTypes.size()); const auto result = sendToStatsd( const auto result = sendToStatsd( CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED) CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED) , callerName , path , path , direction , direction , framesPerBurst , framesPerBurst Loading @@ -1033,12 +1037,13 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( , formatApp , formatApp , formatDevice , formatDevice , logSessionId.c_str() , logSessionId.c_str() , sampleRate , contentType ); ); std::stringstream ss; std::stringstream ss; ss << "result:" << result; ss << "result:" << result; const auto fieldsStr = printFields(AAudioStreamFields, const auto fieldsStr = printFields(AAudioStreamFields, CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED) CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED) , callerName , path , path , direction , direction , framesPerBurst , framesPerBurst Loading @@ -1054,6 +1059,8 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( , formatApp , formatApp , formatDevice , formatDevice , logSessionId.c_str() , logSessionId.c_str() , sampleRate , contentType ); ); ss << " " << fieldsStr; ss << " " << fieldsStr; std::string str = ss.str(); std::string str = ss.str(); Loading services/mediametrics/AudioTypes.cpp +10 −10 Original line number Original line Diff line number Diff line Loading @@ -158,9 +158,9 @@ const std::unordered_map<std::string, int32_t>& getAAudioDirection() { // DO NOT MODIFY VALUES(OK to add new ones). // DO NOT MODIFY VALUES(OK to add new ones). // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h static std::unordered_map<std::string, int32_t> map { static std::unordered_map<std::string, int32_t> map { // UNKNOWN is -1 // UNKNOWN is 0 {"AAUDIO_DIRECTION_OUTPUT", 0}, {"AAUDIO_DIRECTION_OUTPUT", 1 /* AAUDIO_DIRECTION_OUTPUT + 1 */}, {"AAUDIO_DIRECTION_INPUT", 1}, {"AAUDIO_DIRECTION_INPUT", 2 /* AAUDIO_DIRECTION_INPUT + 1*/}, }; }; return map; return map; } } Loading @@ -169,7 +169,7 @@ const std::unordered_map<std::string, int32_t>& getAAudioPerformanceMode() { // DO NOT MODIFY VALUES(OK to add new ones). // DO NOT MODIFY VALUES(OK to add new ones). // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h static std::unordered_map<std::string, int32_t> map { static std::unordered_map<std::string, int32_t> map { // UNKNOWN is -1 // UNKNOWN is 0 {"AAUDIO_PERFORMANCE_MODE_NONE", 10}, {"AAUDIO_PERFORMANCE_MODE_NONE", 10}, {"AAUDIO_PERFORMANCE_MODE_POWER_SAVING", 11}, {"AAUDIO_PERFORMANCE_MODE_POWER_SAVING", 11}, {"AAUDIO_PERFORMANCE_MODE_LOW_LATENCY", 12}, {"AAUDIO_PERFORMANCE_MODE_LOW_LATENCY", 12}, Loading @@ -181,9 +181,9 @@ const std::unordered_map<std::string, int32_t>& getAAudioSharingMode() { // DO NOT MODIFY VALUES(OK to add new ones). // DO NOT MODIFY VALUES(OK to add new ones). // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h static std::unordered_map<std::string, int32_t> map { static std::unordered_map<std::string, int32_t> map { // UNKNOWN is -1 // UNKNOWN is 0 {"AAUDIO_SHARING_MODE_EXCLUSIVE", 0}, {"AAUDIO_SHARING_MODE_EXCLUSIVE", 1 /* AAUDIO_SHARING_MODE_EXCLUSIVE + 1 */}, {"AAUDIO_SHARING_MODE_SHARED", 1}, {"AAUDIO_SHARING_MODE_SHARED", 2 /* AAUDIO_SHARING_MODE_SHARED + 1 */}, }; }; return map; return map; } } Loading Loading @@ -484,7 +484,7 @@ int32_t lookup<AAUDIO_DIRECTION>(const std::string &direction) auto& map = getAAudioDirection(); auto& map = getAAudioDirection(); auto it = map.find(direction); auto it = map.find(direction); if (it == map.end()) { if (it == map.end()) { return -1; // return unknown return 0; // return unknown } } return it->second; return it->second; } } Loading @@ -506,7 +506,7 @@ int32_t lookup<AAUDIO_PERFORMANCE_MODE>(const std::string &performanceMode) auto& map = getAAudioPerformanceMode(); auto& map = getAAudioPerformanceMode(); auto it = map.find(performanceMode); auto it = map.find(performanceMode); if (it == map.end()) { if (it == map.end()) { return -1; // return unknown return 0; // return unknown } } return it->second; return it->second; } } Loading @@ -528,7 +528,7 @@ int32_t lookup<AAUDIO_SHARING_MODE>(const std::string &sharingMode) auto& map = getAAudioSharingMode(); auto& map = getAAudioSharingMode(); auto it = map.find(sharingMode); auto it = map.find(sharingMode); if (it == map.end()) { if (it == map.end()) { return -1; // return unknown return 0; // return unknown } } return it->second; return it->second; } } Loading Loading
services/mediametrics/AudioAnalytics.cpp +18 −11 Original line number Original line Diff line number Diff line Loading @@ -140,7 +140,6 @@ static constexpr const char * const AudioDeviceConnectionFields[] = { static constexpr const char * const AAudioStreamFields[] { static constexpr const char * const AAudioStreamFields[] { "mediametrics_aaudiostream_reported", "mediametrics_aaudiostream_reported", "caller_name", "path", "path", "direction", "direction", "frames_per_burst", "frames_per_burst", Loading @@ -156,6 +155,8 @@ static constexpr const char * const AAudioStreamFields[] { "format_app", "format_app", "format_device", "format_device", "log_session_id", "log_session_id", "sample_rate", "content_type", }; }; /** /** Loading Loading @@ -932,12 +933,6 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( const std::shared_ptr<const android::mediametrics::Item> &item, CallerPath path) const { const std::shared_ptr<const android::mediametrics::Item> &item, CallerPath path) const { const std::string& key = item->getKey(); const std::string& key = item->getKey(); std::string callerNameStr; mAudioAnalytics.mAnalyticsState->timeMachine().get( key, AMEDIAMETRICS_PROP_CALLERNAME, &callerNameStr); const auto callerName = types::lookup<types::CALLER_NAME, int32_t>(callerNameStr); std::string directionStr; std::string directionStr; mAudioAnalytics.mAnalyticsState->timeMachine().get( mAudioAnalytics.mAnalyticsState->timeMachine().get( key, AMEDIAMETRICS_PROP_DIRECTION, &directionStr); key, AMEDIAMETRICS_PROP_DIRECTION, &directionStr); Loading Loading @@ -994,8 +989,16 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( std::string logSessionId; std::string logSessionId; // TODO: log logSessionId // TODO: log logSessionId int32_t sampleRate = 0; mAudioAnalytics.mAnalyticsState->timeMachine().get( key, AMEDIAMETRICS_PROP_SAMPLERATE, &sampleRate); std::string contentTypeStr; mAudioAnalytics.mAnalyticsState->timeMachine().get( key, AMEDIAMETRICS_PROP_CONTENTTYPE, &contentTypeStr); const auto contentType = types::lookup<types::CONTENT_TYPE, int32_t>(contentTypeStr); LOG(LOG_LEVEL) << "key:" << key LOG(LOG_LEVEL) << "key:" << key << " caller_name:" << callerName << "(" << callerNameStr << ")" << " path:" << path << " path:" << path << " direction:" << direction << "(" << directionStr << ")" << " direction:" << direction << "(" << directionStr << ")" << " frames_per_burst:" << framesPerBurst << " frames_per_burst:" << framesPerBurst Loading @@ -1010,14 +1013,15 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( << " device_type:" << serializedDeviceTypes << " device_type:" << serializedDeviceTypes << " format_app:" << formatApp << " format_app:" << formatApp << " format_device: " << formatDevice << "(" << formatDeviceStr << ")" << " format_device: " << formatDevice << "(" << formatDeviceStr << ")" << " log_session_id: " << logSessionId; << " log_session_id: " << logSessionId << " sample_rate: " << sampleRate << " content_type: " << contentType << "(" << contentTypeStr << ")"; if (mAudioAnalytics.mDeliverStatistics) { if (mAudioAnalytics.mDeliverStatistics) { android::util::BytesField bf_serialized( android::util::BytesField bf_serialized( serializedDeviceTypes.c_str(), serializedDeviceTypes.size()); serializedDeviceTypes.c_str(), serializedDeviceTypes.size()); const auto result = sendToStatsd( const auto result = sendToStatsd( CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED) CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED) , callerName , path , path , direction , direction , framesPerBurst , framesPerBurst Loading @@ -1033,12 +1037,13 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( , formatApp , formatApp , formatDevice , formatDevice , logSessionId.c_str() , logSessionId.c_str() , sampleRate , contentType ); ); std::stringstream ss; std::stringstream ss; ss << "result:" << result; ss << "result:" << result; const auto fieldsStr = printFields(AAudioStreamFields, const auto fieldsStr = printFields(AAudioStreamFields, CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED) CONDITION(android::util::MEDIAMETRICS_AAUDIOSTREAM_REPORTED) , callerName , path , path , direction , direction , framesPerBurst , framesPerBurst Loading @@ -1054,6 +1059,8 @@ void AudioAnalytics::AAudioStreamInfo::endAAudioStream( , formatApp , formatApp , formatDevice , formatDevice , logSessionId.c_str() , logSessionId.c_str() , sampleRate , contentType ); ); ss << " " << fieldsStr; ss << " " << fieldsStr; std::string str = ss.str(); std::string str = ss.str(); Loading
services/mediametrics/AudioTypes.cpp +10 −10 Original line number Original line Diff line number Diff line Loading @@ -158,9 +158,9 @@ const std::unordered_map<std::string, int32_t>& getAAudioDirection() { // DO NOT MODIFY VALUES(OK to add new ones). // DO NOT MODIFY VALUES(OK to add new ones). // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h static std::unordered_map<std::string, int32_t> map { static std::unordered_map<std::string, int32_t> map { // UNKNOWN is -1 // UNKNOWN is 0 {"AAUDIO_DIRECTION_OUTPUT", 0}, {"AAUDIO_DIRECTION_OUTPUT", 1 /* AAUDIO_DIRECTION_OUTPUT + 1 */}, {"AAUDIO_DIRECTION_INPUT", 1}, {"AAUDIO_DIRECTION_INPUT", 2 /* AAUDIO_DIRECTION_INPUT + 1*/}, }; }; return map; return map; } } Loading @@ -169,7 +169,7 @@ const std::unordered_map<std::string, int32_t>& getAAudioPerformanceMode() { // DO NOT MODIFY VALUES(OK to add new ones). // DO NOT MODIFY VALUES(OK to add new ones). // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h static std::unordered_map<std::string, int32_t> map { static std::unordered_map<std::string, int32_t> map { // UNKNOWN is -1 // UNKNOWN is 0 {"AAUDIO_PERFORMANCE_MODE_NONE", 10}, {"AAUDIO_PERFORMANCE_MODE_NONE", 10}, {"AAUDIO_PERFORMANCE_MODE_POWER_SAVING", 11}, {"AAUDIO_PERFORMANCE_MODE_POWER_SAVING", 11}, {"AAUDIO_PERFORMANCE_MODE_LOW_LATENCY", 12}, {"AAUDIO_PERFORMANCE_MODE_LOW_LATENCY", 12}, Loading @@ -181,9 +181,9 @@ const std::unordered_map<std::string, int32_t>& getAAudioSharingMode() { // DO NOT MODIFY VALUES(OK to add new ones). // DO NOT MODIFY VALUES(OK to add new ones). // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h // This may be found in frameworks/av/media/libaaudio/include/aaudio/AAudio.h static std::unordered_map<std::string, int32_t> map { static std::unordered_map<std::string, int32_t> map { // UNKNOWN is -1 // UNKNOWN is 0 {"AAUDIO_SHARING_MODE_EXCLUSIVE", 0}, {"AAUDIO_SHARING_MODE_EXCLUSIVE", 1 /* AAUDIO_SHARING_MODE_EXCLUSIVE + 1 */}, {"AAUDIO_SHARING_MODE_SHARED", 1}, {"AAUDIO_SHARING_MODE_SHARED", 2 /* AAUDIO_SHARING_MODE_SHARED + 1 */}, }; }; return map; return map; } } Loading Loading @@ -484,7 +484,7 @@ int32_t lookup<AAUDIO_DIRECTION>(const std::string &direction) auto& map = getAAudioDirection(); auto& map = getAAudioDirection(); auto it = map.find(direction); auto it = map.find(direction); if (it == map.end()) { if (it == map.end()) { return -1; // return unknown return 0; // return unknown } } return it->second; return it->second; } } Loading @@ -506,7 +506,7 @@ int32_t lookup<AAUDIO_PERFORMANCE_MODE>(const std::string &performanceMode) auto& map = getAAudioPerformanceMode(); auto& map = getAAudioPerformanceMode(); auto it = map.find(performanceMode); auto it = map.find(performanceMode); if (it == map.end()) { if (it == map.end()) { return -1; // return unknown return 0; // return unknown } } return it->second; return it->second; } } Loading @@ -528,7 +528,7 @@ int32_t lookup<AAUDIO_SHARING_MODE>(const std::string &sharingMode) auto& map = getAAudioSharingMode(); auto& map = getAAudioSharingMode(); auto it = map.find(sharingMode); auto it = map.find(sharingMode); if (it == map.end()) { if (it == map.end()) { return -1; // return unknown return 0; // return unknown } } return it->second; return it->second; } } Loading