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

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

Issue 2613143003: [MediaSession] Keep MediaSession controllable when losing audio focus (Closed)
Patch Set: Created 3 years, 11 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/audio_focus_delegate_android.h" 5 #include "content/browser/media/session/audio_focus_delegate_android.h"
6 6
7 #include "base/android/context_utils.h" 7 #include "base/android/context_utils.h"
8 #include "base/android/jni_android.h" 8 #include "base/android/jni_android.h"
9 #include "content/browser/media/session/media_session_impl.h" 9 #include "content/browser/media/session/media_session_impl.h"
10 #include "jni/AudioFocusDelegate_jni.h" 10 #include "jni/AudioFocusDelegate_jni.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 JNIEnv* env = base::android::AttachCurrentThread(); 50 JNIEnv* env = base::android::AttachCurrentThread();
51 DCHECK(env); 51 DCHECK(env);
52 Java_AudioFocusDelegate_abandonAudioFocus(env, j_media_session_delegate_); 52 Java_AudioFocusDelegate_abandonAudioFocus(env, j_media_session_delegate_);
53 } 53 }
54 54
55 void AudioFocusDelegateAndroid::OnSuspend(JNIEnv*, 55 void AudioFocusDelegateAndroid::OnSuspend(JNIEnv*,
56 const JavaParamRef<jobject>&, 56 const JavaParamRef<jobject>&,
57 jboolean temporary) { 57 jboolean temporary) {
58 // TODO(mlamouri): this check makes it so that if a MediaSession is paused and 58 // TODO(mlamouri): this check makes it so that if a MediaSession is paused and
59 // then loses audio focus, it will still stay in the Suspended state. 59 // then loses audio focus, it will still stay in the Suspended state.
60 // See https://crbug.com/539998 60 // See https://crbug.com/539998
mlamouri (slow - plz ping) 2017/01/09 14:33:37 I guess your change would deprecate this comment,
Zhiqiang Zhang (Slow) 2017/01/09 18:11:59 Done.
61 if (!media_session_->IsActive()) 61 if (!media_session_->IsActive())
62 return; 62 return;
63 63
64 if (temporary) { 64 // Suspending the session instead of stopping regardless of |temporary| to
mlamouri (slow - plz ping) 2017/01/09 14:33:37 Could you remove `temporary` from the method if it
Zhiqiang Zhang (Slow) 2017/01/09 18:11:59 Done.
65 media_session_->Suspend(MediaSession::SuspendType::SYSTEM); 65 // keep the session controllable.
66 } else { 66 media_session_->Suspend(MediaSession::SuspendType::SYSTEM);
67 media_session_->Stop(MediaSession::SuspendType::SYSTEM);
mlamouri (slow - plz ping) 2017/01/09 14:33:37 Do we still use `Stop()` somewhere?
Zhiqiang Zhang (Slow) 2017/01/09 18:11:59 Yes, but Stop() is now only called with SuspendTyp
68 }
69 } 67 }
70 68
71 void AudioFocusDelegateAndroid::OnResume(JNIEnv*, 69 void AudioFocusDelegateAndroid::OnResume(JNIEnv*,
72 const JavaParamRef<jobject>&) { 70 const JavaParamRef<jobject>&) {
73 if (!media_session_->IsReallySuspended()) 71 if (!media_session_->IsReallySuspended())
74 return; 72 return;
75 73
76 media_session_->Resume(MediaSession::SuspendType::SYSTEM); 74 media_session_->Resume(MediaSession::SuspendType::SYSTEM);
77 } 75 }
78 76
(...skipping 14 matching lines...) Expand all
93 // static 91 // static
94 std::unique_ptr<AudioFocusDelegate> AudioFocusDelegate::Create( 92 std::unique_ptr<AudioFocusDelegate> AudioFocusDelegate::Create(
95 MediaSessionImpl* media_session) { 93 MediaSessionImpl* media_session) {
96 AudioFocusDelegateAndroid* delegate = 94 AudioFocusDelegateAndroid* delegate =
97 new AudioFocusDelegateAndroid(media_session); 95 new AudioFocusDelegateAndroid(media_session);
98 delegate->Initialize(); 96 delegate->Initialize();
99 return std::unique_ptr<AudioFocusDelegate>(delegate); 97 return std::unique_ptr<AudioFocusDelegate>(delegate);
100 } 98 }
101 99
102 } // namespace content 100 } // 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