opensles: call setCallerName() for MediaMetrics

This can be used to tell whether OpenSL ES
created the AudioTrack or AudioRecord object.

Bug: 149850236
Test: adb shell dumpsys media.metrics --clear
Test: Run an app that uses OpenSL ES.
Test: adb shell dumpsys media.metrics
Test: Look for "callerName=opensles" in the dump.
Change-Id: Iabc90299165869f0bc5d4e790f48ac72282c426d
diff --git a/src/android/AudioPlayer_to_android.cpp b/src/android/AudioPlayer_to_android.cpp
index d8940b8..9dc0a8a 100644
--- a/src/android/AudioPlayer_to_android.cpp
+++ b/src/android/AudioPlayer_to_android.cpp
@@ -1695,6 +1695,10 @@
                 (void *) pAudioPlayer,                               // user
                 notificationFrames,                                  // see comment above
                 pAudioPlayer->mSessionId);
+
+        // Set it here so it can be logged by the destructor if the open failed.
+        pat->setCallerName(ANDROID_OPENSLES_CALLER_NAME);
+
         android::status_t status = pat->initCheck();
         if (status != android::NO_ERROR) {
             // AudioTracks are meant to be refcounted, so their dtor is protected.
diff --git a/src/android/AudioRecorder_to_android.cpp b/src/android/AudioRecorder_to_android.cpp
index 4e2f31d..2595112 100644
--- a/src/android/AudioRecorder_to_android.cpp
+++ b/src/android/AudioRecorder_to_android.cpp
@@ -703,6 +703,9 @@
                                    // transfer type
             policy);               // audio_input_flags_t
 
+    // Set it here so it can be logged by the destructor if the open failed.
+    ar->mAudioRecord->setCallerName(ANDROID_OPENSLES_CALLER_NAME);
+
     android::status_t status = ar->mAudioRecord->initCheck();
     if (android::NO_ERROR != status) {
         SL_LOGE("android_audioRecorder_realize(%p) error creating AudioRecord object; status %d",
diff --git a/src/android/android_defs.h b/src/android/android_defs.h
index 8b28983..daa7b70 100644
--- a/src/android/android_defs.h
+++ b/src/android/android_defs.h
@@ -221,5 +221,7 @@
                                       ANDROID_PERFORMANCE_MODE_NONE | \
                                       ANDROID_PERFORMANCE_MODE_POWER_SAVING)
 
+// This is used for exact matching by MediaMetrics. So do not change it.
+#define ANDROID_OPENSLES_CALLER_NAME       "opensles"
 
 } // namespace android