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

Commit 4e4d015b authored by Eric Laurent's avatar Eric Laurent Committed by Automerger Merge Worker
Browse files

Merge "AudioPlaybackConfiguration: add audio session ID" into sc-dev am: 25ffe6ce

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/13437587

MUST ONLY BE SUBMITTED BY AUTOMERGER

Change-Id: If7d2137290c0e4d6baed52eb36cdd78766f0df3c
parents e5b81534 25ffe6ce
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -4972,6 +4972,7 @@ package android.media {
    method public android.media.PlayerProxy getPlayerProxy();
    method public int getPlayerState();
    method public int getPlayerType();
    method @IntRange(from=0) public int getSessionId();
    method public boolean isActive();
    field public static final int PLAYER_STATE_IDLE = 1; // 0x1
    field public static final int PLAYER_STATE_PAUSED = 3; // 0x3
+39 −4
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ import static android.media.AudioAttributes.ALLOW_CAPTURE_BY_ALL;
import static android.media.AudioAttributes.ALLOW_CAPTURE_BY_NONE;

import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
@@ -195,6 +196,8 @@ public final class AudioPlaybackConfiguration implements Parcelable {

    private int mDeviceId;

    private int mSessionId;

    /**
     * Never use without initializing parameters afterwards
     */
@@ -207,7 +210,10 @@ public final class AudioPlaybackConfiguration implements Parcelable {
     * @hide
     */
    public AudioPlaybackConfiguration(PlayerBase.PlayerIdCard pic, int piid, int uid, int pid) {
        if (DEBUG) { Log.d(TAG, "new: piid=" + piid + " iplayer=" + pic.mIPlayer); }
        if (DEBUG) {
            Log.d(TAG, "new: piid=" + piid + " iplayer=" + pic.mIPlayer
                    + " sessionId=" + pic.mSessionId);
        }
        mPlayerIId = piid;
        mPlayerType = pic.mPlayerType;
        mClientUid = uid;
@@ -220,6 +226,7 @@ public final class AudioPlaybackConfiguration implements Parcelable {
        } else {
            mIPlayerShell = null;
        }
        mSessionId = pic.mSessionId;
    }

    /**
@@ -259,6 +266,7 @@ public final class AudioPlaybackConfiguration implements Parcelable {
        anonymCopy.mClientUid = PLAYER_UPID_INVALID;
        anonymCopy.mClientPid = PLAYER_UPID_INVALID;
        anonymCopy.mIPlayerShell = null;
        anonymCopy.mSessionId = AudioSystem.AUDIO_SESSION_ALLOCATE;
        return anonymCopy;
    }

@@ -301,6 +309,17 @@ public final class AudioPlaybackConfiguration implements Parcelable {
        return AudioManager.getDeviceForPortId(mDeviceId, AudioManager.GET_DEVICES_OUTPUTS);
    }

    /**
     * @hide
     * Return the audio session ID associated with this player.
     * See {@link AudioManager#generateAudioSessionId()}.
     * @return an audio session ID
     */
    @SystemApi
    public @IntRange(from = 0) int getSessionId() {
        return mSessionId;
    }

    /**
     * @hide
     * Return the type of player linked to this configuration.
@@ -379,6 +398,17 @@ public final class AudioPlaybackConfiguration implements Parcelable {
        return changed;
    }

    /**
     * @hide
     * Handle a change of audio session Id
     * @param sessionId the audio session ID
     */
    public boolean handleSessionIdEvent(int sessionId) {
        final boolean changed = sessionId != mSessionId;
        mSessionId = sessionId;
        return changed;
    }

    /**
     * @hide
     * Handle a player state change
@@ -476,7 +506,8 @@ public final class AudioPlaybackConfiguration implements Parcelable {

    @Override
    public int hashCode() {
        return Objects.hash(mPlayerIId, mDeviceId, mPlayerType, mClientUid, mClientPid);
        return Objects.hash(mPlayerIId, mDeviceId, mPlayerType, mClientUid, mClientPid,
                mSessionId);
    }

    @Override
@@ -498,6 +529,7 @@ public final class AudioPlaybackConfiguration implements Parcelable {
            ips = mIPlayerShell;
        }
        dest.writeStrongInterface(ips == null ? null : ips.getIPlayer());
        dest.writeInt(mSessionId);
    }

    private AudioPlaybackConfiguration(Parcel in) {
@@ -510,6 +542,7 @@ public final class AudioPlaybackConfiguration implements Parcelable {
        mPlayerAttr = AudioAttributes.CREATOR.createFromParcel(in);
        final IPlayer p = IPlayer.Stub.asInterface(in.readStrongBinder());
        mIPlayerShell = (p == null) ? null : new IPlayerShell(null, p);
        mSessionId = in.readInt();
    }

    @Override
@@ -523,7 +556,8 @@ public final class AudioPlaybackConfiguration implements Parcelable {
                && (mDeviceId == that.mDeviceId)
                && (mPlayerType == that.mPlayerType)
                && (mClientUid == that.mClientUid)
                && (mClientPid == that.mClientPid));
                && (mClientPid == that.mClientPid))
                && (mSessionId == that.mSessionId);
    }

    @Override
@@ -533,7 +567,8 @@ public final class AudioPlaybackConfiguration implements Parcelable {
                + " type:" + toLogFriendlyPlayerType(mPlayerType)
                + " u/pid:" + mClientUid + "/" + mClientPid
                + " state:" + toLogFriendlyPlayerState(mPlayerState)
                + " attr:" + mPlayerAttr;
                + " attr:" + mPlayerAttr
                + " sessionId:" + mSessionId;
    }

    //=====================================================================
+2 −2
Original line number Diff line number Diff line
@@ -836,7 +836,7 @@ public class AudioTrack extends PlayerBase
            mState = STATE_INITIALIZED;
        }

        baseRegisterPlayer();
        baseRegisterPlayer(mSessionId);
    }

    /**
@@ -866,7 +866,7 @@ public class AudioTrack extends PlayerBase

        // other initialization...
        if (nativeTrackInJavaObj != 0) {
            baseRegisterPlayer();
            baseRegisterPlayer(AudioSystem.AUDIO_SESSION_ALLOCATE);
            deferred_connect(nativeTrackInJavaObj);
        } else {
            mState = STATE_UNINITIALIZED;
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ public class HwAudioSource extends PlayerBase {
        Preconditions.checkArgument(device.isSource(), "Requires a source device");
        mAudioDeviceInfo = device;
        mAudioAttributes = attributes;
        baseRegisterPlayer();
        baseRegisterPlayer(AudioSystem.AUDIO_SESSION_ALLOCATE);
    }

    /**
+2 −0
Original line number Diff line number Diff line
@@ -73,6 +73,8 @@ interface IAudioService {

    oneway void releaseRecorder(in int riid);

    oneway void playerSessionId(in int piid, in int sessionId);

    // Java-only methods below.

    oneway void adjustSuggestedStreamVolume(int direction, int suggestedStreamType, int flags,
Loading