Closed Bug 1282658 Opened 9 years ago Closed 9 years ago

Some AccurateSeekTask code cleanup

Categories

(Core :: Audio/Video: Playback, defect, P3)

defect

Tracking

()

RESOLVED FIXED
mozilla50
Tracking Status
firefox50 --- fixed

People

(Reporter: jwwang, Assigned: jwwang)

References

Details

Attachments

(17 files)

58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
58 bytes, text/x-review-board-request
kaku
: review+
Details
No description provided.
Attachment #8766617 - Flags: review?(kaku)
Attachment #8766618 - Flags: review?(kaku)
Attachment #8766619 - Flags: review?(kaku)
Attachment #8766620 - Flags: review?(kaku)
Attachment #8766621 - Flags: review?(kaku)
Attachment #8766622 - Flags: review?(kaku)
Attachment #8766623 - Flags: review?(kaku)
Attachment #8766624 - Flags: review?(kaku)
Attachment #8766625 - Flags: review?(kaku)
Attachment #8766626 - Flags: review?(kaku)
Attachment #8766627 - Flags: review?(kaku)
Attachment #8766628 - Flags: review?(kaku)
Attachment #8766629 - Flags: review?(kaku)
Attachment #8766630 - Flags: review?(kaku)
Attachment #8766631 - Flags: review?(kaku)
Attachment #8766632 - Flags: review?(kaku)
1. On{Audio,Video}[Not]Decoded() is always called after Seek() and before mSeekTaskPromise is resolved or rejected. So mSeekTaskPromise should be never empty and Exists() should be always true. 2. Is{Audio,Video}SeekComplete is called by On{Audio,Video}[Not]Decoded() where Exists should be always true. Review commit: https://reviewboard.mozilla.org/r/61442/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/61442/
Ensure{Audio,Video}DecodeTaskQueued() is always called after OnSeekResolved() where mSeekRequest is completed. So |mSeekRequest.Exists()| should be always false in Ensure{Audio,Video}DecodeTaskQueued(). Review commit: https://reviewboard.mozilla.org/r/61450/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/61450/
We need to request another audio sample in OnAudioDecoded() only when mDoneAudioSeeking is false which also applies OnVideoDecodd(). Therefore we remove calls to Ensure{Audio,Video}DecodeTaskQueued() from CheckIfSeekComplete() to prevent requesting video samples inside OnAudioDecoded() for they will be handled by OnVideoDecodd(). This also allows us to remove checking of mReader->IsRequesting{Audio,Video}Data() from Ensure{Audio,Video}DecodeTaskQueued(). Review commit: https://reviewboard.mozilla.org/r/61468/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/61468/
EnsureAudioDecodeTaskQueued() is called from several places where mReader->IsWaitingAudioData() can be proven to be false: 1. OnAudioDecoded() - definitely false. 2. OnNotDecoded() - false because aReason is MediaDecoderReader::CANCELED. 3. OnSeekResolved() - false becuase we haven't requested any samples. 4. SetCallbacks() - false because AudioWaitCallback is resolved. Review commit: https://reviewboard.mozilla.org/r/61470/diff/#index_header See other reviews: https://reviewboard.mozilla.org/r/61470/
Blocks: 1283751
Attachment #8766617 - Flags: review?(kaku) → review+
Attachment #8766618 - Flags: review?(kaku) → review+
Comment on attachment 8766618 [details] Bug 1282658. Part 2 - remove unnecessary checks for Exists(). https://reviewboard.mozilla.org/r/61442/#review58752
Attachment #8766619 - Flags: review?(kaku) → review+
Comment on attachment 8766620 [details] Bug 1282658. Part 4 - simplify logic of checking whether if audio/video seeking is completed. . https://reviewboard.mozilla.org/r/61446/#review58758 ::: dom/media/AccurateSeekTask.cpp:514 (Diff revision 1) > EnsureAudioDecodeTaskQueued(); > return; > } > > if (aReason == MediaDecoderReader::END_OF_STREAM) { > - mIsAudioQueueFinished = true; > + mDoneAudioSeeking = true; We need to keep the "{audio,video} queue finished" information. So that we can notify the MDSM. ::: dom/media/AccurateSeekTask.cpp (Diff revision 1) > // below. > mSeekedVideoData = mFirstVideoFrameAfterSeek; > mFirstVideoFrameAfterSeek = nullptr; > } > - > + mDoneVideoSeeking = true; > - mIsVideoQueueFinished = true; Same to the audio case.
Attachment #8766620 - Flags: review?(kaku) → review-
Attachment #8766621 - Flags: review?(kaku) → review+
Attachment #8766622 - Flags: review?(kaku) → review+
Comment on attachment 8766622 [details] Bug 1282658. Part 6 - remove unnecessary checks for |mSeekRequest.Exists()|. . https://reviewboard.mozilla.org/r/61450/#review58988
Attachment #8766623 - Flags: review?(kaku) → review+
Comment on attachment 8766623 [details] Bug 1282658. Part 7 - remove setting mNeedToStopPrerolling{Audio,Video} per discussion in https://reviewboard.mozilla.org/r/43689/#comment54421. https://reviewboard.mozilla.org/r/61452/#review58968 ::: dom/media/AccurateSeekTask.cpp (Diff revision 1) > mReader->WaitForData(MediaData::AUDIO_DATA); > - > - // We are out of data to decode and will enter buffering mode soon. > - // We want to play the frames we have already decoded, so we stop pre-rolling > - // and ensure that loadeddata is fired as required. > - mNeedToStopPrerollingAudio = true; Then, mNeedToStopPrerollingAudio and mNeedToStopPrerollingVideo are not used anymore, they are not used in the NextFrameSeekTask. We could just remove them from the SeekTask.h.
Comment on attachment 8766624 [details] Bug 1282658. Part 8 - remove asserting |mReader->IsWaitForDataSupported()| for mReader->WaitForData() will crash if the method has no override. https://reviewboard.mozilla.org/r/61454/#review58970
Attachment #8766624 - Flags: review?(kaku) → review+
Comment on attachment 8766625 [details] Bug 1282658. Part 9 - return void for Ensure{Audio,Video}DecodeTaskQueued() for they always return NS_OK. . https://reviewboard.mozilla.org/r/61456/#review58990
Attachment #8766625 - Flags: review?(kaku) → review+
Comment on attachment 8766626 [details] Bug 1282658. Part 10 - merge Request{Audio,Video}Data() into Ensure{Audio,Video}DecodeTaskQueued() for the logs are not quite useful. https://reviewboard.mozilla.org/r/61458/#review58992
Attachment #8766626 - Flags: review?(kaku) → review+
Attachment #8766627 - Flags: review?(kaku) → review+
Comment on attachment 8766627 [details] Bug 1282658. Part 11 - merge OnAudioNotDecoded() and OnVideoNotDecoded(). https://reviewboard.mozilla.org/r/61460/#review58994
Comment on attachment 8766628 [details] Bug 1282658. Part 12 - extract common code about adjusting fast seek. https://reviewboard.mozilla.org/r/61462/#review58996
Attachment #8766628 - Flags: review?(kaku) → review+
Comment on attachment 8766629 [details] Bug 1282658. Part 13 - replace use of int64_t with media::TimeUnit. https://reviewboard.mozilla.org/r/61464/#review58998
Attachment #8766629 - Flags: review?(kaku) → review+
https://reviewboard.mozilla.org/r/61466/#review58978 ::: dom/media/AccurateSeekTask.cpp:366 (Diff revision 1) > - if (audio->mDiscontinuity) { > - mDropAudioUntilNextDiscontinuity = false; > + if (mFirstAudioSample) { > + mFirstAudioSample = false; > + MOZ_ASSERT(audio->mDiscontinuity); The mFirstAudioSample is only used here to place the assertion. How about we make this flag as a mermber of the lambda in the AccurateSeekTask::SetCallbacks() and do this check and assertion in the lambda funtion? Will it be better in this way? At least, by this way, we don't need to have mFirstAudioSample as a member of AccurateSeekTask. Same to the video case.
Comment on attachment 8766631 [details] Bug 1282658. Part 15 - optimize checking of seek complete. https://reviewboard.mozilla.org/r/61468/#review58982 ::: dom/media/AccurateSeekTask.cpp:285 (Diff revision 1) > -void > +bool > AccurateSeekTask::CheckIfSeekComplete() > { > AssertOwnerThread(); > - > - if (!mDoneVideoSeeking) { > - // We haven't reached the target. Ensure we have requested another sample. > - EnsureVideoDecodeTaskQueued(); > - } > - > - if (!mDoneAudioSeeking) { > - // We haven't reached the target. Ensure we have requested another sample. > - EnsureAudioDecodeTaskQueued(); > - } > - > - SAMPLE_LOG("CheckIfSeekComplete() doneAudio=%d doneVideo=%d", > - mDoneAudioSeeking, mDoneVideoSeeking); > - > if (mDoneAudioSeeking && mDoneVideoSeeking) { > Resolve(__func__); // Call to MDSM::SeekCompleted(); > + return true; > } > + return false; > } I agree to move "requesting audio/video data" out of this method which makes this method clean, however, I suggest to rename this method to somethig like "ResolvePromiseIfSeekCompleted" since this is the only duty of this method thereafter. By this way, ResolvePromiseIfSeekCompleted() doen't event need to return a boolean because the boolean value is only used to ask for decoding more audio/video data and for the resason addressed bellow, this boolean is not needed. ::: dom/media/AccurateSeekTask.cpp:370 (Diff revision 1) > - CheckIfSeekComplete(); > + if (!CheckIfSeekComplete() && !mDoneAudioSeeking) { > + EnsureAudioDecodeTaskQueued(); > + } Then, we don't to check "!CheckIfSeekComplete()" in this if-statement. "!CheckIfSeekComplete() && !mDoneAudioSeeking" has the same true-false table to the "!mDoneAudioSeeking". Same to the video case. ::: dom/media/AccurateSeekTask.cpp:417 (Diff revision 1) > // Hit the end of stream. Move mFirstVideoFrameAfterSeek into > // mSeekedVideoData so we have something to display after seeking. > mSeekedVideoData = mFirstVideoFrameAfterSeek.forget(); > } > } > CheckIfSeekComplete(); The method call here is only used to resolve promise is both audio and video seeking are done. Requesting more audio/video data is not the bussiness here.
Attachment #8766631 - Flags: review?(kaku) → review-
Comment on attachment 8766632 [details] Bug 1282658. Part 16 - remove checks for |mReader->IsWaiting{Audio,Video}Data()|. https://reviewboard.mozilla.org/r/61470/#review59000 ::: dom/media/AccurateSeekTask.cpp:107 (Diff revision 1) > AccurateSeekTask::EnsureAudioDecodeTaskQueued() > { > AssertOwnerThread(); > MOZ_ASSERT(!mDoneAudioSeeking); > MOZ_ASSERT(!mReader->IsRequestingAudioData()); > - > + MOZ_ASSERT(!mReader->IsWaitingAudioData()); > - SAMPLE_LOG("EnsureAudioDecodeTaskQueued status=%s", AudioRequestStatus()); > - > - if (mReader->IsWaitingAudioData()) { > - return; > - } > - > mReader->RequestAudioData(); > } Should we rename this method to just "RequestAudioData"? since this is the only duty of this method now. Same to the video case.
Attachment #8766632 - Flags: review?(kaku) → review+
https://reviewboard.mozilla.org/r/61446/#review58758 > We need to keep the "{audio,video} queue finished" information. So that we can notify the MDSM. Good catch! I guess I accidentally deleted the line | mIsAudioQueueFinished = true;|.
https://reviewboard.mozilla.org/r/61452/#review58968 > Then, mNeedToStopPrerollingAudio and mNeedToStopPrerollingVideo are not used anymore, they are not used in the NextFrameSeekTask. We could just remove them from the SeekTask.h. Will fix it in a new bug. This bug will focus on changes in AccurateSeekTask.
https://reviewboard.mozilla.org/r/61438/#review58782 ::: dom/media/AccurateSeekTask.cpp:127 (Diff revision 1) > - RequestVideoData(); > - return NS_OK; > } > > const char* > AccurateSeekTask::AudioRequestStatus() We have {Audio,Video}RequestStatus() in MDSM, AccurateSeekTaks and NextFrameSeekTask; and they are all the same. I think we could move {Audio,Video}RequestStatus() into MediaDecoderReaderWrapper. This is not belong to the scope of this bug, just make a note here and maybe I can handle it later.
https://reviewboard.mozilla.org/r/61466/#review58978 > The mFirstAudioSample is only used here to place the assertion. How about we make this flag as a mermber of the lambda in the AccurateSeekTask::SetCallbacks() and do this check and assertion in the lambda funtion? Will it be better in this way? At least, by this way, we don't need to have mFirstAudioSample as a member of AccurateSeekTask. > > Same to the video case. Good idea! I will try that.
https://reviewboard.mozilla.org/r/61466/#review58978 > Good idea! I will try that. Well... The lambda is copied during the notification of MediaEventSource so changes to the flag will not change the original copy. We will hit the assertion because firstAudioSample is always true.
https://reviewboard.mozilla.org/r/61468/#review58982 > I agree to move "requesting audio/video data" out of this method which makes this method clean, however, I suggest to rename this method to somethig like "ResolvePromiseIfSeekCompleted" since this is the only duty of this method thereafter. > > By this way, ResolvePromiseIfSeekCompleted() doen't event need to return a boolean because the boolean value is only used to ask for decoding more audio/video data and for the resason addressed bellow, this boolean is not needed. Will call it "MaybeFinishSeek()" and return type will be void. > Then, we don't to check "!CheckIfSeekComplete()" in this if-statement. "!CheckIfSeekComplete() && !mDoneAudioSeeking" has the same true-false table to the "!mDoneAudioSeeking". Same to the video case. The code can be structed as: if (!mDoneAudioSeeking) { EnsureAudioDecodeTaskQueued(); return; // no need to call CheckIfSeekComplete() because seek is definitely not completed. } CheckIfSeekComplete(); So we don't need the return value of CheckIfSeekComplete(). > The method call here is only used to resolve promise is both audio and video seeking are done. Requesting more audio/video data is not the bussiness here. I don't get it. Can you elaborate it?
https://reviewboard.mozilla.org/r/61468/#review58982 > I don't get it. Can you elaborate it? Sorry, my fault. I was just responding to the suggestion of "ResolvePromiseIfSeekCompleted" (or "MaybeFinishSeek()") above. This is not an issue.
https://reviewboard.mozilla.org/r/61466/#review58978 > Well... The lambda is copied during the notification of MediaEventSource so changes to the flag will not change the original copy. We will hit the assertion because firstAudioSample is always true. QQ..., r+ then.
Attachment #8766630 - Flags: review?(kaku) → review+
Comment on attachment 8766630 [details] Bug 1282658. Part 14 - remove mDrop{Audio,Video}UntilNextDiscontinuity for MediaData::mDiscontinuity is guaranteed to be true for the 1st sample after seeking. https://reviewboard.mozilla.org/r/61466/#review59032
https://reviewboard.mozilla.org/r/61470/#review59000 > Should we rename this method to just "RequestAudioData"? since this is the only duty of this method now. Same to the video case. Good idea!
Attachment #8767883 - Flags: review?(kaku)
Attachment #8766620 - Flags: review- → review?(kaku)
Attachment #8766631 - Flags: review- → review?(kaku)
Comment on attachment 8766617 [details] Bug 1282658. Part 1 - remove some null-checks. . Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61440/diff/1-2/
Comment on attachment 8766618 [details] Bug 1282658. Part 2 - remove unnecessary checks for Exists(). Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61442/diff/1-2/
Comment on attachment 8766619 [details] Bug 1282658. Part 3 - rename some functions. . Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61444/diff/1-2/
Comment on attachment 8766620 [details] Bug 1282658. Part 4 - simplify logic of checking whether if audio/video seeking is completed. . Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61446/diff/1-2/
Comment on attachment 8766621 [details] Bug 1282658. Part 5 - remove unused members. . Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61448/diff/1-2/
Comment on attachment 8766622 [details] Bug 1282658. Part 6 - remove unnecessary checks for |mSeekRequest.Exists()|. . Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61450/diff/1-2/
Comment on attachment 8766623 [details] Bug 1282658. Part 7 - remove setting mNeedToStopPrerolling{Audio,Video} per discussion in https://reviewboard.mozilla.org/r/43689/#comment54421. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61452/diff/1-2/
Comment on attachment 8766624 [details] Bug 1282658. Part 8 - remove asserting |mReader->IsWaitForDataSupported()| for mReader->WaitForData() will crash if the method has no override. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61454/diff/1-2/
Comment on attachment 8766625 [details] Bug 1282658. Part 9 - return void for Ensure{Audio,Video}DecodeTaskQueued() for they always return NS_OK. . Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61456/diff/1-2/
Comment on attachment 8766626 [details] Bug 1282658. Part 10 - merge Request{Audio,Video}Data() into Ensure{Audio,Video}DecodeTaskQueued() for the logs are not quite useful. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61458/diff/1-2/
Comment on attachment 8766627 [details] Bug 1282658. Part 11 - merge OnAudioNotDecoded() and OnVideoNotDecoded(). Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61460/diff/1-2/
Comment on attachment 8766628 [details] Bug 1282658. Part 12 - extract common code about adjusting fast seek. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61462/diff/1-2/
Comment on attachment 8766629 [details] Bug 1282658. Part 13 - replace use of int64_t with media::TimeUnit. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61464/diff/1-2/
Comment on attachment 8766630 [details] Bug 1282658. Part 14 - remove mDrop{Audio,Video}UntilNextDiscontinuity for MediaData::mDiscontinuity is guaranteed to be true for the 1st sample after seeking. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61466/diff/1-2/
Comment on attachment 8766631 [details] Bug 1282658. Part 15 - optimize checking of seek complete. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61468/diff/1-2/
Comment on attachment 8766632 [details] Bug 1282658. Part 16 - remove checks for |mReader->IsWaiting{Audio,Video}Data()|. Review request updated; see interdiff: https://reviewboard.mozilla.org/r/61470/diff/1-2/
Comment on attachment 8766620 [details] Bug 1282658. Part 4 - simplify logic of checking whether if audio/video seeking is completed. . https://reviewboard.mozilla.org/r/61446/#review59050
Attachment #8766620 - Flags: review?(kaku) → review+
Attachment #8766631 - Flags: review?(kaku) → review+
Attachment #8767883 - Flags: review?(kaku) → review+
Thanks for the review!
Pushed by jwwang@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4dbc6fc64432 Part 1 - remove some null-checks. r=kaku. https://hg.mozilla.org/integration/autoland/rev/badd48f1ff4a Part 2 - remove unnecessary checks for Exists(). r=kaku https://hg.mozilla.org/integration/autoland/rev/156ad7d5fdac Part 3 - rename some functions. r=kaku. https://hg.mozilla.org/integration/autoland/rev/05bcd2db0e70 Part 4 - simplify logic of checking whether if audio/video seeking is completed. r=kaku. https://hg.mozilla.org/integration/autoland/rev/18a1d4f64db9 Part 5 - remove unused members. r=kaku. https://hg.mozilla.org/integration/autoland/rev/59f502a9f190 Part 6 - remove unnecessary checks for |mSeekRequest.Exists()|. r=kaku. https://hg.mozilla.org/integration/autoland/rev/cea92d10be95 Part 7 - remove setting mNeedToStopPrerolling{Audio,Video} per discussion in https://reviewboard.mozilla.org/r/43689/#comment54421. r=kaku https://hg.mozilla.org/integration/autoland/rev/c0910b20aefc Part 8 - remove asserting |mReader->IsWaitForDataSupported()| for mReader->WaitForData() will crash if the method has no override. r=kaku https://hg.mozilla.org/integration/autoland/rev/1668f3d274b7 Part 9 - return void for Ensure{Audio,Video}DecodeTaskQueued() for they always return NS_OK. r=kaku. https://hg.mozilla.org/integration/autoland/rev/a0325c3082b8 Part 10 - merge Request{Audio,Video}Data() into Ensure{Audio,Video}DecodeTaskQueued() for the logs are not quite useful. r=kaku https://hg.mozilla.org/integration/autoland/rev/111114fbbe27 Part 11 - merge OnAudioNotDecoded() and OnVideoNotDecoded(). r=kaku https://hg.mozilla.org/integration/autoland/rev/eb18fb6afd68 Part 12 - extract common code about adjusting fast seek. r=kaku https://hg.mozilla.org/integration/autoland/rev/d7f5babfb534 Part 13 - replace use of int64_t with media::TimeUnit. r=kaku https://hg.mozilla.org/integration/autoland/rev/4c079c504dfe Part 14 - remove mDrop{Audio,Video}UntilNextDiscontinuity for MediaData::mDiscontinuity is guaranteed to be true for the 1st sample after seeking. r=kaku https://hg.mozilla.org/integration/autoland/rev/44ed26a7269a Part 15 - optimize checking of seek complete. r=kaku https://hg.mozilla.org/integration/autoland/rev/0468b7cedfcf Part 16 - remove checks for |mReader->IsWaiting{Audio,Video}Data()|. r=kaku https://hg.mozilla.org/integration/autoland/rev/28c44b72633b Part 17 - rename and remove some functions. r=kaku
Mass change P2 -> P3
Priority: P2 → P3
Depends on: 1285248
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: