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 <stddef.h> | 5 #include <stddef.h> |
6 #include <stdint.h> | 6 #include <stdint.h> |
7 | 7 |
8 #include <algorithm> | 8 #include <algorithm> |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/environment.h" | 12 #include "base/environment.h" |
13 #include "base/files/file_util.h" | 13 #include "base/files/file_util.h" |
14 #include "base/macros.h" | 14 #include "base/macros.h" |
15 #include "base/path_service.h" | 15 #include "base/path_service.h" |
16 #include "base/run_loop.h" | 16 #include "base/run_loop.h" |
17 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
18 #include "base/synchronization/lock.h" | 18 #include "base/synchronization/lock.h" |
19 #include "base/test/test_timeouts.h" | 19 #include "base/test/test_timeouts.h" |
20 #include "base/threading/thread_task_runner_handle.h" | 20 #include "base/threading/thread_task_runner_handle.h" |
21 #include "base/time/time.h" | 21 #include "base/time/time.h" |
22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
23 #include "media/audio/audio_device_description.h" | 23 #include "media/audio/audio_device_description.h" |
| 24 #include "media/audio/audio_device_info_accessor_for_tests.h" |
24 #include "media/audio/audio_io.h" | 25 #include "media/audio/audio_io.h" |
25 #include "media/audio/audio_unittest_util.h" | 26 #include "media/audio/audio_unittest_util.h" |
26 #include "media/audio/fake_audio_log_factory.h" | 27 #include "media/audio/fake_audio_log_factory.h" |
27 #include "media/base/seekable_buffer.h" | 28 #include "media/base/seekable_buffer.h" |
28 #include "testing/gmock/include/gmock/gmock.h" | 29 #include "testing/gmock/include/gmock/gmock.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 30 #include "testing/gtest/include/gtest/gtest.h" |
30 | 31 |
31 #if defined(USE_PULSEAUDIO) | 32 #if defined(USE_PULSEAUDIO) |
32 #include "media/audio/pulse/audio_manager_pulse.h" | 33 #include "media/audio/pulse/audio_manager_pulse.h" |
33 #elif defined(USE_ALSA) | 34 #elif defined(USE_ALSA) |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 size_t output_elements_to_write_; | 280 size_t output_elements_to_write_; |
280 base::TimeTicks previous_write_time_; | 281 base::TimeTicks previous_write_time_; |
281 }; | 282 }; |
282 | 283 |
283 class AudioInputStreamTraits { | 284 class AudioInputStreamTraits { |
284 public: | 285 public: |
285 typedef AudioInputStream StreamType; | 286 typedef AudioInputStream StreamType; |
286 | 287 |
287 static AudioParameters GetDefaultAudioStreamParameters( | 288 static AudioParameters GetDefaultAudioStreamParameters( |
288 AudioManager* audio_manager) { | 289 AudioManager* audio_manager) { |
289 return audio_manager->GetInputStreamParameters( | 290 return AudioDeviceInfoAccessorForTests(audio_manager) |
290 AudioDeviceDescription::kDefaultDeviceId); | 291 .GetInputStreamParameters(AudioDeviceDescription::kDefaultDeviceId); |
291 } | 292 } |
292 | 293 |
293 static StreamType* CreateStream(AudioManager* audio_manager, | 294 static StreamType* CreateStream(AudioManager* audio_manager, |
294 const AudioParameters& params) { | 295 const AudioParameters& params) { |
295 return audio_manager->MakeAudioInputStream( | 296 return audio_manager->MakeAudioInputStream( |
296 params, AudioDeviceDescription::kDefaultDeviceId, | 297 params, AudioDeviceDescription::kDefaultDeviceId, |
297 base::Bind(&OnLogMessage)); | 298 base::Bind(&OnLogMessage)); |
298 } | 299 } |
299 }; | 300 }; |
300 | 301 |
301 class AudioOutputStreamTraits { | 302 class AudioOutputStreamTraits { |
302 public: | 303 public: |
303 typedef AudioOutputStream StreamType; | 304 typedef AudioOutputStream StreamType; |
304 | 305 |
305 static AudioParameters GetDefaultAudioStreamParameters( | 306 static AudioParameters GetDefaultAudioStreamParameters( |
306 AudioManager* audio_manager) { | 307 AudioManager* audio_manager) { |
307 return audio_manager->GetDefaultOutputStreamParameters(); | 308 return AudioDeviceInfoAccessorForTests(audio_manager) |
| 309 .GetDefaultOutputStreamParameters(); |
308 } | 310 } |
309 | 311 |
310 static StreamType* CreateStream(AudioManager* audio_manager, | 312 static StreamType* CreateStream(AudioManager* audio_manager, |
311 const AudioParameters& params) { | 313 const AudioParameters& params) { |
312 return audio_manager->MakeAudioOutputStream(params, std::string(), | 314 return audio_manager->MakeAudioOutputStream(params, std::string(), |
313 base::Bind(&OnLogMessage)); | 315 base::Bind(&OnLogMessage)); |
314 } | 316 } |
315 }; | 317 }; |
316 | 318 |
317 // Traits template holding a trait of StreamType. It encapsulates | 319 // Traits template holding a trait of StreamType. It encapsulates |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 // MATLAB example: | 385 // MATLAB example: |
384 // D=load('audio_delay_values_ms.txt'); | 386 // D=load('audio_delay_values_ms.txt'); |
385 // x=cumsum(D(:,1)); | 387 // x=cumsum(D(:,1)); |
386 // plot(x, D(:,2), x, D(:,3), x, D(:,4), x, D(:,2)+D(:,3)+D(:,4)); | 388 // plot(x, D(:,2), x, D(:,3), x, D(:,4), x, D(:,2)+D(:,3)+D(:,4)); |
387 // axis([0, max(x), 0, max(D(:,2)+D(:,3)+D(:,4))+10]); | 389 // axis([0, max(x), 0, max(D(:,2)+D(:,3)+D(:,4))+10]); |
388 // legend('buffer delay','input delay','output delay','total delay'); | 390 // legend('buffer delay','input delay','output delay','total delay'); |
389 // xlabel('time [msec]') | 391 // xlabel('time [msec]') |
390 // ylabel('delay [msec]') | 392 // ylabel('delay [msec]') |
391 // title('Full-duplex audio delay measurement'); | 393 // title('Full-duplex audio delay measurement'); |
392 TEST_F(AudioLowLatencyInputOutputTest, DISABLED_FullDuplexDelayMeasurement) { | 394 TEST_F(AudioLowLatencyInputOutputTest, DISABLED_FullDuplexDelayMeasurement) { |
393 ABORT_AUDIO_TEST_IF_NOT(audio_manager()->HasAudioInputDevices() && | 395 AudioDeviceInfoAccessorForTests device_info_accessor(audio_manager()); |
394 audio_manager()->HasAudioOutputDevices()); | 396 ABORT_AUDIO_TEST_IF_NOT(device_info_accessor.HasAudioInputDevices() && |
| 397 device_info_accessor.HasAudioOutputDevices()); |
395 | 398 |
396 AudioInputStreamWrapper aisw(audio_manager()); | 399 AudioInputStreamWrapper aisw(audio_manager()); |
397 AudioInputStream* ais = aisw.Create(); | 400 AudioInputStream* ais = aisw.Create(); |
398 EXPECT_TRUE(ais); | 401 EXPECT_TRUE(ais); |
399 | 402 |
400 AudioOutputStreamWrapper aosw(audio_manager()); | 403 AudioOutputStreamWrapper aosw(audio_manager()); |
401 AudioOutputStream* aos = aosw.Create(); | 404 AudioOutputStream* aos = aosw.Create(); |
402 EXPECT_TRUE(aos); | 405 EXPECT_TRUE(aos); |
403 | 406 |
404 // This test only supports identical parameters in both directions. | 407 // This test only supports identical parameters in both directions. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 | 446 |
444 // All Close() operations that run on the mocked audio thread, | 447 // All Close() operations that run on the mocked audio thread, |
445 // should be synchronous and not post additional close tasks to | 448 // should be synchronous and not post additional close tasks to |
446 // mocked the audio thread. Hence, there is no need to call | 449 // mocked the audio thread. Hence, there is no need to call |
447 // message_loop()->RunUntilIdle() after the Close() methods. | 450 // message_loop()->RunUntilIdle() after the Close() methods. |
448 aos->Close(); | 451 aos->Close(); |
449 ais->Close(); | 452 ais->Close(); |
450 } | 453 } |
451 | 454 |
452 } // namespace media | 455 } // namespace media |
OLD | NEW |