Update logging logic in AudioStream.
In destructor, it may point to a wrong virtual function for subclasses.
In that case, move the logging logic from destructor of AudioStream to
close_l.
In AudioStream::logOpen, the performance mode is the actual performance
mode instead of the requested one. In that case, log the requested
performance mode when the metric id is set.
Renamed ENCODINGREQUESTED as ENCODINGAPP to make it consitent with atom
definition.
Test: atest MediaMetricsAtomTests
Bug: 185788699
Change-Id: I35b40d7ccd7d135f79bc2c84f7cbfe73946f9d2f
diff --git a/media/libaaudio/src/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index dc961ad..bf07abb 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -100,8 +100,9 @@
const int32_t burstMinMicros = AAudioProperty_getHardwareBurstMinMicros();
int32_t burstMicros = 0;
+ const audio_format_t requestedFormat = getFormat();
// We have to do volume scaling. So we prefer FLOAT format.
- if (getFormat() == AUDIO_FORMAT_DEFAULT) {
+ if (requestedFormat == AUDIO_FORMAT_DEFAULT) {
setFormat(AUDIO_FORMAT_PCM_FLOAT);
}
// Request FLOAT for the shared mixer or the device.
@@ -156,6 +157,12 @@
mMetricsId = std::string(AMEDIAMETRICS_KEY_PREFIX_AUDIO_STREAM)
+ std::to_string(mServiceStreamHandle);
+ android::mediametrics::LogItem(mMetricsId)
+ .set(AMEDIAMETRICS_PROP_PERFORMANCEMODE,
+ AudioGlobal_convertPerformanceModeToText(getPerformanceMode()))
+ .set(AMEDIAMETRICS_PROP_ENCODINGCLIENT,
+ android::toString(requestedFormat).c_str()).record();
+
result = configurationOutput.validate();
if (result != AAUDIO_OK) {
goto error;