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

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

Issue 8818012: Remove the AudioManager singleton. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Set svn eol properties for a couple of files Created 9 years 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_renderer_host.h" 5 #include "content/browser/renderer_host/media/audio_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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 // Then try to initialize the sync reader. 263 // Then try to initialize the sync reader.
264 if (!reader->Init()) { 264 if (!reader->Init()) {
265 SendErrorMessage(stream_id); 265 SendErrorMessage(stream_id);
266 return; 266 return;
267 } 267 }
268 268
269 // If we have successfully created the SyncReader then assign it to the 269 // If we have successfully created the SyncReader then assign it to the
270 // entry and construct an AudioOutputController. 270 // entry and construct an AudioOutputController.
271 entry->reader.reset(reader.release()); 271 entry->reader.reset(reader.release());
272 entry->controller = 272 entry->controller =
273 media::AudioOutputController::CreateLowLatency(this, audio_params, 273 media::AudioOutputController::CreateLowLatency(
274 entry->reader.get()); 274 resource_context_->audio_manager(), this, audio_params,
275 entry->reader.get());
275 } else { 276 } else {
276 // The choice of buffer capacity is based on experiment. 277 // The choice of buffer capacity is based on experiment.
277 entry->controller = 278 entry->controller =
278 media::AudioOutputController::Create(this, audio_params, 279 media::AudioOutputController::Create(
279 3 * packet_size); 280 resource_context_->audio_manager(), this, audio_params,
281 3 * packet_size);
280 } 282 }
281 283
282 if (!entry->controller) { 284 if (!entry->controller) {
283 SendErrorMessage(stream_id); 285 SendErrorMessage(stream_id);
284 return; 286 return;
285 } 287 }
286 288
287 // If we have created the controller successfully create a entry and add it 289 // If we have created the controller successfully create a entry and add it
288 // to the map. 290 // to the map.
289 entry->stream_id = stream_id; 291 entry->stream_id = stream_id;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
392 void AudioRendererHost::DeleteEntries() { 394 void AudioRendererHost::DeleteEntries() {
393 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 395 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
394 396
395 for (AudioEntryMap::iterator i = audio_entries_.begin(); 397 for (AudioEntryMap::iterator i = audio_entries_.begin();
396 i != audio_entries_.end(); ++i) { 398 i != audio_entries_.end(); ++i) {
397 CloseAndDeleteStream(i->second); 399 CloseAndDeleteStream(i->second);
398 } 400 }
399 } 401 }
400 402
401 void AudioRendererHost::CloseAndDeleteStream(AudioEntry* entry) { 403 void AudioRendererHost::CloseAndDeleteStream(AudioEntry* entry) {
404 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
405
402 if (!entry->pending_close) { 406 if (!entry->pending_close) {
403 entry->controller->Close( 407 entry->controller->Close(
404 base::Bind(&AudioRendererHost::OnStreamClosed, this, entry)); 408 base::Bind(&AudioRendererHost::OnStreamClosed, this, entry));
405 entry->pending_close = true; 409 entry->pending_close = true;
406 } 410 }
407 } 411 }
408 412
409 void AudioRendererHost::OnStreamClosed(AudioEntry* entry) { 413 void AudioRendererHost::OnStreamClosed(AudioEntry* entry) {
410 // Delete the entry after we've closed the stream. 414 // Delete the entry on the IO thread after we've closed the stream.
415 // (We're currently on the audio thread).
411 BrowserThread::PostTask( 416 BrowserThread::PostTask(
412 BrowserThread::IO, FROM_HERE, 417 BrowserThread::IO, FROM_HERE,
413 base::Bind(&AudioRendererHost::DeleteEntry, this, entry)); 418 base::Bind(&AudioRendererHost::DeleteEntry, this, entry));
414 } 419 }
415 420
416 void AudioRendererHost::DeleteEntry(AudioEntry* entry) { 421 void AudioRendererHost::DeleteEntry(AudioEntry* entry) {
417 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 422 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
418 423
419 // Delete the entry when this method goes out of scope. 424 // Delete the entry when this method goes out of scope.
420 scoped_ptr<AudioEntry> entry_deleter(entry); 425 scoped_ptr<AudioEntry> entry_deleter(entry);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 } 464 }
460 return NULL; 465 return NULL;
461 } 466 }
462 467
463 MediaObserver* AudioRendererHost::media_observer() { 468 MediaObserver* AudioRendererHost::media_observer() {
464 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); 469 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
465 if (!media_observer_) 470 if (!media_observer_)
466 media_observer_ = resource_context_->media_observer(); 471 media_observer_ = resource_context_->media_observer();
467 return media_observer_; 472 return media_observer_;
468 } 473 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698