Bug 1121692 - Clean up semantics around m{Audio,Video}IsSeeking. r=mattwoodrow

The comments indicate that they're supposed to be used for setting mDiscontinuity
on the samples, but that never actually happens (and appears to happen in
MP4Reader.cpp). Resetting them in Request{Audio,Video}Data doesn't make any sense
at all. So we repurpose them to track our seek stage.
This commit is contained in:
Bobby Holley 2015-01-16 10:58:00 -08:00
parent 5c8c8f53b7
commit 500974f144
2 changed files with 29 additions and 17 deletions

View File

@ -50,12 +50,12 @@ MediaSourceReader::MediaSourceReader(MediaSourceDecoder* aDecoder)
, mLastVideoTime(0)
, mPendingSeekTime(-1)
, mWaitingForSeekData(false)
, mAudioIsSeeking(false)
, mVideoIsSeeking(false)
, mTimeThreshold(-1)
, mDropAudioBeforeThreshold(false)
, mDropVideoBeforeThreshold(false)
, mEnded(false)
, mAudioIsSeeking(false)
, mVideoIsSeeking(false)
, mHasEssentialTrackBuffers(false)
#ifdef MOZ_FMP4
, mSharedDecoderManager(new SharedDecoderManager())
@ -118,7 +118,7 @@ MediaSourceReader::RequestAudioData()
mAudioPromise.Reject(DECODE_ERROR, __func__);
return p;
}
mAudioIsSeeking = false;
MOZ_ASSERT(!mAudioIsSeeking);
if (SwitchAudioReader(mLastAudioTime)) {
mAudioReader->Seek(mLastAudioTime, 0)
->Then(GetTaskQueue(), __func__, this,
@ -252,7 +252,7 @@ MediaSourceReader::RequestVideoData(bool aSkipToNextKeyframe, int64_t aTimeThres
mDropAudioBeforeThreshold = true;
mDropVideoBeforeThreshold = true;
}
mVideoIsSeeking = false;
MOZ_ASSERT(!mVideoIsSeeking);
if (SwitchVideoReader(mLastVideoTime)) {
mVideoReader->Seek(mLastVideoTime, 0)
->Then(GetTaskQueue(), __func__, this,
@ -655,6 +655,10 @@ void
MediaSourceReader::OnVideoSeekCompleted(int64_t aTime)
{
mPendingSeekTime = aTime;
MOZ_ASSERT(mVideoIsSeeking);
MOZ_ASSERT(!mAudioIsSeeking);
mVideoIsSeeking = false;
if (mAudioTrack) {
mAudioIsSeeking = true;
SwitchAudioReader(mPendingSeekTime);
@ -671,18 +675,32 @@ MediaSourceReader::OnVideoSeekCompleted(int64_t aTime)
void
MediaSourceReader::OnAudioSeekCompleted(int64_t aTime)
{
mPendingSeekTime = aTime;
MOZ_ASSERT(mAudioIsSeeking);
MOZ_ASSERT(!mVideoIsSeeking);
mAudioIsSeeking = false;
mSeekPromise.Resolve(mPendingSeekTime, __func__);
mPendingSeekTime = -1;
}
void
MediaSourceReader::OnSeekFailed(nsresult aResult)
{
// Keep the most recent failed result (if any)
if (NS_FAILED(aResult)) {
mSeekPromise.Reject(aResult, __func__);
return;
MOZ_ASSERT(mVideoIsSeeking || mAudioIsSeeking);
if (mVideoIsSeeking) {
MOZ_ASSERT(!mAudioIsSeeking);
mVideoIsSeeking = false;
}
mSeekPromise.Resolve(mPendingSeekTime, __func__);
if (mAudioIsSeeking) {
MOZ_ASSERT(!mVideoIsSeeking);
mAudioIsSeeking = false;
}
mPendingSeekTime = -1;
mSeekPromise.Reject(aResult, __func__);
}
void

View File

@ -192,6 +192,8 @@ private:
MediaPromiseHolder<SeekPromise> mSeekPromise;
int64_t mPendingSeekTime;
bool mWaitingForSeekData;
bool mAudioIsSeeking;
bool mVideoIsSeeking;
int64_t mTimeThreshold;
bool mDropAudioBeforeThreshold;
@ -199,14 +201,6 @@ private:
bool mEnded;
// For a seek to complete we need to send a sample with
// the mDiscontinuity field set to true once we have the
// first decoded sample. These flags are set during seeking
// so we can detect when we have the first decoded sample
// after a seek.
bool mAudioIsSeeking;
bool mVideoIsSeeking;
bool mHasEssentialTrackBuffers;
void ContinueShutdown();