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 "content/renderer/media/audio_device_factory.h" | 5 #include "content/renderer/media/audio_device_factory.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "content/common/child_process.h" | 8 #include "content/common/child_process.h" |
9 #include "content/renderer/media/audio_device.h" | 9 #include "content/renderer/media/audio_device.h" |
| 10 #include "content/renderer/media/audio_input_device.h" |
| 11 #include "content/renderer/media/audio_input_message_filter.h" |
| 12 #include "content/renderer/media/audio_message_filter.h" |
10 | 13 |
11 namespace content { | 14 namespace content { |
12 | 15 |
13 // static | 16 // static |
14 AudioDeviceFactory* AudioDeviceFactory::factory_ = NULL; | 17 AudioDeviceFactory* AudioDeviceFactory::factory_ = NULL; |
15 | 18 |
16 // static | 19 // static |
17 media::AudioRendererSink* AudioDeviceFactory::Create() { | 20 media::AudioRendererSink* AudioDeviceFactory::NewOutputDevice() { |
18 if (factory_) { | 21 media::AudioRendererSink* device = NULL; |
19 return factory_->CreateAudioDevice(); | 22 if (factory_) |
20 } | 23 device = factory_->CreateOutputDevice(); |
21 return new AudioDevice( | 24 |
| 25 return device ? device : new AudioDevice( |
| 26 AudioMessageFilter::Get(), |
22 ChildProcess::current()->io_message_loop()->message_loop_proxy()); | 27 ChildProcess::current()->io_message_loop()->message_loop_proxy()); |
23 } | 28 } |
24 | 29 |
| 30 // static |
| 31 AudioInputDevice* AudioDeviceFactory::NewInputDevice() { |
| 32 AudioInputDevice* device = NULL; |
| 33 if (factory_) |
| 34 device = factory_->CreateInputDevice(); |
| 35 |
| 36 return device ? device : new AudioInputDevice( |
| 37 AudioInputMessageFilter::Get(), |
| 38 ChildProcess::current()->io_message_loop()->message_loop_proxy()); |
| 39 } |
| 40 |
25 AudioDeviceFactory::AudioDeviceFactory() { | 41 AudioDeviceFactory::AudioDeviceFactory() { |
26 DCHECK(!factory_) << "Can't register two factories at once."; | 42 DCHECK(!factory_) << "Can't register two factories at once."; |
27 factory_ = this; | 43 factory_ = this; |
28 } | 44 } |
29 | 45 |
30 AudioDeviceFactory::~AudioDeviceFactory() { | 46 AudioDeviceFactory::~AudioDeviceFactory() { |
31 factory_ = NULL; | 47 factory_ = NULL; |
32 } | 48 } |
33 | 49 |
34 } // namespace content | 50 } // namespace content |
OLD | NEW |