diff --git a/dom/media/AudioCaptureTrack.cpp b/dom/media/AudioCaptureTrack.cpp index f30581ee6925..1b86459c1e7c 100644 --- a/dom/media/AudioCaptureTrack.cpp +++ b/dom/media/AudioCaptureTrack.cpp @@ -134,6 +134,6 @@ void AudioCaptureTrack::MixerCallback(AudioDataValue* aMixedBuffer, } // Now we have mixed data, simply append it. - GetData()->AppendAndConsumeChunk(std::move(chunk)); + GetData()->AppendAndConsumeChunk(&chunk); } } // namespace mozilla diff --git a/dom/media/AudioSegment.h b/dom/media/AudioSegment.h index 4ec71c92bce8..1f133cb02f1f 100644 --- a/dom/media/AudioSegment.h +++ b/dom/media/AudioSegment.h @@ -424,17 +424,17 @@ class AudioSegment : public MediaSegmentBase { } // Consumes aChunk, and returns a pointer to the persistent copy of aChunk // in the segment. - AudioChunk* AppendAndConsumeChunk(AudioChunk&& aChunk) { - AudioChunk* chunk = AppendChunk(aChunk.mDuration); - chunk->mBuffer = std::move(aChunk.mBuffer); - chunk->mChannelData = std::move(aChunk.mChannelData); + AudioChunk* AppendAndConsumeChunk(AudioChunk* aChunk) { + AudioChunk* chunk = AppendChunk(aChunk->mDuration); + chunk->mBuffer = std::move(aChunk->mBuffer); + chunk->mChannelData = std::move(aChunk->mChannelData); - MOZ_ASSERT(chunk->mBuffer || aChunk.mChannelData.IsEmpty(), + MOZ_ASSERT(chunk->mBuffer || aChunk->mChannelData.IsEmpty(), "Appending invalid data ?"); - chunk->mVolume = aChunk.mVolume; - chunk->mBufferFormat = aChunk.mBufferFormat; - chunk->mPrincipalHandle = aChunk.mPrincipalHandle; + chunk->mVolume = aChunk->mVolume; + chunk->mBufferFormat = aChunk->mBufferFormat; + chunk->mPrincipalHandle = aChunk->mPrincipalHandle; return chunk; } void ApplyVolume(float aVolume); diff --git a/dom/media/CrossGraphPort.cpp b/dom/media/CrossGraphPort.cpp index 836458473be5..c4cb4d764563 100644 --- a/dom/media/CrossGraphPort.cpp +++ b/dom/media/CrossGraphPort.cpp @@ -176,7 +176,7 @@ void CrossGraphReceiver::ProcessInput(GraphTime aFrom, GraphTime aTo, while (mCrossThreadFIFO.AvailableRead()) { AudioChunk chunk; Unused << mCrossThreadFIFO.Dequeue(&chunk, 1); - transmittedAudio.AppendAndConsumeChunk(std::move(chunk)); + transmittedAudio.AppendAndConsumeChunk(&chunk); mTransmitterHasStarted = true; } diff --git a/dom/media/DynamicResampler.cpp b/dom/media/DynamicResampler.cpp index 8de8dd19e327..b823597a717c 100644 --- a/dom/media/DynamicResampler.cpp +++ b/dom/media/DynamicResampler.cpp @@ -443,7 +443,8 @@ AudioSegment AudioResampler::Resample(uint32_t aOutFrames) { // Create a copy in order to consume that copy and not the pre-allocated // chunk - segment.AppendAndConsumeChunk(AudioChunk(chunk)); + AudioChunk tmp = chunk; + segment.AppendAndConsumeChunk(&tmp); } return segment; diff --git a/dom/media/DynamicResampler.h b/dom/media/DynamicResampler.h index 9203b9af315c..3450fd756b59 100644 --- a/dom/media/DynamicResampler.h +++ b/dom/media/DynamicResampler.h @@ -292,7 +292,7 @@ class AudioChunkList { * AudioChunk& chunk = audioChunklist.GetNext(); * // Set up the chunk * AudioChunk tmp = chunk; - * audioSegment.AppendAndConsumeChunk(std::move(tmp)); + * audioSegment.AppendAndConsumeChunk(&tmp); * ``` * This way no memory allocation or copy, takes place. */ diff --git a/dom/media/gtest/TestAudioDriftCorrection.cpp b/dom/media/gtest/TestAudioDriftCorrection.cpp index 9fda0bcc0e86..361c01fc2f2a 100644 --- a/dom/media/gtest/TestAudioDriftCorrection.cpp +++ b/dom/media/gtest/TestAudioDriftCorrection.cpp @@ -367,7 +367,7 @@ TEST(TestAudioDriftCorrection, NotEnoughFrames) // after 4 iterations AudioChunk chunk = CreateAudioChunk(10, 1, AUDIO_FORMAT_FLOAT32); AudioSegment inSegment; - inSegment.AppendAndConsumeChunk(std::move(chunk)); + inSegment.AppendAndConsumeChunk(&chunk); AudioSegment outSegment = ad.RequestFrames(inSegment, targetFrames); EXPECT_EQ(outSegment.GetDuration(), targetFrames); @@ -392,7 +392,7 @@ TEST(TestAudioDriftCorrection, CrashInAudioResampler) AudioChunk chunk = CreateAudioChunk(sampleRateTransmitter / 1000, 1, AUDIO_FORMAT_FLOAT32); AudioSegment inSegment; - inSegment.AppendAndConsumeChunk(std::move(chunk)); + inSegment.AppendAndConsumeChunk(&chunk); AudioSegment outSegment = ad.RequestFrames(inSegment, targetFrames); EXPECT_EQ(outSegment.GetDuration(), targetFrames); diff --git a/dom/media/gtest/TestAudioSegment.cpp b/dom/media/gtest/TestAudioSegment.cpp index 610187f709cf..a2f50fdb8d3d 100644 --- a/dom/media/gtest/TestAudioSegment.cpp +++ b/dom/media/gtest/TestAudioSegment.cpp @@ -268,7 +268,7 @@ TEST(AudioSegment, FlushAfter_ZeroDuration) fillChunk(&c, 10); AudioSegment s; - s.AppendAndConsumeChunk(std::move(c)); + s.AppendAndConsumeChunk(&c); s.FlushAfter(0); EXPECT_EQ(s.GetDuration(), 0); } @@ -286,8 +286,8 @@ TEST(AudioSegment, FlushAfter_SmallerDuration) fillChunk(&c2, duration); AudioSegment s; - s.AppendAndConsumeChunk(std::move(c1)); - s.AppendAndConsumeChunk(std::move(c2)); + s.AppendAndConsumeChunk(&c1); + s.AppendAndConsumeChunk(&c2); s.FlushAfter(smaller_duration); EXPECT_EQ(s.GetDuration(), smaller_duration) << "Check new duration"; @@ -310,14 +310,13 @@ TEST(AudioSegment, MemoizedOutputChannelCount) s.Clear(); EXPECT_EQ(s.MaxChannelCount(), 0U) << "Still 0 after clearing"; - AudioChunk c1; - fillChunk(&c1, 1); - s.AppendAndConsumeChunk(std::move(c1)); + AudioChunk c; + fillChunk(&c, 1); + s.AppendAndConsumeChunk(&c); EXPECT_EQ(s.MaxChannelCount(), 1U) << "A single chunk's channel count"; - AudioChunk c2; - fillChunk(&c2, 1); - s.AppendAndConsumeChunk(std::move(c2)); + fillChunk(&c, 1); + s.AppendAndConsumeChunk(&c); EXPECT_EQ(s.MaxChannelCount(), 2U) << "The max of two chunks' channel count"; s.ForgetUpTo(2); @@ -326,9 +325,8 @@ TEST(AudioSegment, MemoizedOutputChannelCount) s.Clear(); EXPECT_EQ(s.MaxChannelCount(), 2U) << "Still memoized after clearing"; - AudioChunk c3; - fillChunk(&c3, 1); - s.AppendAndConsumeChunk(std::move(c3)); + fillChunk(&c, 1); + s.AppendAndConsumeChunk(&c); EXPECT_EQ(s.MaxChannelCount(), 1U) << "Real chunk trumps memoized value"; s.Clear(); diff --git a/dom/media/gtest/TestDynamicResampler.cpp b/dom/media/gtest/TestDynamicResampler.cpp index 93b78e034760..a84b0be3eee0 100644 --- a/dom/media/gtest/TestDynamicResampler.cpp +++ b/dom/media/gtest/TestDynamicResampler.cpp @@ -891,13 +891,15 @@ TEST(TestAudioChunkList, ConsumeAndForget) AudioChunkList list(256, 2); list.SetSampleFormat(AUDIO_FORMAT_FLOAT32); - AudioChunk c1 = list.GetNext(); - s.AppendAndConsumeChunk(std::move(c1)); + AudioChunk& c1 = list.GetNext(); + AudioChunk tmp = c1; + s.AppendAndConsumeChunk(&tmp); EXPECT_FALSE(c1.mBuffer.get() == nullptr); EXPECT_EQ(c1.ChannelData().Length(), 2u); - AudioChunk c2 = list.GetNext(); - s.AppendAndConsumeChunk(std::move(c2)); + AudioChunk& c2 = list.GetNext(); + tmp = c2; + s.AppendAndConsumeChunk(&tmp); EXPECT_FALSE(c2.mBuffer.get() == nullptr); EXPECT_EQ(c2.ChannelData().Length(), 2u); @@ -943,7 +945,7 @@ AudioSegment CreateAudioSegment(uint32_t aFrames, uint32_t aChannels, AudioSampleFormat aSampleFormat) { AudioSegment segment; AudioChunk chunk = CreateAudioChunk(aFrames, aChannels, aSampleFormat); - segment.AppendAndConsumeChunk(std::move(chunk)); + segment.AppendAndConsumeChunk(&chunk); return segment; } @@ -1076,7 +1078,7 @@ TEST(TestAudioResampler, InAudioSegment_Float) AudioChunk chunk1; chunk1.SetNull(in_frames / 2); - inSegment.AppendAndConsumeChunk(std::move(chunk1)); + inSegment.AppendAndConsumeChunk(&chunk1); AudioChunk chunk2; nsTArray> buffer; @@ -1100,7 +1102,7 @@ TEST(TestAudioResampler, InAudioSegment_Float) chunk2.mChannelData[i] = bufferPtrs[i]; } chunk2.mDuration = in_frames / 2; - inSegment.AppendAndConsumeChunk(std::move(chunk2)); + inSegment.AppendAndConsumeChunk(&chunk2); dr.AppendInput(inSegment); AudioSegment outSegment = dr.Resample(out_frames); @@ -1131,7 +1133,7 @@ TEST(TestAudioResampler, InAudioSegment_Short) // The null chunk at the beginning will be ignored. AudioChunk chunk1; chunk1.SetNull(in_frames / 2); - inSegment.AppendAndConsumeChunk(std::move(chunk1)); + inSegment.AppendAndConsumeChunk(&chunk1); AudioChunk chunk2; nsTArray> buffer; @@ -1155,7 +1157,7 @@ TEST(TestAudioResampler, InAudioSegment_Short) chunk2.mChannelData[i] = bufferPtrs[i]; } chunk2.mDuration = in_frames / 2; - inSegment.AppendAndConsumeChunk(std::move(chunk2)); + inSegment.AppendAndConsumeChunk(&chunk2); dr.AppendInput(inSegment); AudioSegment outSegment = dr.Resample(out_frames); @@ -1187,8 +1189,8 @@ TEST(TestAudioResampler, ChannelChange_MonoToStereo) CreateAudioChunk(in_frames, 2, AUDIO_FORMAT_FLOAT32); AudioSegment inSegment; - inSegment.AppendAndConsumeChunk(std::move(monoChunk)); - inSegment.AppendAndConsumeChunk(std::move(stereoChunk)); + inSegment.AppendAndConsumeChunk(&monoChunk); + inSegment.AppendAndConsumeChunk(&stereoChunk); dr.AppendInput(inSegment); AudioSegment s = dr.Resample(out_frames); @@ -1217,8 +1219,8 @@ TEST(TestAudioResampler, ChannelChange_StereoToMono) CreateAudioChunk(in_frames, 2, AUDIO_FORMAT_FLOAT32); AudioSegment inSegment; - inSegment.AppendAndConsumeChunk(std::move(stereoChunk)); - inSegment.AppendAndConsumeChunk(std::move(monoChunk)); + inSegment.AppendAndConsumeChunk(&stereoChunk); + inSegment.AppendAndConsumeChunk(&monoChunk); dr.AppendInput(inSegment); AudioSegment s = dr.Resample(out_frames); @@ -1247,8 +1249,8 @@ TEST(TestAudioResampler, ChannelChange_StereoToQuad) CreateAudioChunk(in_frames, 4, AUDIO_FORMAT_FLOAT32); AudioSegment inSegment; - inSegment.AppendAndConsumeChunk(std::move(stereoChunk)); - inSegment.AppendAndConsumeChunk(std::move(quadChunk)); + inSegment.AppendAndConsumeChunk(&stereoChunk); + inSegment.AppendAndConsumeChunk(&quadChunk); dr.AppendInput(inSegment); AudioSegment s = dr.Resample(out_frames); @@ -1280,8 +1282,8 @@ TEST(TestAudioResampler, ChannelChange_QuadToStereo) CreateAudioChunk(in_frames, 4, AUDIO_FORMAT_FLOAT32); AudioSegment inSegment; - inSegment.AppendAndConsumeChunk(std::move(quadChunk)); - inSegment.AppendAndConsumeChunk(std::move(stereoChunk)); + inSegment.AppendAndConsumeChunk(&quadChunk); + inSegment.AppendAndConsumeChunk(&stereoChunk); dr.AppendInput(inSegment); AudioSegment s = dr.Resample(out_frames); @@ -1333,7 +1335,7 @@ TEST(TestAudioResampler, ChannelChange_Discontinuity) } AudioSegment inSegment; - inSegment.AppendAndConsumeChunk(std::move(stereoChunk)); + inSegment.AppendAndConsumeChunk(&stereoChunk); // printAudioSegment(inSegment); dr.AppendInput(inSegment); @@ -1341,7 +1343,7 @@ TEST(TestAudioResampler, ChannelChange_Discontinuity) // printAudioSegment(s); AudioSegment inSegment2; - inSegment2.AppendAndConsumeChunk(std::move(monoChunk)); + inSegment2.AppendAndConsumeChunk(&monoChunk); // The resampler here is updated due to the channel change and that creates // discontinuity. dr.AppendInput(inSegment2); @@ -1389,8 +1391,8 @@ TEST(TestAudioResampler, ChannelChange_Discontinuity2) } AudioSegment inSegment; - inSegment.AppendAndConsumeChunk(std::move(monoChunk)); - inSegment.AppendAndConsumeChunk(std::move(stereoChunk)); + inSegment.AppendAndConsumeChunk(&monoChunk); + inSegment.AppendAndConsumeChunk(&stereoChunk); // printAudioSegment(inSegment); dr.AppendInput(inSegment); @@ -1443,7 +1445,7 @@ TEST(TestAudioResampler, ChannelChange_Discontinuity3) } AudioSegment inSegment; - inSegment.AppendAndConsumeChunk(std::move(stereoChunk)); + inSegment.AppendAndConsumeChunk(&stereoChunk); // printAudioSegment(inSegment); dr.AppendInput(inSegment); diff --git a/dom/media/webaudio/AudioNodeTrack.cpp b/dom/media/webaudio/AudioNodeTrack.cpp index d98c765d7ee3..bacf345a4179 100644 --- a/dom/media/webaudio/AudioNodeTrack.cpp +++ b/dom/media/webaudio/AudioNodeTrack.cpp @@ -594,7 +594,7 @@ void AudioNodeTrack::AdvanceOutputSegment() { AudioChunk copyChunk = *mLastChunks[0].AsMutableChunk(); AudioSegment tmpSegment; - tmpSegment.AppendAndConsumeChunk(std::move(copyChunk)); + tmpSegment.AppendAndConsumeChunk(©Chunk); for (const auto& l : mTrackListeners) { // Notify MediaTrackListeners.