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

Unified Diff: media/renderers/audio_renderer_impl.cc

Issue 2098853003: Merge M52: "Restrict OnSuspend() restrictions for audio to non-Android." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 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 | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/renderers/audio_renderer_impl.cc
diff --git a/media/renderers/audio_renderer_impl.cc b/media/renderers/audio_renderer_impl.cc
index 1ddebb9148c0e87cfdd5962508caf789a1a27cfe..3e3620301c4031956e39afeb55bae7bb9b098a69 100644
--- a/media/renderers/audio_renderer_impl.cc
+++ b/media/renderers/audio_renderer_impl.cc
@@ -65,6 +65,11 @@ AudioRendererImpl::AudioRendererImpl(
audio_buffer_stream_->set_config_change_observer(base::Bind(
&AudioRendererImpl::OnConfigChange, weak_factory_.GetWeakPtr()));
+// Suspend and resume work differently on Android and are handled at a higher
+// level than here. OnSuspend() notifications will be delivered a few seconds
+// after an application is backgrounded, even if it should still be playing.
+// See http://crbug.com/623066 for more details.
+#if !defined(OS_ANDROID)
// Tests may not have a power monitor.
base::PowerMonitor* monitor = base::PowerMonitor::Get();
if (!monitor)
@@ -82,6 +87,7 @@ AudioRendererImpl::AudioRendererImpl(
base::Bind(&base::PowerMonitor::AddObserver,
base::Unretained(monitor), this));
}
+#endif
// Do not add anything below this line since the above actions are only safe
// as the last lines of the constructor.
}
@@ -89,8 +95,10 @@ AudioRendererImpl::AudioRendererImpl(
AudioRendererImpl::~AudioRendererImpl() {
DVLOG(1) << __FUNCTION__;
DCHECK(task_runner_->BelongsToCurrentThread());
+#if !defined(OS_ANDROID)
if (base::PowerMonitor::Get())
base::PowerMonitor::Get()->RemoveObserver(this);
+#endif
// If Render() is in progress, this call will wait for Render() to finish.
// After this call, the |sink_| will not call back into |this| anymore.
« 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