Closed Bug 1716248 Opened 3 years ago Closed 3 years ago

Change `AppendAndConsumeChunk`'s input type from `AudioChunk*` to `AudioChunk&&`

Categories

(Core :: Audio/Video: MediaStreamGraph, enhancement, P1)

enhancement

Tracking

()

RESOLVED FIXED
91 Branch
Tracking Status
firefox91 --- fixed

People

(Reporter: chunmin, Assigned: chunmin)

Details

Attachments

(1 file)

It's better to change the AppendAndConsumeChunk's input parameter type from AudioChunk* to AudioChunk&& since the AudioChunk is consumed in AppendAndConsumeChunk. That is, AudioChunk* AppendAndConsumeChunk(AudioChunk* aChunk) should be replaced by AudioChunk* AppendAndConsumeChunk(AudioChunk&& aChunk). As a result,

AudioChunk chunk = ...
audioSegment.AppendAndConsumeChunk(&chunk);
// chunk is consumed and it should not be used again

will become

AudioChunk chunk = ...
audioSegment.AppendAndConsumeChunk(std::move(chunk));

or

audioSegment.AppendAndConsumeChunk(CreateAudioChunk(...));
// CreateAudioChunk is a function returning AudioChunk

One benefit for doing so is to prevent the consumed AudioChunk from being used again after it's moved. Firefox has a clang-tidy check, bugprone-use-after-move , to catch this kind of error. We should utilize this clang-tidy check instead of catching this error by human eyes.

It's better to change the input parameter's type of
AppendAndConsumeChunk from AudioChunk* to AudioChunk&& since the
AudioChunk will be consumed once it's fed to this function.

One benefit for doing so is to prevent the consumed AudioChunk from
being used again after it's moved/consumed. Gecko has a clang-tidy
check, bugprone-use-after-move [1], to avoid this kind of error. We
should utilize this check instead of catching used-after-move error by
human eyes.

Pushed by cchang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/da97faf315ee
Change AppendAndConsumeChunk's input parameter type r=padenot

(In reply to Atila Butkovits from comment #3)

Backed out for causing Gtest failures.

The updated D117714 should be able to fix the issue

Flags: needinfo?(cchang)
Pushed by cchang@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/e9b1ff295960
Change AppendAndConsumeChunk's input parameter type r=padenot
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 91 Branch
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: