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

Unified Diff: content/browser/media/session/media_session.h

Issue 2291163002: Let MediaSession store duck state instead of volume multiplier (Closed)
Patch Set: addressed Anton's comments Created 4 years, 4 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: content/browser/media/session/media_session.h
diff --git a/content/browser/media/session/media_session.h b/content/browser/media/session/media_session.h
index d791c61eacc54dde1bfc4437a7223ad0be8f1638..9d501fcfd8b7324f41eaf052962620b96e4c43fb 100644
--- a/content/browser/media/session/media_session.h
+++ b/content/browser/media/session/media_session.h
@@ -103,8 +103,13 @@ class MediaSession : public WebContentsObserver,
// |type| represents the origin of the request.
CONTENT_EXPORT void Stop(SuspendType suspend_type);
- // Change the volume multiplier of the session to |volume_multiplier|.
- CONTENT_EXPORT void SetVolumeMultiplier(double volume_multiplier);
+ // Let the media session start ducking such that the volume multiplier is
+ // reduced.
+ CONTENT_EXPORT void StartDucking();
+
+ // Let the media session stop ducking such that the volume multiplier is
+ // recovered.
+ CONTENT_EXPORT void StopDucking();
// Returns if the session can be controlled by Resume() and Suspend calls
// above.
@@ -187,6 +192,13 @@ class MediaSession : public WebContentsObserver,
// It sets audio_focus_state_ and notifies observers about the state change.
void SetAudioFocusState(State audio_focus_state);
+ // Update the volume multiplier when ducking state changes.
+ void UpdateVolumeMultiplier();
+
+ // Get the volume multiplier, which depends on whether the media session is
+ // ducking.
+ double GetVolumeMultiplier() const;
+
// Registers a MediaSession state change callback.
CONTENT_EXPORT std::unique_ptr<base::CallbackList<void(State)>::Subscription>
RegisterMediaSessionStateChangedCallbackForTest(
@@ -201,9 +213,10 @@ class MediaSession : public WebContentsObserver,
MediaSessionUmaHelper uma_helper_;
- // The volume multiplier of this session. All players in this session should
- // multiply their volume with this multiplier to get the effective volume.
- double volume_multiplier_;
+ // The ducking state of this media session. The initial value is |false|, and
+ // is set to |true| after StartDucking(), and will be set to |false| after
+ // StopDucking().
+ bool is_ducking_;
MediaMetadata metadata_;
base::CallbackList<void(State)> media_session_state_listeners_;
« no previous file with comments | « content/browser/media/session/audio_focus_manager_unittest.cc ('k') | content/browser/media/session/media_session.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698