status_t MediaPlayer::seekTo_l(int msec) { LOGV("seekTo %d", msec); if ((mPlayer != 0) && ( mCurrentState & ( MEDIA_PLAYER_STARTED | MEDIA_PLAYER_PREPARED | MEDIA_PLAYER_PAUSED | MEDIA_PLAYER_PLAYBACK_COMPLETE) ) ) { if ( msec < 0 ) { LOGW("Attempt to seek to invalid position: %d", msec); msec = 0; } else if ((mDuration > 0) && (msec > mDuration)) { LOGW("Attempt to seek to past end of file: request = %d, EOF = %d", msec, mDuration); msec = mDuration; } // cache duration mCurrentPosition = msec; if (mSeekPosition < 0) { getDuration_l(NULL); mSeekPosition = msec; return mPlayer->seekTo(msec); } else { LOGV("Seek in progress - queue up seekTo[%d]", msec); return NO_ERROR; } } LOGE("Attempt to perform seekTo in wrong state: mPlayer=%p, mCurrentState=%u", mPlayer.get(), mCurrentState); return INVALID_OPERATION; }
status_t MediaPlayer::getDuration(int *msec) { Mutex::Autolock _l(mLock); return getDuration_l(msec); }
int getDuration(VideoState **ps, int *msec) { return getDuration_l(ps, msec); }