Delete almost all includes of platform_file.h
Only remaining user is WavReader. Demote its constructor
accepting a PlatformFile to private, to refactor implementation
in a later cl.
Bug: webrtc:6463
Change-Id: I7b950be6f02073cb135dd0fab1190b9dc0de1fba
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/144025
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Commit-Queue: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28410}
diff --git a/common_audio/wav_file_unittest.cc b/common_audio/wav_file_unittest.cc
index d7b09c1..bf03b1c 100644
--- a/common_audio/wav_file_unittest.cc
+++ b/common_audio/wav_file_unittest.cc
@@ -19,15 +19,12 @@
#include "test/gtest.h"
#include "test/testsupport/file_utils.h"
-// WavWriterTest.CPPFileDescriptor and WavWriterTest.CPP flaky on Mac.
-// See webrtc:9247.
+// WavWriterTest.CPP flaky on Mac. See webrtc:9247.
#if defined(WEBRTC_MAC)
#define MAYBE_CPP DISABLED_CPP
-#define MAYBE_CPPFileDescriptor DISABLED_CPPFileDescriptor
#define MAYBE_CPPReset DISABLED_CPPReset
#else
#define MAYBE_CPP CPP
-#define MAYBE_CPPFileDescriptor CPPFileDescriptor
#define MAYBE_CPPReset CPPReset
#endif
@@ -145,75 +142,6 @@
}
}
-// Write a tiny WAV file with the the std::FILE interface and verify the
-// result.
-TEST(WavWriterTest, MAYBE_CPPFileDescriptor) {
- const std::string outfile = test::OutputPath() + "wavtest1.wav";
- static constexpr size_t kNumSamples = 3;
- {
- WavWriter w(FileWrapper::OpenWriteOnly(outfile), 14099, 1);
- EXPECT_EQ(14099, w.sample_rate());
- EXPECT_EQ(1u, w.num_channels());
- EXPECT_EQ(0u, w.num_samples());
- w.WriteSamples(kSamples, kNumSamples);
- EXPECT_EQ(kNumSamples, w.num_samples());
- }
- // Write some extra "metadata" to the file that should be silently ignored
- // by WavReader. We don't use WavWriter directly for this because it doesn't
- // support metadata.
- static constexpr uint8_t kMetadata[] = {101, 202};
- {
- FILE* f = fopen(outfile.c_str(), "ab");
- ASSERT_TRUE(f);
- ASSERT_EQ(1u, fwrite(kMetadata, sizeof(kMetadata), 1, f));
- fclose(f);
- }
- static const uint8_t kExpectedContents[] = {
- // clang-format off
- // clang formatting doesn't respect inline comments.
- 'R', 'I', 'F', 'F',
- 42, 0, 0, 0, // size of whole file - 8: 6 + 44 - 8
- 'W', 'A', 'V', 'E',
- 'f', 'm', 't', ' ',
- 16, 0, 0, 0, // size of fmt block - 8: 24 - 8
- 1, 0, // format: PCM (1)
- 1, 0, // channels: 1
- 0x13, 0x37, 0, 0, // sample rate: 14099
- 0x26, 0x6e, 0, 0, // byte rate: 2 * 14099
- 2, 0, // block align: NumChannels * BytesPerSample
- 16, 0, // bits per sample: 2 * 8
- 'd', 'a', 't', 'a',
- 6, 0, 0, 0, // size of payload: 6
- 0, 0, // first sample: 0.0
- 10, 0, // second sample: 10.0
- 0xff, 0x7f, // third sample: 4e4 (saturated)
- kMetadata[0], kMetadata[1],
- // clang-format on
- };
- static constexpr size_t kContentSize =
- kWavHeaderSize + kNumSamples * sizeof(int16_t) + sizeof(kMetadata);
- static_assert(sizeof(kExpectedContents) == kContentSize, "");
- EXPECT_EQ(kContentSize, test::GetFileSize(outfile));
- FILE* f = fopen(outfile.c_str(), "rb");
- ASSERT_TRUE(f);
- uint8_t contents[kContentSize];
- ASSERT_EQ(1u, fread(contents, kContentSize, 1, f));
- EXPECT_EQ(0, fclose(f));
- EXPECT_EQ(0, memcmp(kExpectedContents, contents, kContentSize));
-
- {
- WavReader r(rtc::OpenPlatformFileReadOnly(outfile));
- EXPECT_EQ(14099, r.sample_rate());
- EXPECT_EQ(1u, r.num_channels());
- EXPECT_EQ(kNumSamples, r.num_samples());
- static constexpr float kTruncatedSamples[] = {0.0, 10.0, 32767.0};
- float samples[kNumSamples];
- EXPECT_EQ(kNumSamples, r.ReadSamples(kNumSamples, samples));
- EXPECT_EQ(0, memcmp(kTruncatedSamples, samples, sizeof(samples)));
- EXPECT_EQ(0u, r.ReadSamples(kNumSamples, samples));
- }
-}
-
// Write a tiny WAV file with the C++ interface then read-reset-read.
TEST(WavReaderTest, MAYBE_CPPReset) {
const std::string outfile = test::OutputPath() + "wavtest4.wav";