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

Unified Diff: content/renderer/media/android/webmediaplayer_android.cc

Issue 532993002: work-in-progress patch to fix context lost black video (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/renderer/media/android/webmediaplayer_android.cc
diff --git a/content/renderer/media/android/webmediaplayer_android.cc b/content/renderer/media/android/webmediaplayer_android.cc
index 6b3a5895c6c99b6fb2a7b5112319e757f3089363..0d7700832b70a2b736916f19d9adfdb779288c38 100644
--- a/content/renderer/media/android/webmediaplayer_android.cc
+++ b/content/renderer/media/android/webmediaplayer_android.cc
@@ -153,6 +153,7 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
DCHECK(cdm_manager_);
DCHECK(main_thread_checker_.CalledOnValidThread());
+ stream_texture_factory_->AddObserver(this);
player_id_ = player_manager_->RegisterMediaPlayer(this);
@@ -194,6 +195,8 @@ WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
if (player_type_ == MEDIA_PLAYER_TYPE_MEDIA_SOURCE && delegate_)
delegate_->PlayerGone(this);
+
+ stream_texture_factory_->AddObserver(this);
boliu 2014/09/03 01:00:07 don't judge...
}
void WebMediaPlayerAndroid::load(LoadType load_type,
@@ -322,6 +325,32 @@ void WebMediaPlayerAndroid::play() {
UpdateNetworkState(WebMediaPlayer::NetworkStateLoading);
}
+void WebMediaPlayerAndroid::OnContextLost() {
+ if (stream_id_) {
+ GLES2Interface* gl = stream_texture_factory_->ContextGL();
+ gl->DeleteTextures(1, &texture_id_);
+ texture_id_ = 0;
+ texture_mailbox_ = gpu::Mailbox();
+ stream_id_ = 0;
+ }
+ stream_texture_proxy_.reset();
+ SetNeedsEstablishPeer(true);
+
+ {
+ base::AutoLock auto_lock(current_frame_lock_);
+ current_frame_ = NULL;
+ }
+ // TODO(boliu): Inform |video_frame_provider_client_|.
+}
+
+void WebMediaPlayerAndroid::OnContextRestored() {
+ TryCreateStreamTextureProxyIfNeeded();
+ if (hasVideo() && needs_establish_peer_ &&
+ !player_manager_->IsInFullscreen(frame_)) {
+ EstablishSurfaceTexturePeer();
+ }
+}
+
void WebMediaPlayerAndroid::pause() {
DCHECK(main_thread_checker_.CalledOnValidThread());
Pause(true);
« no previous file with comments | « content/renderer/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698