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

Unified Diff: content/browser/renderer_host/media/audio_renderer_host.cc

Issue 1214883004: Fixed the audio backgrounding bug (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Made changes as suggested by dalecurtis@chromium.org 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/media/audio_renderer_host.cc
diff --git a/content/browser/renderer_host/media/audio_renderer_host.cc b/content/browser/renderer_host/media/audio_renderer_host.cc
index dddeee21626a31f30aff5b4f749c396fcd5024b8..12fee35c93cf144117701e414d1c6afb999ed7b2 100644
--- a/content/browser/renderer_host/media/audio_renderer_host.cc
+++ b/content/browser/renderer_host/media/audio_renderer_host.cc
@@ -651,11 +651,33 @@ void AudioRendererHost::UpdateNumPlayingStreams(AudioEntry* entry,
!RenderFrameHasActiveAudio(entry->render_frame_id());
entry->set_playing(true);
base::AtomicRefCountInc(&num_playing_streams_);
+
+ // If it's the first audio stream to start for this renderer.
+ if (base::AtomicRefCountIsOne(&num_playing_streams_)) {
+ RenderProcessHost* render_process_host =
+ RenderProcessHost::FromID(render_process_id_);
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&RenderProcessHost::AudioStarted,
+ base::Unretained(render_process_host)));
+ }
} else {
entry->set_playing(false);
should_alert_resource_scheduler =
!RenderFrameHasActiveAudio(entry->render_frame_id());
base::AtomicRefCountDec(&num_playing_streams_);
+
+ // If it was the last audio stream playing for this renderer.
+ if (base::AtomicRefCountIsZero(&num_playing_streams_)) {
DaleCurtis 2015/06/29 22:21:40 You can use the result of AtomicRefCountDec instea
sebsg 2015/06/29 22:35:00 Done.
+ RenderProcessHost* render_process_host =
+ RenderProcessHost::FromID(render_process_id_);
+
+ BrowserThread::PostTask(
+ BrowserThread::UI, FROM_HERE,
+ base::Bind(&RenderProcessHost::AudioStopped,
+ base::Unretained(render_process_host)));
+ }
}
if (should_alert_resource_scheduler && ResourceDispatcherHostImpl::Get()) {
« no previous file with comments | « no previous file | content/browser/renderer_host/render_process_host_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698