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

Commit f4e58509 authored by Oscar Azucena's avatar Oscar Azucena Committed by Android (Google) Code Review
Browse files

Merge "Fixed device info reporting for media player" into sc-dev

parents 24eadb70 7f9d814d
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -3526,8 +3526,9 @@ public class AudioTrack extends PlayerBase
                native_enableDeviceCallback();
                return true;
            } catch (IllegalStateException e) {
                // Fail silently as track state could have changed in between start
                // and enabling routing callback, return false to indicate not enabled
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "testEnableNativeRoutingCallbacks failed", e);
                }
            }
        }
        return false;
@@ -3577,7 +3578,7 @@ public class AudioTrack extends PlayerBase
            Handler handler) {
        synchronized (mRoutingChangeListeners) {
            if (listener != null && !mRoutingChangeListeners.containsKey(listener)) {
                testEnableNativeRoutingCallbacksLocked();
                mEnableSelfRoutingMonitor = testEnableNativeRoutingCallbacksLocked();
                mRoutingChangeListeners.put(
                        listener, new NativeRoutingEventHandlerDelegate(this, listener,
                                handler != null ? handler : new Handler(mInitializationLooper)));
+6 −15
Original line number Diff line number Diff line
@@ -1360,6 +1360,7 @@ public class MediaPlayer extends PlayerBase
    private void startImpl() {
        baseStart(0); // unknown device at this point
        stayAwake(true);
        tryToEnableNativeRoutingCallback();
        _start();
    }

@@ -1385,6 +1386,7 @@ public class MediaPlayer extends PlayerBase
        stayAwake(false);
        _stop();
        baseStop();
        tryToDisableNativeRoutingCallback();
    }

    private native void _stop() throws IllegalStateException;
@@ -1526,8 +1528,9 @@ public class MediaPlayer extends PlayerBase
                native_enableDeviceCallback(true);
                return true;
            } catch (IllegalStateException e) {
                // Fail silently as media player state could have changed in between start
                // and enabling routing callback, return false to indicate not enabled
                if (Log.isLoggable(TAG, Log.DEBUG)) {
                    Log.d(TAG, "testEnableNativeRoutingCallbacks failed", e);
                }
            }
        }
        return false;
@@ -1590,7 +1593,7 @@ public class MediaPlayer extends PlayerBase
            Handler handler) {
        synchronized (mRoutingChangeListeners) {
            if (listener != null && !mRoutingChangeListeners.containsKey(listener)) {
                testEnableNativeRoutingCallbacksLocked();
                mEnableSelfRoutingMonitor = testEnableNativeRoutingCallbacksLocked();
                mRoutingChangeListeners.put(
                        listener, new NativeRoutingEventHandlerDelegate(this, listener,
                                handler != null ? handler : mEventHandler));
@@ -3483,9 +3486,6 @@ public class MediaPlayer extends PlayerBase

            case MEDIA_STOPPED:
                {
                    tryToDisableNativeRoutingCallback();
                    // FIXME see b/179218630
                    //baseStop();
                    TimeProvider timeProvider = mTimeProvider;
                    if (timeProvider != null) {
                        timeProvider.onStopped();
@@ -3494,18 +3494,9 @@ public class MediaPlayer extends PlayerBase
                break;

            case MEDIA_STARTED:
                {
                    // FIXME see b/179218630
                    //baseStart(native_getRoutedDeviceId());
                    tryToEnableNativeRoutingCallback();
                }
                // fall through
            case MEDIA_PAUSED:
                {
                    // FIXME see b/179218630
                    //if (msg.what == MEDIA_PAUSED) {
                    //    basePause();
                    //}
                    TimeProvider timeProvider = mTimeProvider;
                    if (timeProvider != null) {
                        timeProvider.onPaused(msg.what == MEDIA_PAUSED);