OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <stdint.h> | 5 #include <stdint.h> |
6 | 6 |
7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
8 #include "base/memory/ptr_util.h" | 8 #include "base/memory/ptr_util.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/sys_byteorder.h" | 10 #include "base/sys_byteorder.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 int writes, | 76 int writes, |
77 int64_t file_length) { | 77 int64_t file_length) { |
78 uint32_t block_align = params.channels() * kBytesPerSample; | 78 uint32_t block_align = params.channels() * kBytesPerSample; |
79 uint32_t data_size = | 79 uint32_t data_size = |
80 static_cast<uint32_t>(params.frames_per_buffer() * params.channels() * | 80 static_cast<uint32_t>(params.frames_per_buffer() * params.channels() * |
81 writes * kBytesPerSample); | 81 writes * kBytesPerSample); |
82 // Offset Length Content | 82 // Offset Length Content |
83 // 0 4 "RIFF" | 83 // 0 4 "RIFF" |
84 EXPECT_EQ(0, strncmp(wav_header, "RIFF", 4)); | 84 EXPECT_EQ(0, strncmp(wav_header, "RIFF", 4)); |
85 // 4 4 <file length - 8> | 85 // 4 4 <file length - 8> |
| 86 ASSERT_GT(file_length, 8); |
86 EXPECT_EQ(static_cast<uint64_t>(file_length - 8), ReadLE4(wav_header + 4)); | 87 EXPECT_EQ(static_cast<uint64_t>(file_length - 8), ReadLE4(wav_header + 4)); |
87 EXPECT_EQ(static_cast<uint32_t>(data_size + kWavHeaderSize - 8), | 88 EXPECT_EQ(static_cast<uint32_t>(data_size + kWavHeaderSize - 8), |
88 ReadLE4(wav_header + 4)); | 89 ReadLE4(wav_header + 4)); |
89 // 8 4 "WAVE" | 90 // 8 4 "WAVE" |
90 // 12 4 "fmt " | 91 // 12 4 "fmt " |
91 EXPECT_EQ(0, strncmp(wav_header + 8, "WAVEfmt ", 8)); | 92 EXPECT_EQ(0, strncmp(wav_header + 8, "WAVEfmt ", 8)); |
92 // 16 4 <length of the fmt data> (=16) | 93 // 16 4 <length of the fmt data> (=16) |
93 EXPECT_EQ(16U, ReadLE4(wav_header + 16)); | 94 EXPECT_EQ(16U, ReadLE4(wav_header + 16)); |
94 // 20 2 <WAVE file encoding tag> | 95 // 20 2 <WAVE file encoding tag> |
95 EXPECT_EQ(kPcmEncoding, ReadLE2(wav_header + 20)); | 96 EXPECT_EQ(kPcmEncoding, ReadLE2(wav_header + 20)); |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
340 AudioInputDebugWriterBehavioralTest, | 341 AudioInputDebugWriterBehavioralTest, |
341 // Using 10ms frames per buffer everywhere. | 342 // Using 10ms frames per buffer everywhere. |
342 testing::Values( | 343 testing::Values( |
343 // No writes. | 344 // No writes. |
344 std::tr1::make_tuple(media::ChannelLayout::CHANNEL_LAYOUT_MONO, | 345 std::tr1::make_tuple(media::ChannelLayout::CHANNEL_LAYOUT_MONO, |
345 44100, | 346 44100, |
346 44100 / 100, | 347 44100 / 100, |
347 100))); | 348 100))); |
348 | 349 |
349 } // namespace content | 350 } // namespace content |
OLD | NEW |