summaryrefslogtreecommitdiffstats
path: root/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'media/libmediaplayerservice/nuplayer/NuPlayer.cpp')
-rw-r--r--media/libmediaplayerservice/nuplayer/NuPlayer.cpp35
1 files changed, 29 insertions, 6 deletions
diff --git a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
index 87074f0..a79858c 100644
--- a/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
+++ b/media/libmediaplayerservice/nuplayer/NuPlayer.cpp
@@ -1153,6 +1153,22 @@ void NuPlayer::onMessageReceived(const sp<AMessage> &msg) {
ALOGV("kWhatSeek seekTimeUs=%lld us, needNotify=%d",
(long long)seekTimeUs, needNotify);
+ if (!mStarted) {
+ // Seek before the player is started. In order to preview video,
+ // need to start the player and pause it. This branch is called
+ // only once if needed. After the player is started, any seek
+ // operation will go through normal path.
+ // All cases, including audio-only, are handled in the same way
+ // for the sake of simplicity.
+ onStart(seekTimeUs);
+ onPause();
+ mPausedByClient = true;
+ if (needNotify) {
+ notifyDriverSeekComplete();
+ }
+ break;
+ }
+
mDeferredActions.push_back(
new FlushDecoderAction(FLUSH_CMD_FLUSH /* audio */,
FLUSH_CMD_FLUSH /* video */));
@@ -1246,13 +1262,16 @@ status_t NuPlayer::onInstantiateSecureDecoders() {
return OK;
}
-void NuPlayer::onStart() {
+void NuPlayer::onStart(int64_t startPositionUs) {
mOffloadAudio = false;
mAudioEOS = false;
mVideoEOS = false;
mStarted = true;
mSource->start();
+ if (startPositionUs > 0) {
+ performSeek(startPositionUs);
+ }
uint32_t flags = 0;
@@ -1908,11 +1927,15 @@ void NuPlayer::performResumeDecoders(bool needNotify) {
void NuPlayer::finishResume() {
if (mResumePending) {
mResumePending = false;
- if (mDriver != NULL) {
- sp<NuPlayerDriver> driver = mDriver.promote();
- if (driver != NULL) {
- driver->notifySeekComplete();
- }
+ notifyDriverSeekComplete();
+ }
+}
+
+void NuPlayer::notifyDriverSeekComplete() {
+ if (mDriver != NULL) {
+ sp<NuPlayerDriver> driver = mDriver.promote();
+ if (driver != NULL) {
+ driver->notifySeekComplete();
}
}
}