| 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 <windows.h> | 5 #include <windows.h> |
| 6 #include <mmsystem.h> | 6 #include <mmsystem.h> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/base_paths.h" | 9 #include "base/base_paths.h" |
| 10 #include "base/memory/aligned_memory.h" | 10 #include "base/memory/aligned_memory.h" |
| (...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 } | 420 } |
| 421 | 421 |
| 422 // With the low latency mode, WASAPI is utilized by default for Vista and | 422 // With the low latency mode, WASAPI is utilized by default for Vista and |
| 423 // higher and Wave is used for XP and lower. It is possible to utilize a | 423 // higher and Wave is used for XP and lower. It is possible to utilize a |
| 424 // smaller buffer size for WASAPI than for Wave. | 424 // smaller buffer size for WASAPI than for Wave. |
| 425 TEST(WinAudioTest, PCMWaveStreamPlay200HzToneLowLatency) { | 425 TEST(WinAudioTest, PCMWaveStreamPlay200HzToneLowLatency) { |
| 426 scoped_ptr<AudioManager> audio_man(AudioManager::CreateForTesting()); | 426 scoped_ptr<AudioManager> audio_man(AudioManager::CreateForTesting()); |
| 427 ABORT_AUDIO_TEST_IF_NOT(audio_man->HasAudioOutputDevices()); | 427 ABORT_AUDIO_TEST_IF_NOT(audio_man->HasAudioOutputDevices()); |
| 428 | 428 |
| 429 // The WASAPI API requires a correct COM environment. | 429 // The WASAPI API requires a correct COM environment. |
| 430 ScopedCOMInitializer com_init(ScopedCOMInitializer::kMTA); | 430 ScopedCOMInitializer com_init; |
| 431 | 431 |
| 432 // Use 10 ms buffer size for WASAPI and 50 ms buffer size for Wave. | 432 // Use 10 ms buffer size for WASAPI and 50 ms buffer size for Wave. |
| 433 // Take the existing native sample rate into account. | 433 // Take the existing native sample rate into account. |
| 434 const AudioParameters params = audio_man->GetDefaultOutputStreamParameters(); | 434 const AudioParameters params = audio_man->GetDefaultOutputStreamParameters(); |
| 435 int sample_rate = params.sample_rate(); | 435 int sample_rate = params.sample_rate(); |
| 436 uint32 samples_10_ms = sample_rate / 100; | 436 uint32 samples_10_ms = sample_rate / 100; |
| 437 int n = 1; | 437 int n = 1; |
| 438 (base::win::GetVersion() <= base::win::VERSION_XP) ? n = 5 : n = 1; | 438 (base::win::GetVersion() <= base::win::VERSION_XP) ? n = 5 : n = 1; |
| 439 AudioOutputStream* oas = audio_man->MakeAudioOutputStream( | 439 AudioOutputStream* oas = audio_man->MakeAudioOutputStream( |
| 440 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, | 440 AudioParameters(AudioParameters::AUDIO_PCM_LOW_LATENCY, |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 631 oas->Start(&source); | 631 oas->Start(&source); |
| 632 | 632 |
| 633 ::WaitForSingleObject(thread, INFINITE); | 633 ::WaitForSingleObject(thread, INFINITE); |
| 634 ::CloseHandle(thread); | 634 ::CloseHandle(thread); |
| 635 | 635 |
| 636 oas->Stop(); | 636 oas->Stop(); |
| 637 oas->Close(); | 637 oas->Close(); |
| 638 } | 638 } |
| 639 | 639 |
| 640 } // namespace media | 640 } // namespace media |
| OLD | NEW |