OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "base/basictypes.h" | 5 #include "base/basictypes.h" |
6 #include "base/environment.h" | 6 #include "base/environment.h" |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 | 151 |
152 virtual ~FullDuplexAudioSinkSource() { | 152 virtual ~FullDuplexAudioSinkSource() { |
153 // Get complete file path to output file in the directory containing | 153 // Get complete file path to output file in the directory containing |
154 // media_unittests.exe. Example: src/build/Debug/audio_delay_values_ms.txt. | 154 // media_unittests.exe. Example: src/build/Debug/audio_delay_values_ms.txt. |
155 base::FilePath file_name; | 155 base::FilePath file_name; |
156 EXPECT_TRUE(PathService::Get(base::DIR_EXE, &file_name)); | 156 EXPECT_TRUE(PathService::Get(base::DIR_EXE, &file_name)); |
157 file_name = file_name.AppendASCII(kDelayValuesFileName); | 157 file_name = file_name.AppendASCII(kDelayValuesFileName); |
158 | 158 |
159 FILE* text_file = file_util::OpenFile(file_name, "wt"); | 159 FILE* text_file = file_util::OpenFile(file_name, "wt"); |
160 DLOG_IF(ERROR, !text_file) << "Failed to open log file."; | 160 DLOG_IF(ERROR, !text_file) << "Failed to open log file."; |
161 LOG(INFO) << ">> Output file " << file_name.value() << " has been created."; | 161 VLOG(0) << ">> Output file " << file_name.value() << " has been created."; |
162 | 162 |
163 // Write the array which contains time-stamps, buffer size and | 163 // Write the array which contains time-stamps, buffer size and |
164 // audio delays values to a text file. | 164 // audio delays values to a text file. |
165 size_t elements_written = 0; | 165 size_t elements_written = 0; |
166 while (elements_written < | 166 while (elements_written < |
167 std::min(input_elements_to_write_, output_elements_to_write_)) { | 167 std::min(input_elements_to_write_, output_elements_to_write_)) { |
168 const AudioDelayState state = delay_states_[elements_written]; | 168 const AudioDelayState state = delay_states_[elements_written]; |
169 fprintf(text_file, "%d %d %d %d\n", | 169 fprintf(text_file, "%d %d %d %d\n", |
170 state.delta_time_ms, | 170 state.delta_time_ms, |
171 state.buffer_delay_ms, | 171 state.buffer_delay_ms, |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
414 ais->Close(); | 414 ais->Close(); |
415 return; | 415 return; |
416 } | 416 } |
417 | 417 |
418 EXPECT_TRUE(ais->Open()); | 418 EXPECT_TRUE(ais->Open()); |
419 EXPECT_TRUE(aos->Open()); | 419 EXPECT_TRUE(aos->Open()); |
420 | 420 |
421 FullDuplexAudioSinkSource full_duplex( | 421 FullDuplexAudioSinkSource full_duplex( |
422 aisw.sample_rate(), aisw.samples_per_packet(), aisw.channels()); | 422 aisw.sample_rate(), aisw.samples_per_packet(), aisw.channels()); |
423 | 423 |
424 LOG(INFO) << ">> You should now be able to hear yourself in loopback..."; | 424 VLOG(0) << ">> You should now be able to hear yourself in loopback..."; |
425 DLOG(INFO) << " sample_rate : " << aisw.sample_rate(); | 425 DVLOG(0) << " sample_rate : " << aisw.sample_rate(); |
426 DLOG(INFO) << " samples_per_packet: " << aisw.samples_per_packet(); | 426 DVLOG(0) << " samples_per_packet: " << aisw.samples_per_packet(); |
427 DLOG(INFO) << " channels : " << aisw.channels(); | 427 DVLOG(0) << " channels : " << aisw.channels(); |
428 | 428 |
429 ais->Start(&full_duplex); | 429 ais->Start(&full_duplex); |
430 aos->Start(&full_duplex); | 430 aos->Start(&full_duplex); |
431 | 431 |
432 // Wait for approximately 10 seconds. The user shall hear his own voice | 432 // Wait for approximately 10 seconds. The user shall hear his own voice |
433 // in loop back during this time. At the same time, delay recordings are | 433 // in loop back during this time. At the same time, delay recordings are |
434 // performed and stored in the output text file. | 434 // performed and stored in the output text file. |
435 message_loop()->PostDelayedTask(FROM_HERE, | 435 message_loop()->PostDelayedTask(FROM_HERE, |
436 base::MessageLoop::QuitClosure(), TestTimeouts::action_timeout()); | 436 base::MessageLoop::QuitClosure(), TestTimeouts::action_timeout()); |
437 message_loop()->Run(); | 437 message_loop()->Run(); |
438 | 438 |
439 aos->Stop(); | 439 aos->Stop(); |
440 ais->Stop(); | 440 ais->Stop(); |
441 | 441 |
442 // All Close() operations that run on the mocked audio thread, | 442 // All Close() operations that run on the mocked audio thread, |
443 // should be synchronous and not post additional close tasks to | 443 // should be synchronous and not post additional close tasks to |
444 // mocked the audio thread. Hence, there is no need to call | 444 // mocked the audio thread. Hence, there is no need to call |
445 // message_loop()->RunUntilIdle() after the Close() methods. | 445 // message_loop()->RunUntilIdle() after the Close() methods. |
446 aos->Close(); | 446 aos->Close(); |
447 ais->Close(); | 447 ais->Close(); |
448 } | 448 } |
449 | 449 |
450 } // namespace media | 450 } // namespace media |
OLD | NEW |