Closed Bug 1594067 Opened 5 years ago Closed 5 years ago

AudioSegment::FlushAfter is crashing for new end equals to zero

Categories

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

defect

Tracking

()

RESOLVED FIXED
mozilla72
Tracking Status
firefox72 --- fixed

People

(Reporter: achronop, Assigned: achronop)

Details

Attachments

(2 files)

The crash happens in [1] and reproduces only when the segment contains audio data. Reading the assert in AudioSegment::SliceTo(), it does not expect zero duration slice. The call to the SliceTo() method happens in [2].

In general, when FlushAfter(0) is called (with new-end equals zero) the segment can handle it as a special case a clears itself.

[1] https://searchfox.org/mozilla-central/rev/3300072e993ae05d50d5c63d815260367eaf9179/dom/media/AudioSegment.h#152
[2] https://searchfox.org/mozilla-central/rev/3300072e993ae05d50d5c63d815260367eaf9179/dom/media/MediaSegment.h#262

The AudioSegment::FlushAfter with input argument equals to zero is crashing on an assert that indicates misuse of the AudioChunk::SliceTo method. In general MediaSegmentBase::FlushAfter is better to clear itself when is called with argument equals to zero. This avoids the misuse and it is slightly more efficient.

Fix MediaSegmentBase::RemoveTrailing to be able to accept the first argument, keep frames, equal to zero. The patch avoids calling the AudioChunk::SliceTo() method with zero slice duration which hits an assert. The crash was being triggered when in the AudioSegment was including one or more chunks, with the first chunk containing silence (null). Then the AudioSegment::FlushAfter had to be called with a duration smaller or equal to the duration of the first chunk. A unit test has been created, verifying the duration of the final segment.

Pushed by achronopoulos@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/cb5434e79ec6
Clear the AudioSegment when FlushAfter is called with new end equals to zero. r=padenot
https://hg.mozilla.org/integration/autoland/rev/f331f382d86b
Fix RemoveTrailing to handle correctly keep frames equals to zero. r=padenot
Status: NEW → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla72
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: