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

Unified Diff: media/renderers/audio_renderer_impl.h

Issue 2072843002: Freeze media time and audio rendering when the system suspends. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add observer on |task_runner_|. 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
Index: media/renderers/audio_renderer_impl.h
diff --git a/media/renderers/audio_renderer_impl.h b/media/renderers/audio_renderer_impl.h
index 5f6f3b557216cd1b8704aa89c5fdc7323f58df7d..c036727f35adfc078d5a0dbbc220385298e1a9dc 100644
--- a/media/renderers/audio_renderer_impl.h
+++ b/media/renderers/audio_renderer_impl.h
@@ -26,6 +26,7 @@
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
+#include "base/power_monitor/power_observer.h"
#include "base/synchronization/lock.h"
#include "media/base/audio_decoder.h"
#include "media/base/audio_renderer.h"
@@ -53,6 +54,7 @@ class DecryptingDemuxerStream;
class MEDIA_EXPORT AudioRendererImpl
: public AudioRenderer,
public TimeSource,
+ public base::PowerObserver,
NON_EXPORTED_BASE(public AudioRendererSink::RenderCallback) {
public:
// |task_runner| is the thread on which AudioRendererImpl will execute.
@@ -87,6 +89,10 @@ class MEDIA_EXPORT AudioRendererImpl
void StartPlaying() override;
void SetVolume(float volume) override;
+ // base::PowerObserver implementation.
+ void OnSuspend() override;
+ void OnResume() override;
+
private:
friend class AudioRendererImplTest;
@@ -285,6 +291,10 @@ class MEDIA_EXPORT AudioRendererImpl
// reported to JavaScript from going backwards in time.
base::TimeDelta last_media_timestamp_;
+ // Set by OnSuspend() and OnResume() to indicate when the system is about to
+ // suspend/is suspended and when it resumes.
+ bool is_suspending_;
+
// End variables which must be accessed under |lock_|. ----------------------
// NOTE: Weak pointers must be invalidated before all other member variables.
« no previous file with comments | « no previous file | media/renderers/audio_renderer_impl.cc » ('j') | media/renderers/audio_renderer_impl_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698