Backed out changeset da97faf315ee (bug 1716248) for causing Gtest failures. CLOSED TREE

This commit is contained in:
Butkovits Atila 2021-06-22 01:46:58 +03:00
Родитель 327fcd4a7f
Коммит 7f57e645d9
9 изменённых файлов: 50 добавлений и 49 удалений

Просмотреть файл

@ -134,6 +134,6 @@ void AudioCaptureTrack::MixerCallback(AudioDataValue* aMixedBuffer,
}
// Now we have mixed data, simply append it.
GetData<AudioSegment>()->AppendAndConsumeChunk(std::move(chunk));
GetData<AudioSegment>()->AppendAndConsumeChunk(&chunk);
}
} // namespace mozilla

Просмотреть файл

@ -424,17 +424,17 @@ class AudioSegment : public MediaSegmentBase<AudioSegment, AudioChunk> {
}
// 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);

Просмотреть файл

@ -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;
}

Просмотреть файл

@ -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;

Просмотреть файл

@ -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.
*/

Просмотреть файл

@ -367,7 +367,7 @@ TEST(TestAudioDriftCorrection, NotEnoughFrames)
// after 4 iterations
AudioChunk chunk = CreateAudioChunk<float>(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<float>(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);

Просмотреть файл

@ -268,7 +268,7 @@ TEST(AudioSegment, FlushAfter_ZeroDuration)
fillChunk<float, 2>(&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<float, 2>(&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<float, 1>(&c1, 1);
s.AppendAndConsumeChunk(std::move(c1));
AudioChunk c;
fillChunk<float, 1>(&c, 1);
s.AppendAndConsumeChunk(&c);
EXPECT_EQ(s.MaxChannelCount(), 1U) << "A single chunk's channel count";
AudioChunk c2;
fillChunk<float, 2>(&c2, 1);
s.AppendAndConsumeChunk(std::move(c2));
fillChunk<float, 2>(&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<float, 1>(&c3, 1);
s.AppendAndConsumeChunk(std::move(c3));
fillChunk<float, 1>(&c, 1);
s.AppendAndConsumeChunk(&c);
EXPECT_EQ(s.MaxChannelCount(), 1U) << "Real chunk trumps memoized value";
s.Clear();

Просмотреть файл

@ -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<float>().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<float>().Length(), 2u);
@ -943,7 +945,7 @@ AudioSegment CreateAudioSegment(uint32_t aFrames, uint32_t aChannels,
AudioSampleFormat aSampleFormat) {
AudioSegment segment;
AudioChunk chunk = CreateAudioChunk<T>(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<nsTArray<float>> 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<nsTArray<short>> 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<float>(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<float>(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<float>(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<float>(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);

Просмотреть файл

@ -594,7 +594,7 @@ void AudioNodeTrack::AdvanceOutputSegment() {
AudioChunk copyChunk = *mLastChunks[0].AsMutableChunk();
AudioSegment tmpSegment;
tmpSegment.AppendAndConsumeChunk(std::move(copyChunk));
tmpSegment.AppendAndConsumeChunk(&copyChunk);
for (const auto& l : mTrackListeners) {
// Notify MediaTrackListeners.