Snap for 10162339 from 53ac8c773c6601a8d4e98db50dad3c390f717f7c to udc-release

Change-Id: Ic851c4bb9df1fcf4983f120247adabcbd71e728e
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp
index 8acc499..5df053d 100644
--- a/src/android/AudioPlayer_to_android.cpp
+++ b/src/android/AudioPlayer_to_android.cpp
@@ -1609,19 +1609,23 @@
         checkAndSetPerformanceModePre(pAudioPlayer);
 
         audio_output_flags_t policy;
+        audio_flags_mask_t attrFlags = AUDIO_FLAG_NONE;
         switch (pAudioPlayer->mPerformanceMode) {
         case ANDROID_PERFORMANCE_MODE_POWER_SAVING:
             policy = AUDIO_OUTPUT_FLAG_DEEP_BUFFER;
+            attrFlags = static_cast<audio_flags_mask_t>(attrFlags | AUDIO_FLAG_DEEP_BUFFER);
             break;
         case ANDROID_PERFORMANCE_MODE_NONE:
             policy = AUDIO_OUTPUT_FLAG_NONE;
             break;
         case ANDROID_PERFORMANCE_MODE_LATENCY_EFFECTS:
             policy = AUDIO_OUTPUT_FLAG_FAST;
+            attrFlags = static_cast<audio_flags_mask_t>(attrFlags | AUDIO_FLAG_LOW_LATENCY);
             break;
         case ANDROID_PERFORMANCE_MODE_LATENCY:
         default:
             policy = (audio_output_flags_t)(AUDIO_OUTPUT_FLAG_FAST | AUDIO_OUTPUT_FLAG_RAW);
+            attrFlags = static_cast<audio_flags_mask_t>(attrFlags | AUDIO_FLAG_LOW_LATENCY);
             break;
         }
 
@@ -1633,9 +1637,13 @@
         } else {
             notificationFrames = 0;
         }
+        audio_attributes_t attributes = AUDIO_ATTRIBUTES_INITIALIZER;
+        attributes.usage = usageForStreamType(pAudioPlayer->mStreamType);
+        attributes.flags = attrFlags;
+
         const auto callbackHandle = android::sp<android::AudioTrackCallback>::make(pAudioPlayer);
         const auto pat = android::sp<android::AudioTrack>::make(
-                pAudioPlayer->mStreamType,                           // streamType
+                AUDIO_STREAM_DEFAULT,                                // streamType
                 sampleRate,                                          // sampleRate
                 sles_to_android_sampleFormat(df_pcm),                // format
                 channelMask,                                         // channel mask
@@ -1643,7 +1651,12 @@
                 policy,                                              // flags
                 callbackHandle,                                      // callback
                 notificationFrames,                                  // see comment above
-                pAudioPlayer->mSessionId);
+                pAudioPlayer->mSessionId,
+                android::AudioTrack::TRANSFER_DEFAULT,               // transferType
+                nullptr,                                             // offloadInfo
+                AttributionSourceState(),                            // attributionSource
+                &attributes                                          // pAttributes
+                );
 
         // Set it here so it can be logged by the destructor if the open failed.
         pat->setCallerName(ANDROID_OPENSLES_CALLER_NAME);