Revert^2 "AAudio: add support of Audio Attributes tags"
This reverts commit 1b2a8a5a8e5723512938407fb8636d07f3ef8b97.
Reason for revert: reland with verification
Change-Id: Ic5f9b6b7a23e008c409c489a41d65288b9dcf9e0
diff --git a/services/oboeservice/AAudioServiceEndpoint.cpp b/services/oboeservice/AAudioServiceEndpoint.cpp
index e7d14a0..e49e9e7 100644
--- a/services/oboeservice/AAudioServiceEndpoint.cpp
+++ b/services/oboeservice/AAudioServiceEndpoint.cpp
@@ -25,6 +25,7 @@
#include <sstream>
#include <vector>
+#include <system/aaudio/AAudio.h>
#include <utils/Singleton.h>
@@ -195,20 +196,28 @@
? AAudioConvert_inputPresetToAudioSource(params->getInputPreset())
: AUDIO_SOURCE_DEFAULT;
audio_flags_mask_t flags;
+ std::optional<std::string> optTags = {};
if (direction == AAUDIO_DIRECTION_OUTPUT) {
flags = AAudio_computeAudioFlagsMask(
params->getAllowedCapturePolicy(),
params->getSpatializationBehavior(),
params->isContentSpatialized(),
AUDIO_OUTPUT_FLAG_FAST);
+ optTags = params->getTags();
} else {
flags = static_cast<audio_flags_mask_t>(AUDIO_FLAG_LOW_LATENCY
| AAudioConvert_privacySensitiveToAudioFlagsMask(params->isPrivacySensitive()));
}
- return {
+ audio_attributes_t nativeAttributes = {
.content_type = contentType,
.usage = usage,
.source = source,
.flags = flags,
- .tags = "" };
+ .tags = ""
+ };
+ if (optTags.has_value() && !optTags->empty()) {
+ strncpy(nativeAttributes.tags, optTags.value().c_str(), AAUDIO_ATTRIBUTES_TAGS_MAX_SIZE);
+ nativeAttributes.tags[AAUDIO_ATTRIBUTES_TAGS_MAX_SIZE - 1] = '\0';
+ }
+ return nativeAttributes;
}