OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/bind.h" | 5 #include "base/bind.h" |
6 #include "base/environment.h" | 6 #include "base/environment.h" |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "media/audio/audio_manager.h" | 10 #include "media/audio/audio_manager.h" |
(...skipping 15 matching lines...) Expand all Loading... |
26 #if defined(USE_PULSEAUDIO) | 26 #if defined(USE_PULSEAUDIO) |
27 #include "media/audio/pulse/audio_manager_pulse.h" | 27 #include "media/audio/pulse/audio_manager_pulse.h" |
28 #endif // defined(USE_PULSEAUDIO) | 28 #endif // defined(USE_PULSEAUDIO) |
29 | 29 |
30 namespace media { | 30 namespace media { |
31 | 31 |
32 // Test fixture which allows us to override the default enumeration API on | 32 // Test fixture which allows us to override the default enumeration API on |
33 // Windows. | 33 // Windows. |
34 class AudioManagerTest : public ::testing::Test { | 34 class AudioManagerTest : public ::testing::Test { |
35 protected: | 35 protected: |
36 AudioManagerTest() | 36 AudioManagerTest() : audio_manager_(AudioManager::CreateForTesting()) {} |
37 : audio_manager_(AudioManager::CreateForTesting()) | |
38 #if defined(OS_WIN) | |
39 , com_init_(base::win::ScopedCOMInitializer::kMTA) | |
40 #endif | |
41 { | |
42 // Wait for audio thread initialization to complete. Otherwise the | |
43 // enumeration type may not have been set yet. | |
44 base::WaitableEvent event(false, false); | |
45 audio_manager_->GetTaskRunner()->PostTask(FROM_HERE, base::Bind( | |
46 &base::WaitableEvent::Signal, base::Unretained(&event))); | |
47 event.Wait(); | |
48 } | |
49 | 37 |
50 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
51 bool SetMMDeviceEnumeration() { | 39 bool SetMMDeviceEnumeration() { |
52 AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); | 40 AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); |
53 // Windows Wave is used as default if Windows XP was detected => | 41 // Windows Wave is used as default if Windows XP was detected => |
54 // return false since MMDevice is not supported on XP. | 42 // return false since MMDevice is not supported on XP. |
55 if (amw->enumeration_type() == AudioManagerWin::kWaveEnumeration) | 43 if (amw->enumeration_type() == AudioManagerWin::kWaveEnumeration) |
56 return false; | 44 return false; |
57 | 45 |
58 amw->SetEnumerationType(AudioManagerWin::kMMDeviceEnumeration); | 46 amw->set_enumeration_type(AudioManagerWin::kMMDeviceEnumeration); |
59 return true; | 47 return true; |
60 } | 48 } |
61 | 49 |
62 void SetWaveEnumeration() { | 50 void SetWaveEnumeration() { |
63 AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); | 51 AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); |
64 amw->SetEnumerationType(AudioManagerWin::kWaveEnumeration); | 52 amw->set_enumeration_type(AudioManagerWin::kWaveEnumeration); |
65 } | 53 } |
66 | 54 |
67 std::string GetDeviceIdFromPCMWaveInAudioInputStream( | 55 std::string GetDeviceIdFromPCMWaveInAudioInputStream( |
68 const std::string& device_id) { | 56 const std::string& device_id) { |
69 AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); | 57 AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); |
70 AudioParameters parameters( | 58 AudioParameters parameters( |
71 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, | 59 AudioParameters::AUDIO_PCM_LINEAR, CHANNEL_LAYOUT_STEREO, |
72 AudioParameters::kAudioCDSampleRate, 16, | 60 AudioParameters::kAudioCDSampleRate, 16, |
73 1024); | 61 1024); |
74 scoped_ptr<PCMWaveInAudioInputStream> stream( | 62 scoped_ptr<PCMWaveInAudioInputStream> stream( |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 DVLOG(2) << it->unique_id << " matches with " << output_device_id; | 359 DVLOG(2) << it->unique_id << " matches with " << output_device_id; |
372 found_an_associated_device = true; | 360 found_an_associated_device = true; |
373 } | 361 } |
374 } | 362 } |
375 | 363 |
376 EXPECT_TRUE(found_an_associated_device); | 364 EXPECT_TRUE(found_an_associated_device); |
377 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 365 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
378 } | 366 } |
379 | 367 |
380 } // namespace media | 368 } // namespace media |
OLD | NEW |