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

This commit is contained in:
Oscar Azucena
2021-02-26 03:05:07 +00:00
committed by Android (Google) Code Review
2 changed files with 10 additions and 18 deletions

View File

@@ -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)));

View File

@@ -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);