Closed Bug 569187 Opened 14 years ago Closed 14 years ago

mAudioEndTime used before it's initialized (buffering logic decodes thousands of audio packets)

Categories

(Core :: Audio/Video, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: kinetik, Assigned: kinetik)

Details

Attachments

(1 file)

I can reproduce this by opening a largish non-autoplay video and then immediately seeking to the middle.

We can get in a situation where the AudioLoop is waiting at http://mxr.mozilla.org/mozilla-central/source/content/media/nsBuiltinDecoderStateMachine.cpp#341 with:

(gdb) p mState
$20 = nsDecoderStateMachine::DECODER_STATE_DECODING
(gdb) p mStopDecodeThreads
$21 = 0 '\0'
(gdb) p IsPlaying()
$22 = 0
(gdb) p mReader.mRawPtr->mAudioQueue.GetSize()
$23 = 33273
(gdb) p mReader.mRawPtr->mAudioQueue.AtEndOfStream()
$24 = 0

In DecodeLoop(), we're constantly decoding audio to try to meet the targets, but:

227	      audioDecoded = mReader->mAudioQueue.Duration() +
228	                     mAudioEndTime - currentTime;

(gdb) p mReader.mRawPtr->mAudioQueue.Duration()
$25 = 709802
(gdb) p mAudioEndTime
$26 = -1
(gdb) p currentTime
$27 = 1254821
(gdb) p audioDecoded
$28 = -545020
Attached patch patch v0Splinter Review
Don't use mAudioEndTime in calculations if it's still -1.  -1 is a sentinel value that indicates we haven't written any audio to the backend since initialization.
Assignee: nobody → kinetik
Status: NEW → ASSIGNED
Attachment #448647 - Flags: review?(chris.double)
Attachment #448647 - Flags: review?(chris.double) → review+
Keywords: checkin-needed
Whiteboard: [needs landing]
http://hg.mozilla.org/mozilla-central/rev/fa1972c19a0b
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Keywords: checkin-needed
Resolution: --- → FIXED
Whiteboard: [needs landing]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: