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

Commit f689b2e1 authored by Ayan Ghosh's avatar Ayan Ghosh Committed by Steve Kondik
Browse files

Bluetooth: Access mediaplayerlist in synchronized way

Access mediaplayerlist in synchronized way to make sure no transient
update is tried to be worked upon in multithreaded environment.

Change-Id: I0e7810ac89e0ddc19d57b32c679450aa7cb87273
CRs-Fixed: 979840
parent 169748b7
Loading
Loading
Loading
Loading
+73 −67
Original line number Diff line number Diff line
@@ -911,6 +911,7 @@ public class AudioService extends IAudioService.Stub {
     * @hide
     */
    public void addMediaPlayerAndUpdateRemoteController (String packageName) {
        synchronized(mMediaPlayers) {
            Log.v(TAG, "addMediaPlayerAndUpdateRemoteController: size of existing list: " +
                    mMediaPlayers.size());
            boolean playerToAdd = true;
@@ -940,11 +941,13 @@ public class AudioService extends IAudioService.Stub {
            Log.v(TAG, "updating focussed RCC change to RCD: CallingPackageName:"
                    + packageName);
        }
    }

    /**
     * @hide
     */
    public void updateRemoteControllerOnExistingMediaPlayers() {
        synchronized(mMediaPlayers) {
            Log.v(TAG, "updateRemoteControllerOnExistingMediaPlayers: size of Player list: " +
                                                                mMediaPlayers.size());
            if (mMediaPlayers.size() > 0) {
@@ -966,11 +969,13 @@ public class AudioService extends IAudioService.Stub {
                Log.e(TAG, "No RCC entry present to update");
            }
        }
    }

    /**
     * @hide
     */
    public void removeMediaPlayerAndUpdateRemoteController (String packageName) {
        synchronized(mMediaPlayers) {
            Log.v(TAG, "removeMediaPlayerAndUpdateRemoteController: size of existing list: " +
                                                                    mMediaPlayers.size());
            boolean playerToRemove = false;
@@ -1000,6 +1005,7 @@ public class AudioService extends IAudioService.Stub {
            sendBroadcastToAll(intent);
            Log.v(TAG, "Updated List size: " + mMediaPlayers.size());
        }
    }

    private void checkAllAliasStreamVolumes() {
        synchronized (VolumeStreamState.class) {