Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(331)

Side by Side Diff: content/renderer/media/audio_device_factory.cc

Issue 1942803002: Caching AudioOutputDevice instances in mixer manager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase, fix for sleep() compile error on win and a bit of cleanup around timeouts. Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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();
miu 2016/05/12 21:53:06 Not sure if this happens in any unit tests, but wh
o1ka 2016/05/17 17:17:23 Done. Now it does not happen in unit tests (and I
144 return render_thread->GetAudioRendererMixerManager()->GetOutputDeviceInfo(
146 render_frame_id, session_id, device_id, security_origin); 145 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 } 146 }
155 147
156 AudioDeviceFactory::AudioDeviceFactory() { 148 AudioDeviceFactory::AudioDeviceFactory() {
157 DCHECK(!factory_) << "Can't register two factories at once."; 149 DCHECK(!factory_) << "Can't register two factories at once.";
158 factory_ = this; 150 factory_ = this;
159 } 151 }
160 152
161 AudioDeviceFactory::~AudioDeviceFactory() { 153 AudioDeviceFactory::~AudioDeviceFactory() {
162 factory_ = NULL; 154 factory_ = NULL;
163 } 155 }
(...skipping 11 matching lines...) Expand all
175 device_id, security_origin); 167 device_id, security_origin);
176 if (sink) 168 if (sink)
177 return sink; 169 return sink;
178 } 170 }
179 171
180 return NewOutputDevice(render_frame_id, session_id, device_id, 172 return NewOutputDevice(render_frame_id, session_id, device_id,
181 security_origin); 173 security_origin);
182 } 174 }
183 175
184 } // namespace content 176 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698