| 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/renderer/media/audio_input_message_filter.h" | 8 #include "content/renderer/media/audio_input_message_filter.h" |
| 9 #include "content/renderer/media/audio_message_filter.h" | 9 #include "content/renderer/media/audio_message_filter.h" |
| 10 #include "content/renderer/media/audio_renderer_mixer_manager.h" | 10 #include "content/renderer/media/audio_renderer_mixer_manager.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 if (source) | 128 if (source) |
| 129 return source; | 129 return source; |
| 130 } | 130 } |
| 131 | 131 |
| 132 AudioInputMessageFilter* const filter = AudioInputMessageFilter::Get(); | 132 AudioInputMessageFilter* const filter = AudioInputMessageFilter::Get(); |
| 133 return new media::AudioInputDevice( | 133 return new media::AudioInputDevice( |
| 134 filter->CreateAudioInputIPC(render_frame_id), filter->io_task_runner()); | 134 filter->CreateAudioInputIPC(render_frame_id), filter->io_task_runner()); |
| 135 } | 135 } |
| 136 | 136 |
| 137 // static | 137 // static |
| 138 // TODO(http://crbug.com/587461): Find a better way to check if device exists | |
| 139 // and is authorized. | |
| 140 media::OutputDeviceInfo AudioDeviceFactory::GetOutputDeviceInfo( | 138 media::OutputDeviceInfo AudioDeviceFactory::GetOutputDeviceInfo( |
| 141 int render_frame_id, | 139 int render_frame_id, |
| 142 int session_id, | 140 int session_id, |
| 143 const std::string& device_id, | 141 const std::string& device_id, |
| 144 const url::Origin& security_origin) { | 142 const url::Origin& security_origin) { |
| 145 scoped_refptr<media::AudioRendererSink> sink = NewFinalAudioRendererSink( | 143 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 144 DCHECK(render_thread) << "RenderThreadImpl is not instantiated, or " |
| 145 << "GetOutputDeviceInfo() is called on a wrong thread "; |
| 146 return render_thread->GetAudioRendererMixerManager()->GetOutputDeviceInfo( |
| 146 render_frame_id, session_id, device_id, security_origin); | 147 render_frame_id, session_id, device_id, security_origin); |
| 147 | |
| 148 const media::OutputDeviceInfo& device_info = sink->GetOutputDeviceInfo(); | |
| 149 | |
| 150 // TODO(olka): Cache it and reuse, http://crbug.com/586161 | |
| 151 sink->Stop(); // Must be stopped. | |
| 152 | |
| 153 return device_info; | |
| 154 } | 148 } |
| 155 | 149 |
| 156 AudioDeviceFactory::AudioDeviceFactory() { | 150 AudioDeviceFactory::AudioDeviceFactory() { |
| 157 DCHECK(!factory_) << "Can't register two factories at once."; | 151 DCHECK(!factory_) << "Can't register two factories at once."; |
| 158 factory_ = this; | 152 factory_ = this; |
| 159 } | 153 } |
| 160 | 154 |
| 161 AudioDeviceFactory::~AudioDeviceFactory() { | 155 AudioDeviceFactory::~AudioDeviceFactory() { |
| 162 factory_ = NULL; | 156 factory_ = NULL; |
| 163 } | 157 } |
| (...skipping 11 matching lines...) Expand all Loading... |
| 175 device_id, security_origin); | 169 device_id, security_origin); |
| 176 if (sink) | 170 if (sink) |
| 177 return sink; | 171 return sink; |
| 178 } | 172 } |
| 179 | 173 |
| 180 return NewOutputDevice(render_frame_id, session_id, device_id, | 174 return NewOutputDevice(render_frame_id, session_id, device_id, |
| 181 security_origin); | 175 security_origin); |
| 182 } | 176 } |
| 183 | 177 |
| 184 } // namespace content | 178 } // namespace content |
| OLD | NEW |