diff --git a/webrtc/voice_engine/test/auto_test/standard/mixing_test.cc b/webrtc/voice_engine/test/auto_test/standard/mixing_test.cc index 499f56184a..eb520b8137 100644 --- a/webrtc/voice_engine/test/auto_test/standard/mixing_test.cc +++ b/webrtc/voice_engine/test/auto_test/standard/mixing_test.cc @@ -87,6 +87,9 @@ class MixingTest : public AfterInitializationFixture { EXPECT_EQ(0, voe_file_->StartRecordingPlayout(-1 /* record meeting */, output_filename_.c_str())); SleepMs(kTestDurationMs); + while (GetFileDurationMs(output_filename_.c_str()) < kTestDurationMs) { + SleepMs(200); + } EXPECT_EQ(0, voe_file_->StopRecordingPlayout(-1)); StopLocalStreams(local_streams); @@ -126,7 +129,7 @@ class MixingTest : public AfterInitializationFixture { // Ensure we've at least recorded half as much file as the duration of the // test. We have to use a relaxed tolerance here due to filesystem flakiness // on the bots. - ASSERT_GE((samples_read * 1000.0) / kSampleRateHz, 0.5 * kTestDurationMs); + ASSERT_GE((samples_read * 1000.0) / kSampleRateHz, kTestDurationMs); // Ensure we read the entire file. ASSERT_NE(0, feof(output_file)); ASSERT_EQ(0, fclose(output_file)); @@ -199,6 +202,17 @@ class MixingTest : public AfterInitializationFixture { } } + int GetFileDurationMs(const char* file_name) { + FILE* fid = fopen(file_name, "rb"); + EXPECT_FALSE(fid == NULL); + fseek(fid, 0, SEEK_END); + int size = ftell(fid); + EXPECT_NE(-1, size); + fclose(fid); + // Divided by 2 due to 2 bytes/sample. + return size * 1000 / kSampleRateHz / 2; + } + std::string input_filename_; const std::string output_filename_; LoopBackTransport* transport_;