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

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

Issue 9369009: Make content::ResourceContext be a real interface like the rest of the Content API (i.e. don't ha... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: sync Created 8 years, 10 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
11 #include "content/browser/renderer_host/media/audio_common.h" 11 #include "content/browser/renderer_host/media/audio_common.h"
12 #include "content/browser/renderer_host/media/audio_input_device_manager.h" 12 #include "content/browser/renderer_host/media/audio_input_device_manager.h"
13 #include "content/browser/renderer_host/media/audio_input_sync_writer.h" 13 #include "content/browser/renderer_host/media/audio_input_sync_writer.h"
14 #include "content/browser/renderer_host/media/media_stream_manager.h" 14 #include "content/browser/renderer_host/media/media_stream_manager.h"
15 #include "content/browser/resource_context.h" 15 #include "content/browser/resource_context.h"
16 #include "content/common/media/audio_messages.h" 16 #include "content/common/media/audio_messages.h"
17 #include "ipc/ipc_logging.h" 17 #include "ipc/ipc_logging.h"
18 18
19 using content::BrowserMessageFilter; 19 using content::BrowserMessageFilter;
20 using content::BrowserThread; 20 using content::BrowserThread;
21 21
22 AudioInputRendererHost::AudioEntry::AudioEntry() 22 AudioInputRendererHost::AudioEntry::AudioEntry()
23 : stream_id(0), 23 : stream_id(0),
24 pending_close(false) { 24 pending_close(false) {
25 } 25 }
26 26
27 AudioInputRendererHost::AudioEntry::~AudioEntry() {} 27 AudioInputRendererHost::AudioEntry::~AudioEntry() {}
28 28
29 AudioInputRendererHost::AudioInputRendererHost( 29 AudioInputRendererHost::AudioInputRendererHost(
30 const content::ResourceContext* resource_context) 30 content::ResourceContext* resource_context)
31 : resource_context_(resource_context) { 31 : resource_context_(resource_context) {
32 } 32 }
33 33
34 AudioInputRendererHost::~AudioInputRendererHost() { 34 AudioInputRendererHost::~AudioInputRendererHost() {
35 DCHECK(audio_entries_.empty()); 35 DCHECK(audio_entries_.empty());
36 } 36 }
37 37
38 void AudioInputRendererHost::OnChannelClosing() { 38 void AudioInputRendererHost::OnChannelClosing() {
39 BrowserMessageFilter::OnChannelClosing(); 39 BrowserMessageFilter::OnChannelClosing();
40 40
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 IPC_END_MESSAGE_MAP_EX() 182 IPC_END_MESSAGE_MAP_EX()
183 183
184 return handled; 184 return handled;
185 } 185 }
186 void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) { 186 void AudioInputRendererHost::OnStartDevice(int stream_id, int session_id) {
187 VLOG(1) << "AudioInputRendererHost::OnStartDevice(stream_id=" 187 VLOG(1) << "AudioInputRendererHost::OnStartDevice(stream_id="
188 << stream_id << ", session_id = " << session_id << ")"; 188 << stream_id << ", session_id = " << session_id << ")";
189 189
190 // Get access to the AudioInputDeviceManager to start the device. 190 // Get access to the AudioInputDeviceManager to start the device.
191 media_stream::AudioInputDeviceManager* audio_input_man = 191 media_stream::AudioInputDeviceManager* audio_input_man =
192 resource_context_->media_stream_manager()->audio_input_device_manager(); 192 resource_context_->GetMediaStreamManager()->audio_input_device_manager();
193 193
194 // Add the session entry to the map. 194 // Add the session entry to the map.
195 session_entries_[session_id] = stream_id; 195 session_entries_[session_id] = stream_id;
196 196
197 // Start the device with the session_id. If the device is started 197 // Start the device with the session_id. If the device is started
198 // successfully, OnDeviceStarted() callback will be triggered. 198 // successfully, OnDeviceStarted() callback will be triggered.
199 audio_input_man->Start(session_id, this); 199 audio_input_man->Start(session_id, this);
200 } 200 }
201 201
202 void AudioInputRendererHost::OnCreateStream(int stream_id, 202 void AudioInputRendererHost::OnCreateStream(int stream_id,
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 return; 234 return;
235 } 235 }
236 236
237 // If we have successfully created the SyncWriter then assign it to the 237 // If we have successfully created the SyncWriter then assign it to the
238 // entry and construct an AudioInputController. 238 // entry and construct an AudioInputController.
239 // TODO(henrika): replace CreateLowLatency() with Create() as soon 239 // TODO(henrika): replace CreateLowLatency() with Create() as soon
240 // as satish has ensured that Speech Input also uses the default low- 240 // as satish has ensured that Speech Input also uses the default low-
241 // latency path. See crbug.com/112472 for details. 241 // latency path. See crbug.com/112472 for details.
242 entry->writer.reset(writer.release()); 242 entry->writer.reset(writer.release());
243 entry->controller = media::AudioInputController::CreateLowLatency( 243 entry->controller = media::AudioInputController::CreateLowLatency(
244 resource_context_->audio_manager(), 244 resource_context_->GetAudioManager(),
245 this, 245 this,
246 audio_params, 246 audio_params,
247 device_id, 247 device_id,
248 entry->writer.get()); 248 entry->writer.get());
249 249
250 if (!entry->controller) { 250 if (!entry->controller) {
251 SendErrorMessage(stream_id); 251 SendErrorMessage(stream_id);
252 return; 252 return;
253 } 253 }
254 254
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 } 360 }
361 361
362 // Delete the session entry. 362 // Delete the session entry.
363 session_entries_.erase(it); 363 session_entries_.erase(it);
364 } 364 }
365 365
366 void AudioInputRendererHost::StopAndDeleteDevice(int session_id) { 366 void AudioInputRendererHost::StopAndDeleteDevice(int session_id) {
367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 367 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
368 368
369 media_stream::AudioInputDeviceManager* audio_input_man = 369 media_stream::AudioInputDeviceManager* audio_input_man =
370 resource_context_->media_stream_manager()->audio_input_device_manager(); 370 resource_context_->GetMediaStreamManager()->audio_input_device_manager();
371 audio_input_man->Stop(session_id); 371 audio_input_man->Stop(session_id);
372 372
373 // Delete the session entry. 373 // Delete the session entry.
374 session_entries_.erase(session_id); 374 session_entries_.erase(session_id);
375 } 375 }
376 376
377 void AudioInputRendererHost::CloseAndDeleteStream(AudioEntry* entry) { 377 void AudioInputRendererHost::CloseAndDeleteStream(AudioEntry* entry) {
378 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 378 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
379 379
380 if (!entry->pending_close) { 380 if (!entry->pending_close) {
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
442 442
443 for (SessionEntryMap::iterator it = session_entries_.begin(); 443 for (SessionEntryMap::iterator it = session_entries_.begin();
444 it != session_entries_.end(); ++it) { 444 it != session_entries_.end(); ++it) {
445 if (stream_id == it->second) { 445 if (stream_id == it->second) {
446 return it->first; 446 return it->first;
447 } 447 }
448 } 448 }
449 return 0; 449 return 0;
450 } 450 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698