| 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 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 delay_states_.reset(new AudioDelayState[kMaxDelayMeasurements]); | 155 delay_states_.reset(new AudioDelayState[kMaxDelayMeasurements]); |
| 156 } | 156 } |
| 157 | 157 |
| 158 virtual ~FullDuplexAudioSinkSource() { | 158 virtual ~FullDuplexAudioSinkSource() { |
| 159 // Get complete file path to output file in the directory containing | 159 // Get complete file path to output file in the directory containing |
| 160 // media_unittests.exe. Example: src/build/Debug/audio_delay_values_ms.txt. | 160 // media_unittests.exe. Example: src/build/Debug/audio_delay_values_ms.txt. |
| 161 base::FilePath file_name; | 161 base::FilePath file_name; |
| 162 EXPECT_TRUE(PathService::Get(base::DIR_EXE, &file_name)); | 162 EXPECT_TRUE(PathService::Get(base::DIR_EXE, &file_name)); |
| 163 file_name = file_name.AppendASCII(kDelayValuesFileName); | 163 file_name = file_name.AppendASCII(kDelayValuesFileName); |
| 164 | 164 |
| 165 FILE* text_file = base::OpenFile(file_name, "wt"); | 165 FILE* text_file = file_util::OpenFile(file_name, "wt"); |
| 166 DLOG_IF(ERROR, !text_file) << "Failed to open log file."; | 166 DLOG_IF(ERROR, !text_file) << "Failed to open log file."; |
| 167 VLOG(0) << ">> Output file " << file_name.value() << " has been created."; | 167 VLOG(0) << ">> Output file " << file_name.value() << " has been created."; |
| 168 | 168 |
| 169 // Write the array which contains time-stamps, buffer size and | 169 // Write the array which contains time-stamps, buffer size and |
| 170 // audio delays values to a text file. | 170 // audio delays values to a text file. |
| 171 size_t elements_written = 0; | 171 size_t elements_written = 0; |
| 172 while (elements_written < | 172 while (elements_written < |
| 173 std::min(input_elements_to_write_, output_elements_to_write_)) { | 173 std::min(input_elements_to_write_, output_elements_to_write_)) { |
| 174 const AudioDelayState state = delay_states_[elements_written]; | 174 const AudioDelayState state = delay_states_[elements_written]; |
| 175 fprintf(text_file, "%d %d %d %d\n", | 175 fprintf(text_file, "%d %d %d %d\n", |
| 176 state.delta_time_ms, | 176 state.delta_time_ms, |
| 177 state.buffer_delay_ms, | 177 state.buffer_delay_ms, |
| 178 state.input_delay_ms, | 178 state.input_delay_ms, |
| 179 state.output_delay_ms); | 179 state.output_delay_ms); |
| 180 ++elements_written; | 180 ++elements_written; |
| 181 } | 181 } |
| 182 | 182 |
| 183 base::CloseFile(text_file); | 183 file_util::CloseFile(text_file); |
| 184 } | 184 } |
| 185 | 185 |
| 186 // AudioInputStream::AudioInputCallback. | 186 // AudioInputStream::AudioInputCallback. |
| 187 virtual void OnData(AudioInputStream* stream, | 187 virtual void OnData(AudioInputStream* stream, |
| 188 const uint8* src, uint32 size, | 188 const uint8* src, uint32 size, |
| 189 uint32 hardware_delay_bytes, | 189 uint32 hardware_delay_bytes, |
| 190 double volume) OVERRIDE { | 190 double volume) OVERRIDE { |
| 191 base::AutoLock lock(lock_); | 191 base::AutoLock lock(lock_); |
| 192 | 192 |
| 193 // Update three components in the AudioDelayState for this recorded | 193 // Update three components in the AudioDelayState for this recorded |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 447 | 447 |
| 448 // All Close() operations that run on the mocked audio thread, | 448 // All Close() operations that run on the mocked audio thread, |
| 449 // should be synchronous and not post additional close tasks to | 449 // should be synchronous and not post additional close tasks to |
| 450 // mocked the audio thread. Hence, there is no need to call | 450 // mocked the audio thread. Hence, there is no need to call |
| 451 // message_loop()->RunUntilIdle() after the Close() methods. | 451 // message_loop()->RunUntilIdle() after the Close() methods. |
| 452 aos->Close(); | 452 aos->Close(); |
| 453 ais->Close(); | 453 ais->Close(); |
| 454 } | 454 } |
| 455 | 455 |
| 456 } // namespace media | 456 } // namespace media |
| OLD | NEW |