Snap for 10453563 from f683c0e239349b9de71deafa96848391466930a3 to mainline-media-release

Change-Id: I63c8bb4dfb380e083a927eca1145b4b0bf61a7f1
diff --git a/Android.bp b/Android.bp
index a961572..c5e3230 100644
--- a/Android.bp
+++ b/Android.bp
@@ -43,6 +43,9 @@
     symbol_file: "src/libOpenMAXAL.map.txt",
     first_version: "14",
     unversioned_until: "current",
+    export_header_libs: [
+        "libOpenMAXAL_headers",
+    ],
 }
 
 ndk_headers {
@@ -58,6 +61,9 @@
     symbol_file: "src/libOpenSLES.map.txt",
     first_version: "9",
     unversioned_until: "current",
+    export_header_libs: [
+        "libOpenSLES_ndk_headers",
+    ],
 }
 
 cc_library_headers {
diff --git a/TEST_MAPPING b/TEST_MAPPING
index 55bbe66..65fa610 100644
--- a/TEST_MAPPING
+++ b/TEST_MAPPING
@@ -2,13 +2,13 @@
 {
     "presubmit": [
         {
-            "name": "CtsMediaTestCases",
+            "name": "CtsMediaAudioTestCases",
             "options" : [
                 {
                     "include-annotation": "android.platform.test.annotations.Presubmit"
                 },
                 {
-                    "include-filter": "android.media.cts.AudioNativeTest"
+                    "include-filter": "android.media.audio.cts.AudioNativeTest"
                 }
             ]
         }
diff --git a/src/MPH_to.h b/src/MPH_to.h
index 1dc83c4..d922bcd 100644
--- a/src/MPH_to.h
+++ b/src/MPH_to.h
@@ -33,6 +33,6 @@
     MPH_to_MediaPlayer[MPH_MAX];
 
 /** \brief Maximum number of interfaces on a single object. */
-#define MAX_INDEX 32
+#define SLES_MAX_INDEX 32
 
 #endif // !defined(__MPH_to_H)
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp
index ef466b6..5df053d 100644
--- a/src/android/AudioPlayer_to_android.cpp
+++ b/src/android/AudioPlayer_to_android.cpp
@@ -1049,8 +1049,6 @@
     const SLuint32 sinkLocatorType = *(SLuint32 *)pAudioSnk->pLocator;
     const SLuint32 sourceFormatType = *(SLuint32 *)pAudioSrc->pFormat;
 
-    const SLuint32 *df_representation = NULL; // pointer to representation field, if it exists
-
     switch (sourceLocatorType) {
     //------------------
     //   Buffer Queues
@@ -1060,12 +1058,7 @@
         // Buffer format
         switch (sourceFormatType) {
         //     currently only PCM buffer queues are supported,
-        case SL_ANDROID_DATAFORMAT_PCM_EX: {
-            const SLAndroidDataFormat_PCM_EX *df_pcm =
-                    (const SLAndroidDataFormat_PCM_EX *) pAudioSrc->pFormat;
-            // checkDataFormat() already checked representation
-            df_representation = &df_pcm->representation;
-            } // SL_ANDROID_DATAFORMAT_PCM_EX - fall through to next test.
+        case SL_ANDROID_DATAFORMAT_PCM_EX:
             FALLTHROUGH_INTENDED;
         case SL_DATAFORMAT_PCM: {
             // checkDataFormat() already did generic checks, now do the Android-specific checks
@@ -1616,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;
         }
 
@@ -1640,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
@@ -1650,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);
diff --git a/src/android/android_Effect.cpp b/src/android/android_Effect.cpp
index 2b5582f..c87e584 100644
--- a/src/android/android_Effect.cpp
+++ b/src/android/android_Effect.cpp
@@ -677,8 +677,7 @@
 
     effect->set(type, EFFECT_UUID_NULL,
             0,// priority
-            0,// effect callback
-            0,// callback data
+            nullptr,// effect callback
             sessionId,// session ID
             0); // output
 
@@ -826,8 +825,7 @@
     pFx->set(NULL, // not using type to create effect
             (const effect_uuid_t*)pUuid,
             0,// priority
-            0,// effect callback
-            0,// callback data
+            nullptr,// effect callback
             sessionId,
             0 );// output
 
diff --git a/src/sles.cpp b/src/sles.cpp
index 0761d24..6b393dc 100644
--- a/src/sles.cpp
+++ b/src/sles.cpp
@@ -37,7 +37,7 @@
     if (0 > (index = clazz->mMPH_to_index[MPH])) {
         return false;
     }
-    assert(MAX_INDEX >= clazz->mInterfaceCount);
+    assert(SLES_MAX_INDEX >= clazz->mInterfaceCount);
     assert(clazz->mInterfaceCount > (unsigned) index);
     switch (thiz->mInterfaceStates[index]) {
     case INTERFACE_EXPOSED: