// invalid command, drop it
return;
}
- if ((mStateFlags & kFlagSeeking) && (timeMsec == mSeekTimeMsec)) {
- // already seeking to the same time, cancel this command
+ if ((mStateFlags & kFlagSeeking) && (timeMsec == mSeekTimeMsec) &&
+ (timeMsec != ANDROID_UNKNOWN_TIME)) {
+ // already seeking to the same non-unknown time, cancel this command
return;
} else if (mStateFlags & kFlagPreparedUnsuccessfully) {
// discard seeks after unsuccessful prepare
if (msg->findInt64(WHATPARAM_SEEK_SEEKTIME_MS, &timeMsec) && (mPlayer != 0)) {
mStateFlags |= kFlagSeeking;
mSeekTimeMsec = (int32_t)timeMsec;
- if (OK != mPlayer->seekTo(timeMsec)) {
+ // seek to unknown time is used by StreamPlayer after discontinuity
+ if (timeMsec == ANDROID_UNKNOWN_TIME) {
+ // FIXME simulate a MEDIA_SEEK_COMPLETE event in 250 ms;
+ // this is a terrible hack to make up for mediaserver not sending one
+ (new AMessage(kWhatSeekComplete, id()))->post(250000);
+ } else if (OK != mPlayer->seekTo(timeMsec)) {
mStateFlags &= ~kFlagSeeking;
mSeekTimeMsec = ANDROID_UNKNOWN_TIME;
}
void GenericPlayer::seek(int64_t timeMsec) {
SL_LOGV("GenericPlayer::seek %lld", timeMsec);
- if (timeMsec < 0) {
+ if (timeMsec < 0 && timeMsec != ANDROID_UNKNOWN_TIME) {
SL_LOGE("GenericPlayer::seek error, can't seek to negative time %lldms", timeMsec);
return;
}
virtual void play();
virtual void pause();
virtual void stop();
+ // timeMsec must be >= 0 or == ANDROID_UNKNOWN_TIME (used by StreamPlayer after discontinuity)
virtual void seek(int64_t timeMsec);
virtual void loop(bool loop);
virtual void setBufferingUpdateThreshold(int16_t thresholdPercent);
msg->setInt32(IStreamListener::kKeyFormatChange, (int32_t) 1);
receivedCmd_l(IStreamListener::DISCONTINUITY, msg /*msg*/);
}
+ if (oldFront->mItems.mTsCmdData.mTsCmdCode & (ANDROID_MP2TSEVENT_DISCONTINUITY |
+ ANDROID_MP2TSEVENT_DISCON_NEWPTS | ANDROID_MP2TSEVENT_FORMAT_CHANGE)) {
+ // FIXME see note at onSeek
+ mPlayer->seek(ANDROID_UNKNOWN_TIME);
+ }
oldFront->mItems.mTsCmdData.mTsCmdCode = ANDROID_MP2TSEVENT_NONE;
}