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