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

Side by Side Diff: content/browser/media/session/media_session.cc

Issue 2429823002: Hotfix for MediaSession::OnPlayerPaused (Closed)
Patch Set: rebased Created 4 years, 2 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/media/session/media_session.h" 5 #include "content/browser/media/session/media_session.h"
6 6
7 #include "content/browser/media/session/audio_focus_delegate.h" 7 #include "content/browser/media/session/audio_focus_delegate.h"
8 #include "content/browser/media/session/media_session_player_observer.h" 8 #include "content/browser/media/session/media_session_player_observer.h"
9 #include "content/browser/web_contents/web_contents_impl.h" 9 #include "content/browser/web_contents/web_contents_impl.h"
10 #include "content/public/browser/web_contents.h" 10 #include "content/public/browser/web_contents.h"
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 MediaSessionSuspendedSource::SystemTransientDuck); 161 MediaSessionSuspendedSource::SystemTransientDuck);
162 } 162 }
163 163
164 void MediaSession::OnPlayerPaused(MediaSessionPlayerObserver* observer, 164 void MediaSession::OnPlayerPaused(MediaSessionPlayerObserver* observer,
165 int player_id) { 165 int player_id) {
166 // If a playback is completed, BrowserMediaPlayerManager will call 166 // If a playback is completed, BrowserMediaPlayerManager will call
167 // OnPlayerPaused() after RemovePlayer(). This is a workaround. 167 // OnPlayerPaused() after RemovePlayer(). This is a workaround.
168 // Also, this method may be called when a player that is not added 168 // Also, this method may be called when a player that is not added
169 // to this session (e.g. a silent video) is paused. MediaSession 169 // to this session (e.g. a silent video) is paused. MediaSession
170 // should ignore the paused player for this case. 170 // should ignore the paused player for this case.
171 if (!players_.count(PlayerIdentifier(observer, player_id))) 171 if (!players_.count(PlayerIdentifier(observer, player_id)) &&
172 !pepper_players_.count(PlayerIdentifier(observer, player_id))) {
172 return; 173 return;
174 }
173 175
174 // If there is more than one observer, remove the paused one from the session. 176 // If the player to be removed is a pepper player, or there is more than one
175 if (players_.size() != 1) { 177 // observer, remove the paused one from the session.
178 if (pepper_players_.count(PlayerIdentifier(observer, player_id)) ||
179 players_.size() != 1) {
176 RemovePlayer(observer, player_id); 180 RemovePlayer(observer, player_id);
177 return; 181 return;
178 } 182 }
179 183
180 // Otherwise, suspend the session. 184 // Otherwise, suspend the session.
181 DCHECK(!IsSuspended()); 185 DCHECK(!IsSuspended());
182 OnSuspendInternal(SuspendType::CONTENT, State::SUSPENDED); 186 OnSuspendInternal(SuspendType::CONTENT, State::SUSPENDED);
183 } 187 }
184 188
185 void MediaSession::Resume(SuspendType suspend_type) { 189 void MediaSession::Resume(SuspendType suspend_type) {
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 DCHECK(success); 436 DCHECK(success);
433 437
434 pepper_players_.insert(PlayerIdentifier(observer, player_id)); 438 pepper_players_.insert(PlayerIdentifier(observer, player_id));
435 439
436 observer->OnSetVolumeMultiplier(player_id, GetVolumeMultiplier()); 440 observer->OnSetVolumeMultiplier(player_id, GetVolumeMultiplier());
437 441
438 return true; 442 return true;
439 } 443 }
440 444
441 } // namespace content 445 } // 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