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

Side by Side Diff: content/browser/renderer_host/media/audio_input_renderer_host.cc

Issue 10662049: Move the device enumerate/open/close work to device thread from IO thread (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: addressed Magnus' comments. Created 8 years, 5 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 | Annotate | Revision Log
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/browser/renderer_host/media/audio_input_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_input_renderer_host.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/process.h" 9 #include "base/process.h"
10 #include "base/shared_memory.h" 10 #include "base/shared_memory.h"
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 return handled; 179 return handled;
180 } 180 }
181 void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) { 181 void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) {
182 VLOG(1) << "AudioInputRendererHost::OnStartDevice(stream_id=" 182 VLOG(1) << "AudioInputRendererHost::OnStartDevice(stream_id="
183 << stream_id << ", session_id = " << session_id << ")"; 183 << stream_id << ", session_id = " << session_id << ")";
184 184
185 // Get access to the AudioInputDeviceManager to start the device. 185 // Get access to the AudioInputDeviceManager to start the device.
186 media_stream::AudioInputDeviceManager* audio_input_man = 186 media_stream::AudioInputDeviceManager* audio_input_man =
187 media_stream::MediaStreamManager::GetForResourceContext( 187 media_stream::MediaStreamManager::GetForResourceContext(
188 resource_context_, audio_manager_)->audio_input_device_manager(); 188 resource_context_)->audio_input_device_manager();
189 189
190 // Add the session entry to the map. 190 // Add the session entry to the map.
191 session_entries_[session_id] = stream_id; 191 session_entries_[session_id] = stream_id;
192 192
193 // Start the device with the session_id. If the device is started 193 // Start the device with the session_id. If the device is started
194 // successfully, OnDeviceStarted() callback will be triggered. 194 // successfully, OnDeviceStarted() callback will be triggered.
195 audio_input_man->Start(session_id, this); 195 audio_input_man->Start(session_id, this);
196 } 196 }
197 197
198 void AudioInputRendererHost::OnCreateStream( 198 void AudioInputRendererHost::OnCreateStream(
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 344
345 // Delete the session entry. 345 // Delete the session entry.
346 session_entries_.erase(it); 346 session_entries_.erase(it);
347 } 347 }
348 348
349 void AudioInputRendererHost::StopAndDeleteDevice(int session_id) { 349 void AudioInputRendererHost::StopAndDeleteDevice(int session_id) {
350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 350 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
351 351
352 media_stream::AudioInputDeviceManager* audio_input_man = 352 media_stream::AudioInputDeviceManager* audio_input_man =
353 media_stream::MediaStreamManager::GetForResourceContext( 353 media_stream::MediaStreamManager::GetForResourceContext(
354 resource_context_, audio_manager_)->audio_input_device_manager(); 354 resource_context_)->audio_input_device_manager();
355 audio_input_man->Stop(session_id); 355 audio_input_man->Stop(session_id);
356 356
357 // Delete the session entry. 357 // Delete the session entry.
358 session_entries_.erase(session_id); 358 session_entries_.erase(session_id);
359 } 359 }
360 360
361 void AudioInputRendererHost::CloseAndDeleteStream(AudioEntry* entry) { 361 void AudioInputRendererHost::CloseAndDeleteStream(AudioEntry* entry) {
362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 362 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
363 363
364 if (!entry->pending_close) { 364 if (!entry->pending_close) {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 415 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
416 416
417 for (SessionEntryMap::iterator it = session_entries_.begin(); 417 for (SessionEntryMap::iterator it = session_entries_.begin();
418 it != session_entries_.end(); ++it) { 418 it != session_entries_.end(); ++it) {
419 if (stream_id == it->second) { 419 if (stream_id == it->second) {
420 return it->first; 420 return it->first;
421 } 421 }
422 } 422 }
423 return 0; 423 return 0;
424 } 424 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698