Merge "Playback activity monitor: fix MediaPlayer / AudioTrack reporting" into sc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
2fd099f165
@@ -181,6 +181,21 @@ public final class AudioPlaybackConfiguration implements Parcelable {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface PlayerState {}
|
||||
|
||||
/** @hide */
|
||||
public static String playerStateToString(@PlayerState int state) {
|
||||
switch (state) {
|
||||
case PLAYER_STATE_UNKNOWN: return "PLAYER_STATE_UNKNOWN";
|
||||
case PLAYER_STATE_RELEASED: return "PLAYER_STATE_RELEASED";
|
||||
case PLAYER_STATE_IDLE: return "PLAYER_STATE_IDLE";
|
||||
case PLAYER_STATE_STARTED: return "PLAYER_STATE_STARTED";
|
||||
case PLAYER_STATE_PAUSED: return "PLAYER_STATE_PAUSED";
|
||||
case PLAYER_STATE_STOPPED: return "PLAYER_STATE_STOPPED";
|
||||
case PLAYER_UPDATE_DEVICE_ID: return "PLAYER_UPDATE_DEVICE_ID";
|
||||
default:
|
||||
return "invalid state " + state;
|
||||
}
|
||||
}
|
||||
|
||||
// immutable data
|
||||
private final int mPlayerIId;
|
||||
|
||||
|
||||
@@ -2726,8 +2726,10 @@ public class AudioTrack extends PlayerBase
|
||||
}
|
||||
}
|
||||
synchronized(mPlayStateLock) {
|
||||
baseStart(0); // unknown device at this point
|
||||
native_start();
|
||||
baseStart(native_getRoutedDeviceId());
|
||||
// FIXME see b/179218630
|
||||
//baseStart(native_getRoutedDeviceId());
|
||||
if (mPlayState == PLAYSTATE_PAUSED_STOPPING) {
|
||||
mPlayState = PLAYSTATE_STOPPING;
|
||||
} else {
|
||||
|
||||
@@ -1356,6 +1356,7 @@ public class MediaPlayer extends PlayerBase
|
||||
}
|
||||
|
||||
private void startImpl() {
|
||||
baseStart(0); // unknown device at this point
|
||||
stayAwake(true);
|
||||
_start();
|
||||
}
|
||||
@@ -1381,6 +1382,7 @@ public class MediaPlayer extends PlayerBase
|
||||
public void stop() throws IllegalStateException {
|
||||
stayAwake(false);
|
||||
_stop();
|
||||
baseStop();
|
||||
}
|
||||
|
||||
private native void _stop() throws IllegalStateException;
|
||||
@@ -1394,6 +1396,7 @@ public class MediaPlayer extends PlayerBase
|
||||
public void pause() throws IllegalStateException {
|
||||
stayAwake(false);
|
||||
_pause();
|
||||
basePause();
|
||||
}
|
||||
|
||||
private native void _pause() throws IllegalStateException;
|
||||
@@ -3479,7 +3482,8 @@ public class MediaPlayer extends PlayerBase
|
||||
case MEDIA_STOPPED:
|
||||
{
|
||||
tryToDisableNativeRoutingCallback();
|
||||
baseStop();
|
||||
// FIXME see b/179218630
|
||||
//baseStop();
|
||||
TimeProvider timeProvider = mTimeProvider;
|
||||
if (timeProvider != null) {
|
||||
timeProvider.onStopped();
|
||||
@@ -3489,15 +3493,17 @@ public class MediaPlayer extends PlayerBase
|
||||
|
||||
case MEDIA_STARTED:
|
||||
{
|
||||
baseStart(native_getRoutedDeviceId());
|
||||
// FIXME see b/179218630
|
||||
//baseStart(native_getRoutedDeviceId());
|
||||
tryToEnableNativeRoutingCallback();
|
||||
}
|
||||
// fall through
|
||||
case MEDIA_PAUSED:
|
||||
{
|
||||
if (msg.what == MEDIA_PAUSED) {
|
||||
basePause();
|
||||
}
|
||||
// FIXME see b/179218630
|
||||
//if (msg.what == MEDIA_PAUSED) {
|
||||
// basePause();
|
||||
//}
|
||||
TimeProvider timeProvider = mTimeProvider;
|
||||
if (timeProvider != null) {
|
||||
timeProvider.onPaused(msg.what == MEDIA_PAUSED);
|
||||
|
||||
@@ -264,8 +264,8 @@ public final class PlaybackActivityMonitor
|
||||
*/
|
||||
public void playerEvent(int piid, int event, int deviceId, int binderUid) {
|
||||
if (DEBUG) {
|
||||
Log.v(TAG, String.format("playerEvent(piid=%d, deviceId=%d, event=%d)",
|
||||
piid, deviceId, event));
|
||||
Log.v(TAG, String.format("playerEvent(piid=%d, deviceId=%d, event=%s)",
|
||||
piid, deviceId, AudioPlaybackConfiguration.playerStateToString(event)));
|
||||
}
|
||||
final boolean change;
|
||||
synchronized(mPlayerLock) {
|
||||
|
||||
Reference in New Issue
Block a user