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

Commit e8b4c97b authored by Wonsik Kim's avatar Wonsik Kim
Browse files

At STARTED_AS_NEXT, offload MediaPlayer.start() to a separate thread

Fixes: 65210445
Fixes: 64915666
Test: adb shell am instrument -e size small -w 'android.media.cts/android.support.test.runner.AndroidJUnitRunner'
Change-Id: I73f1cebdd4b990e28f8d466f129e781cba2b5bbf
parent 9174e877
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -3408,7 +3408,7 @@ public class MediaPlayer extends PlayerBase
    private static void postEventFromNative(Object mediaplayer_ref,
                                            int what, int arg1, int arg2, Object obj)
    {
        MediaPlayer mp = (MediaPlayer)((WeakReference)mediaplayer_ref).get();
        final MediaPlayer mp = (MediaPlayer)((WeakReference)mediaplayer_ref).get();
        if (mp == null) {
            return;
        }
@@ -3416,9 +3416,15 @@ public class MediaPlayer extends PlayerBase
        switch (what) {
        case MEDIA_INFO:
            if (arg1 == MEDIA_INFO_STARTED_AS_NEXT) {
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        // this acquires the wakelock if needed, and sets the client side state
                        mp.start();
                    }
                }).start();
                Thread.yield();
            }
            break;

        case MEDIA_DRM_INFO: