| 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 "media/audio/mock_audio_manager.h" | 5 #include "media/audio/mock_audio_manager.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/single_thread_task_runner.h" | 9 #include "base/single_thread_task_runner.h" |
| 10 #include "media/base/audio_parameters.h" | 10 #include "media/base/audio_parameters.h" |
| 11 | 11 |
| 12 namespace media { | 12 namespace media { |
| 13 | 13 |
| 14 void MockAudioManager::Deleter::operator()( | 14 MockAudioManager::MockAudioManager(std::unique_ptr<AudioThread> audio_thread) |
| 15 const MockAudioManager* instance) const { | 15 : AudioManager(std::move(audio_thread)) {} |
| 16 CHECK(instance); | |
| 17 if (instance->GetTaskRunner()->BelongsToCurrentThread()) { | |
| 18 delete instance; | |
| 19 return; | |
| 20 } | |
| 21 // AudioManager must be destroyed on the audio thread. | |
| 22 if (!instance->GetTaskRunner()->DeleteSoon(FROM_HERE, instance)) { | |
| 23 LOG(WARNING) << "Failed to delete AudioManager instance."; | |
| 24 } | |
| 25 } | |
| 26 | |
| 27 MockAudioManager::MockAudioManager( | |
| 28 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | |
| 29 : AudioManager(task_runner, task_runner) {} | |
| 30 | 16 |
| 31 MockAudioManager::~MockAudioManager() { | 17 MockAudioManager::~MockAudioManager() { |
| 32 } | 18 } |
| 33 | 19 |
| 20 void MockAudioManager::ShutdownOnAudioThread() {} |
| 21 |
| 34 bool MockAudioManager::HasAudioOutputDevices() { | 22 bool MockAudioManager::HasAudioOutputDevices() { |
| 35 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 23 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 36 return has_output_devices_; | 24 return has_output_devices_; |
| 37 } | 25 } |
| 38 | 26 |
| 39 bool MockAudioManager::HasAudioInputDevices() { | 27 bool MockAudioManager::HasAudioInputDevices() { |
| 40 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); | 28 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 41 return has_input_devices_; | 29 return has_input_devices_; |
| 42 } | 30 } |
| 43 | 31 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 GetDeviceDescriptionsCallback callback) { | 156 GetDeviceDescriptionsCallback callback) { |
| 169 get_output_device_descriptions_cb_ = std::move(callback); | 157 get_output_device_descriptions_cb_ = std::move(callback); |
| 170 } | 158 } |
| 171 | 159 |
| 172 void MockAudioManager::SetAssociatedOutputDeviceIDCallback( | 160 void MockAudioManager::SetAssociatedOutputDeviceIDCallback( |
| 173 GetAssociatedOutputDeviceIDCallback callback) { | 161 GetAssociatedOutputDeviceIDCallback callback) { |
| 174 get_associated_output_device_id_cb_ = std::move(callback); | 162 get_associated_output_device_id_cb_ = std::move(callback); |
| 175 } | 163 } |
| 176 | 164 |
| 177 } // namespace media. | 165 } // namespace media. |
| OLD | NEW |