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/logging.h" | 7 #include "base/logging.h" |
8 #include "base/single_thread_task_runner.h" | 8 #include "base/single_thread_task_runner.h" |
9 #include "media/base/audio_parameters.h" | 9 #include "media/base/audio_parameters.h" |
10 | 10 |
11 namespace media { | 11 namespace media { |
12 | 12 |
| 13 void MockAudioManager::Deleter::operator()( |
| 14 const MockAudioManager* instance) const { |
| 15 CHECK(instance); |
| 16 if (instance->GetTaskRunner()->BelongsToCurrentThread()) { |
| 17 delete instance; |
| 18 return; |
| 19 } |
| 20 // AudioManager must be destroyed on the audio thread. |
| 21 if (!instance->GetTaskRunner()->DeleteSoon(FROM_HERE, instance)) { |
| 22 LOG(WARNING) << "Failed to delete AudioManager instance."; |
| 23 } |
| 24 } |
| 25 |
13 MockAudioManager::MockAudioManager( | 26 MockAudioManager::MockAudioManager( |
14 scoped_refptr<base::SingleThreadTaskRunner> task_runner) | 27 scoped_refptr<base::SingleThreadTaskRunner> task_runner) |
15 : AudioManager(task_runner, task_runner) {} | 28 : AudioManager(task_runner, task_runner) {} |
16 | 29 |
17 MockAudioManager::~MockAudioManager() { | 30 MockAudioManager::~MockAudioManager() { |
18 } | 31 } |
19 | 32 |
20 bool MockAudioManager::HasAudioOutputDevices() { | 33 bool MockAudioManager::HasAudioOutputDevices() { |
| 34 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
21 return true; | 35 return true; |
22 } | 36 } |
23 | 37 |
24 bool MockAudioManager::HasAudioInputDevices() { | 38 bool MockAudioManager::HasAudioInputDevices() { |
25 return true; | 39 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 40 return has_input_devices_; |
26 } | 41 } |
27 | 42 |
28 base::string16 MockAudioManager::GetAudioInputDeviceModel() { | 43 base::string16 MockAudioManager::GetAudioInputDeviceModel() { |
| 44 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
29 return base::string16(); | 45 return base::string16(); |
30 } | 46 } |
31 | 47 |
32 void MockAudioManager::ShowAudioInputSettings() { | 48 void MockAudioManager::ShowAudioInputSettings() { |
33 } | 49 } |
34 | 50 |
35 void MockAudioManager::GetAudioInputDeviceDescriptions( | 51 void MockAudioManager::GetAudioInputDeviceDescriptions( |
36 AudioDeviceDescriptions* device_descriptions) {} | 52 AudioDeviceDescriptions* device_descriptions) { |
| 53 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 54 } |
37 | 55 |
38 void MockAudioManager::GetAudioOutputDeviceDescriptions( | 56 void MockAudioManager::GetAudioOutputDeviceDescriptions( |
39 AudioDeviceDescriptions* device_descriptions) {} | 57 AudioDeviceDescriptions* device_descriptions) { |
| 58 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 59 } |
40 | 60 |
41 media::AudioOutputStream* MockAudioManager::MakeAudioOutputStream( | 61 media::AudioOutputStream* MockAudioManager::MakeAudioOutputStream( |
42 const media::AudioParameters& params, | 62 const media::AudioParameters& params, |
43 const std::string& device_id, | 63 const std::string& device_id, |
44 const LogCallback& log_callback) { | 64 const LogCallback& log_callback) { |
45 NOTREACHED(); | 65 NOTREACHED(); |
46 return NULL; | 66 return NULL; |
47 } | 67 } |
48 | 68 |
49 media::AudioOutputStream* MockAudioManager::MakeAudioOutputStreamProxy( | 69 media::AudioOutputStream* MockAudioManager::MakeAudioOutputStreamProxy( |
(...skipping 18 matching lines...) Expand all Loading... |
68 void MockAudioManager::RemoveOutputDeviceChangeListener( | 88 void MockAudioManager::RemoveOutputDeviceChangeListener( |
69 AudioDeviceListener* listener) { | 89 AudioDeviceListener* listener) { |
70 } | 90 } |
71 | 91 |
72 AudioParameters MockAudioManager::GetDefaultOutputStreamParameters() { | 92 AudioParameters MockAudioManager::GetDefaultOutputStreamParameters() { |
73 return AudioParameters(); | 93 return AudioParameters(); |
74 } | 94 } |
75 | 95 |
76 AudioParameters MockAudioManager::GetOutputStreamParameters( | 96 AudioParameters MockAudioManager::GetOutputStreamParameters( |
77 const std::string& device_id) { | 97 const std::string& device_id) { |
| 98 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
78 return AudioParameters(); | 99 return AudioParameters(); |
79 } | 100 } |
80 | 101 |
81 AudioParameters MockAudioManager::GetInputStreamParameters( | 102 AudioParameters MockAudioManager::GetInputStreamParameters( |
82 const std::string& device_id) { | 103 const std::string& device_id) { |
83 return AudioParameters(); | 104 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
| 105 return input_params_; |
84 } | 106 } |
85 | 107 |
86 std::string MockAudioManager::GetAssociatedOutputDeviceID( | 108 std::string MockAudioManager::GetAssociatedOutputDeviceID( |
87 const std::string& input_device_id) { | 109 const std::string& input_device_id) { |
| 110 DCHECK(GetTaskRunner()->BelongsToCurrentThread()); |
88 return std::string(); | 111 return std::string(); |
89 } | 112 } |
90 | 113 |
91 std::unique_ptr<AudioLog> MockAudioManager::CreateAudioLog( | 114 std::unique_ptr<AudioLog> MockAudioManager::CreateAudioLog( |
92 AudioLogFactory::AudioComponent component) { | 115 AudioLogFactory::AudioComponent component) { |
93 return nullptr; | 116 return nullptr; |
94 } | 117 } |
95 | 118 |
96 const char* MockAudioManager::GetName() { | 119 const char* MockAudioManager::GetName() { |
97 return nullptr; | 120 return nullptr; |
98 } | 121 } |
99 | 122 |
| 123 void MockAudioManager::SetInputStreamParameters( |
| 124 const AudioParameters& input_params) { |
| 125 input_params_ = input_params; |
| 126 } |
| 127 |
| 128 void MockAudioManager::SetHasInputDevices(bool has_input_devices) { |
| 129 has_input_devices_ = has_input_devices; |
| 130 } |
| 131 |
100 } // namespace media. | 132 } // namespace media. |
OLD | NEW |