Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b5f4ba9c authored by Andy Hung's avatar Andy Hung Committed by Android (Google) Code Review
Browse files

Merge "MediaMetrics: Send playerIId to native AudioTrack" into sc-dev

parents 318641ee 850d0685
Loading
Loading
Loading
Loading
+11 −0
Original line number Diff line number Diff line
@@ -1419,6 +1419,16 @@ static jint android_media_AudioTrack_getDualMonoMode(JNIEnv *env, jobject thiz,
    return nativeToJavaStatus(status);
}

static void android_media_AudioTrack_setPlayerIId(JNIEnv *env, jobject thiz, jint playerIId) {
    sp<AudioTrack> track = getAudioTrack(env, thiz);
    if (track == nullptr) {
        jniThrowException(env, "java/lang/IllegalStateException",
                          "Unable to retrieve AudioTrack pointer for setPlayerIId()");
    }
    ALOGV("%s: playerIId %d", __func__, playerIId);
    track->setPlayerIId(playerIId);
}

// ----------------------------------------------------------------------------
// ----------------------------------------------------------------------------
static const JNINativeMethod gMethods[] = {
@@ -1496,6 +1506,7 @@ static const JNINativeMethod gMethods[] = {
         (void *)android_media_AudioTrack_getAudioDescriptionMixLeveldB},
        {"native_set_dual_mono_mode", "(I)I", (void *)android_media_AudioTrack_setDualMonoMode},
        {"native_get_dual_mono_mode", "([I)I", (void *)android_media_AudioTrack_getDualMonoMode},
        {"native_setPlayerIId", "(I)V", (void *)android_media_AudioTrack_setPlayerIId},
};

// field names found in android/media/AudioTrack.java
+15 −0
Original line number Diff line number Diff line
@@ -837,6 +837,7 @@ public class AudioTrack extends PlayerBase
        }

        baseRegisterPlayer(mSessionId);
        native_setPlayerIId(mPlayerIId); // mPlayerIId now ready to send to native AudioTrack.
    }

    /**
@@ -4203,6 +4204,20 @@ public class AudioTrack extends PlayerBase
    private native int native_set_dual_mono_mode(int dualMonoMode);
    private native int native_get_dual_mono_mode(int[] dualMonoMode);

    /**
     * Sets the audio service Player Interface Id.
     *
     * The playerIId does not change over the lifetime of the client
     * Java AudioTrack and is set automatically on creation.
     *
     * This call informs the native AudioTrack for metrics logging purposes.
     *
     * @param id the value reported by AudioManager when registering the track.
     *           A value of -1 indicates invalid - the playerIId was never set.
     * @throws IllegalStateException if AudioTrack not initialized.
     */
    private native void native_setPlayerIId(int playerIId);

    //---------------------------------------------------------
    // Utility methods
    //------------------
+1 −1
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ public abstract class PlayerBase {

    private final int mImplType;
    // uniquely identifies the Player Interface throughout the system (P I Id)
    private int mPlayerIId = AudioPlaybackConfiguration.PLAYER_PIID_INVALID;
    protected int mPlayerIId = AudioPlaybackConfiguration.PLAYER_PIID_INVALID;

    @GuardedBy("mLock")
    private int mState;