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