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

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

Issue 1172883003: Fix for undesired audio blip when closing a muted tab. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix crash on Windows (grab pointer before scoped_ptr is passed). Created 5 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/shared_memory.h" 10 #include "base/memory/shared_memory.h"
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 432
433 // Prevent oustanding callbacks from attempting to close/delete the same 433 // Prevent oustanding callbacks from attempting to close/delete the same
434 // AudioEntry twice. 434 // AudioEntry twice.
435 AudioEntryMap::iterator i = audio_entries_.find(stream_id); 435 AudioEntryMap::iterator i = audio_entries_.find(stream_id);
436 if (i == audio_entries_.end()) 436 if (i == audio_entries_.end())
437 return; 437 return;
438 scoped_ptr<AudioEntry> entry(i->second); 438 scoped_ptr<AudioEntry> entry(i->second);
439 audio_entries_.erase(i); 439 audio_entries_.erase(i);
440 440
441 media::AudioOutputController* const controller = entry->controller(); 441 media::AudioOutputController* const controller = entry->controller();
442 if (mirroring_manager_)
443 mirroring_manager_->RemoveDiverter(controller);
444 controller->Close( 442 controller->Close(
445 base::Bind(&AudioRendererHost::DeleteEntry, this, base::Passed(&entry))); 443 base::Bind(&AudioRendererHost::DeleteEntry, this, base::Passed(&entry)));
446 audio_log_->OnClosed(stream_id); 444 audio_log_->OnClosed(stream_id);
447 } 445 }
448 446
449 void AudioRendererHost::DeleteEntry(scoped_ptr<AudioEntry> entry) { 447 void AudioRendererHost::DeleteEntry(scoped_ptr<AudioEntry> entry) {
450 DCHECK_CURRENTLY_ON(BrowserThread::IO); 448 DCHECK_CURRENTLY_ON(BrowserThread::IO);
449
450 // De-register the controller from the AudioMirroringManager now that the
451 // controller has closed the AudioOutputStream and shut itself down. This
452 // ensures that calling RemoveDiverter() here won't trigger the controller to
453 // re-start the default AudioOutputStream and cause a brief audio blip to come
454 // out the user's speakers. http://crbug.com/474432
455 if (mirroring_manager_)
456 mirroring_manager_->RemoveDiverter(entry->controller());
457
451 AudioStreamMonitor::StopMonitoringStream( 458 AudioStreamMonitor::StopMonitoringStream(
452 render_process_id_, entry->render_frame_id(), entry->stream_id()); 459 render_process_id_, entry->render_frame_id(), entry->stream_id());
453 UpdateNumPlayingStreams(entry.get(), false); 460 UpdateNumPlayingStreams(entry.get(), false);
454 } 461 }
455 462
456 void AudioRendererHost::ReportErrorAndClose(int stream_id) { 463 void AudioRendererHost::ReportErrorAndClose(int stream_id) {
457 DCHECK_CURRENTLY_ON(BrowserThread::IO); 464 DCHECK_CURRENTLY_ON(BrowserThread::IO);
458 465
459 // Make sure this isn't a stray callback executing after the stream has been 466 // Make sure this isn't a stray callback executing after the stream has been
460 // closed, so error notifications aren't sent after clients believe the stream 467 // closed, so error notifications aren't sent after clients believe the stream
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 it != audio_entries_.end(); 520 it != audio_entries_.end();
514 ++it) { 521 ++it) {
515 AudioEntry* entry = it->second; 522 AudioEntry* entry = it->second;
516 if (entry->render_frame_id() == render_frame_id && entry->playing()) 523 if (entry->render_frame_id() == render_frame_id && entry->playing())
517 return true; 524 return true;
518 } 525 }
519 return false; 526 return false;
520 } 527 }
521 528
522 } // namespace content 529 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698