| 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/environment.h" | 5 #include "base/environment.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/synchronization/waitable_event.h" |
| 8 #include "media/audio/audio_manager.h" | 9 #include "media/audio/audio_manager.h" |
| 9 #include "media/audio/audio_manager_base.h" | 10 #include "media/audio/audio_manager_base.h" |
| 10 #include "media/audio/fake_audio_log_factory.h" | 11 #include "media/audio/fake_audio_log_factory.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 12 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 13 |
| 13 #if defined(USE_ALSA) | 14 #if defined(USE_ALSA) |
| 14 #include "media/audio/alsa/audio_manager_alsa.h" | 15 #include "media/audio/alsa/audio_manager_alsa.h" |
| 15 #endif // defined(USE_ALSA) | 16 #endif // defined(USE_ALSA) |
| 16 | 17 |
| 17 #if defined(OS_WIN) | 18 #if defined(OS_WIN) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 // Windows. | 31 // Windows. |
| 31 class AudioManagerTest | 32 class AudioManagerTest |
| 32 : public ::testing::Test { | 33 : public ::testing::Test { |
| 33 protected: | 34 protected: |
| 34 AudioManagerTest() | 35 AudioManagerTest() |
| 35 : audio_manager_(AudioManager::CreateForTesting()) | 36 : audio_manager_(AudioManager::CreateForTesting()) |
| 36 #if defined(OS_WIN) | 37 #if defined(OS_WIN) |
| 37 , com_init_(base::win::ScopedCOMInitializer::kMTA) | 38 , com_init_(base::win::ScopedCOMInitializer::kMTA) |
| 38 #endif | 39 #endif |
| 39 { | 40 { |
| 41 // Wait for audio thread initialization to complete. Otherwise the |
| 42 // enumeration type may not have been set yet. |
| 43 base::WaitableEvent event(false, false); |
| 44 audio_manager_->GetTaskRunner()->PostTask(FROM_HERE, base::Bind( |
| 45 &base::WaitableEvent::Signal, base::Unretained(&event))); |
| 46 event.Wait(); |
| 40 } | 47 } |
| 41 | 48 |
| 42 #if defined(OS_WIN) | 49 #if defined(OS_WIN) |
| 43 bool SetMMDeviceEnumeration() { | 50 bool SetMMDeviceEnumeration() { |
| 44 AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); | 51 AudioManagerWin* amw = static_cast<AudioManagerWin*>(audio_manager_.get()); |
| 45 // Windows Wave is used as default if Windows XP was detected => | 52 // Windows Wave is used as default if Windows XP was detected => |
| 46 // return false since MMDevice is not supported on XP. | 53 // return false since MMDevice is not supported on XP. |
| 47 if (amw->enumeration_type() == AudioManagerWin::kWaveEnumeration) | 54 if (amw->enumeration_type() == AudioManagerWin::kWaveEnumeration) |
| 48 return false; | 55 return false; |
| 49 | 56 |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 VLOG(2) << it->unique_id << " matches with " << output_device_id; | 355 VLOG(2) << it->unique_id << " matches with " << output_device_id; |
| 349 found_an_associated_device = true; | 356 found_an_associated_device = true; |
| 350 } | 357 } |
| 351 } | 358 } |
| 352 | 359 |
| 353 EXPECT_TRUE(found_an_associated_device); | 360 EXPECT_TRUE(found_an_associated_device); |
| 354 #endif // defined(OS_WIN) || defined(OS_MACOSX) | 361 #endif // defined(OS_WIN) || defined(OS_MACOSX) |
| 355 } | 362 } |
| 356 | 363 |
| 357 } // namespace media | 364 } // namespace media |
| OLD | NEW |