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

Unified Diff: media/base/android/media_player_listener.cc

Issue 11348199: Free (and pause) audio resources when getting a phone call (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@input_color
Patch Set: Created 8 years, 1 month 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/base/android/media_player_listener.cc
diff --git a/media/base/android/media_player_listener.cc b/media/base/android/media_player_listener.cc
index de1820190c7b8efe8d649e0ed0fd8f02d5a6f1e7..e304c71a5fabaa065f056c495b9c491ad2f9e3b5 100644
--- a/media/base/android/media_player_listener.cc
+++ b/media/base/android/media_player_listener.cc
@@ -35,9 +35,20 @@ void MediaPlayerListener::CreateMediaPlayerListener(
jobject context, jobject media_player) {
JNIEnv* env = AttachCurrentThread();
CHECK(env);
+ j_media_player_listener_.Reset(
+ Java_MediaPlayerListener_create(
+ env, reinterpret_cast<intptr_t>(this), context, media_player));
+}
+
- Java_MediaPlayerListener_create(
- env, reinterpret_cast<intptr_t>(this), context, media_player);
+void MediaPlayerListener::ReleaseMediaPlayerListenerResources() {
+ JNIEnv* env = AttachCurrentThread();
+ DCHECK(env);
+ if (env && !j_media_player_listener_.is_null()) {
Yaron 2012/11/27 05:58:00 Just change the DCHECK above to CHECK and remove t
Miguel Garcia 2012/11/27 17:24:06 Done.
+ Java_MediaPlayerListener_releaseResources(
+ env, j_media_player_listener_.obj());
+ }
+ j_media_player_listener_.Reset();
}
void MediaPlayerListener::OnMediaError(
@@ -77,6 +88,12 @@ void MediaPlayerListener::OnMediaPrepared(
&MediaPlayerBridge::OnMediaPrepared, media_player_));
}
+void MediaPlayerListener::OnMediaInterrupted(
+ JNIEnv* /* env */, jobject /* obj */) {
+ message_loop_->PostTask(FROM_HERE, base::Bind(
+ &MediaPlayerBridge::OnMediaInterrupted, media_player_));
+}
+
bool MediaPlayerListener::RegisterMediaPlayerListener(JNIEnv* env) {
bool ret = RegisterNativesImpl(env);
DCHECK(g_MediaPlayerListener_clazz);

Powered by Google App Engine
This is Rietveld 408576698