mediaplayer2: fix state during transitioning
Test: cts
Bug: 130292355
Change-Id: I18dd97aebe816280abf498a856bb387e73b0511a
diff --git a/media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h b/media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h
index 2993ab1..1e8a1d5 100644
--- a/media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h
+++ b/media/libmediaplayer2/include/mediaplayer2/mediaplayer2.h
@@ -143,6 +143,7 @@
Mutex mNotifyLock;
sp<MediaPlayer2Listener> mListener;
media_player2_internal_states mCurrentState;
+ bool mTransitionToNext;
int64_t mCurrentPosition;
MediaPlayer2SeekMode mCurrentSeekMode;
int64_t mSeekPosition;
diff --git a/media/libmediaplayer2/mediaplayer2.cpp b/media/libmediaplayer2/mediaplayer2.cpp
index c34f1c9..de65f8d 100644
--- a/media/libmediaplayer2/mediaplayer2.cpp
+++ b/media/libmediaplayer2/mediaplayer2.cpp
@@ -241,6 +241,7 @@
mSeekPosition = -1;
mSeekMode = MediaPlayer2SeekMode::SEEK_PREVIOUS_SYNC;
mCurrentState = MEDIA_PLAYER2_IDLE;
+ mTransitionToNext = false;
mLoop = false;
mVolume = 1.0;
mVideoWidth = mVideoHeight = 0;
@@ -389,6 +390,7 @@
return INVALID_OPERATION;
}
mSrcId = srcId;
+ mTransitionToNext = true;
return mPlayer->playNextDataSource(srcId);
}
@@ -568,6 +570,7 @@
mCurrentState = MEDIA_PLAYER2_STATE_ERROR;
} else {
mCurrentState = MEDIA_PLAYER2_PAUSED;
+ mTransitionToNext = false;
}
return ret;
}
@@ -815,6 +818,7 @@
} else {
mPlayer->setListener(NULL);
mCurrentState = MEDIA_PLAYER2_IDLE;
+ mTransitionToNext = false;
}
// setDataSource has to be called again to create a
// new mediaplayer.
@@ -1031,12 +1035,6 @@
mCurrentState = MEDIA_PLAYER2_PREPARED;
}
break;
- case MEDIA2_STARTED:
- ALOGV("MediaPlayer2::notify() started, srcId=%lld", (long long)srcId);
- if (srcId == mSrcId) {
- mCurrentState = MEDIA_PLAYER2_STARTED;
- }
- break;
case MEDIA2_DRM_INFO:
ALOGV("MediaPlayer2::notify() MEDIA2_DRM_INFO(%lld, %d, %d, %d, %p)",
(long long)srcId, msg, ext1, ext2, obj);
@@ -1063,8 +1061,9 @@
if (ext1 != MEDIA2_INFO_VIDEO_TRACK_LAGGING) {
ALOGW("info/warning (%d, %d)", ext1, ext2);
- if (ext1 == MEDIA2_INFO_DATA_SOURCE_START && srcId == mSrcId) {
+ if (ext1 == MEDIA2_INFO_DATA_SOURCE_START && srcId == mSrcId && mTransitionToNext) {
mCurrentState = MEDIA_PLAYER2_STARTED;
+ mTransitionToNext = false;
}
}
break;