MediaMetrics: Accept elided second argument in string pair
(device, address) string pairs used to have an optional second argument
that was empty.
Before: (d1, )|(d2, a2)
we now permit elision of the second argument entirely, so that
can now be written as
After: d1|(d2, a2)
Note: the prior string continues to be accepted.
Flag: EXEMPT bugfix
Test: atest mediametrics_tests
Test: play ringtone with BT buds and check mediametrics dumpsys
Bug: 376948941
Change-Id: I41fd2f6acf1ea42cc5e683835790769148988b7d
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 060c72b..91c82a2 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -338,28 +338,32 @@
// under #ifdef __cplusplus #endif
static std::string patchSinksToString(const struct audio_patch *patch)
{
- std::stringstream ss;
+ std::string s;
for (size_t i = 0; i < patch->num_sinks; ++i) {
- if (i > 0) {
- ss << "|";
+ if (i > 0) s.append("|");
+ if (patch->sinks[i].ext.device.address[0]) {
+ s.append("(").append(toString(patch->sinks[i].ext.device.type))
+ .append(", ").append(patch->sinks[i].ext.device.address).append(")");
+ } else {
+ s.append(toString(patch->sinks[i].ext.device.type));
}
- ss << "(" << toString(patch->sinks[i].ext.device.type)
- << ", " << patch->sinks[i].ext.device.address << ")";
}
- return ss.str();
+ return s;
}
static std::string patchSourcesToString(const struct audio_patch *patch)
{
- std::stringstream ss;
+ std::string s;
for (size_t i = 0; i < patch->num_sources; ++i) {
- if (i > 0) {
- ss << "|";
+ if (i > 0) s.append("|");
+ if (patch->sources[i].ext.device.address[0]) {
+ s.append("(").append(toString(patch->sources[i].ext.device.type))
+ .append(", ").append(patch->sources[i].ext.device.address).append(")");
+ } else {
+ s.append(toString(patch->sources[i].ext.device.type));
}
- ss << "(" << toString(patch->sources[i].ext.device.type)
- << ", " << patch->sources[i].ext.device.address << ")";
}
- return ss.str();
+ return s;
}
static std::string toString(audio_latency_mode_t mode) {