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

Unified Diff: webkit/media/android/webmediaplayer_android.cc

Issue 10828079: Fix a renderer crash when media elements get deleted (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixing merge conflicts Created 8 years, 5 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 | « webkit/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: webkit/media/android/webmediaplayer_android.cc
diff --git a/webkit/media/android/webmediaplayer_android.cc b/webkit/media/android/webmediaplayer_android.cc
index 23d1580beca666c045fd793d9324b2e05b4dfcad..ef457b25e5d4f7a9ed113b028d99647e2a57141b 100644
--- a/webkit/media/android/webmediaplayer_android.cc
+++ b/webkit/media/android/webmediaplayer_android.cc
@@ -84,14 +84,19 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
main_loop_->AddDestructionObserver(this);
if (manager_)
player_id_ = manager_->RegisterMediaPlayer(this);
- if (stream_texture_factory_.get())
+ if (stream_texture_factory_.get()) {
stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy());
+ stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_);
+ }
}
WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
if (manager_)
manager_->UnregisterMediaPlayer(player_id_);
+ if (stream_id_)
+ stream_texture_factory_->DestroyStreamTexture(texture_id_);
+
if (main_loop_)
main_loop_->RemoveDestructionObserver(this);
}
@@ -441,8 +446,16 @@ void WebMediaPlayerAndroid::OnMediaInfo(int info_type) {
}
void WebMediaPlayerAndroid::OnVideoSizeChanged(int width, int height) {
+ if (natural_size_.width == width && natural_size_.height == height)
+ return;
+
natural_size_.width = width;
natural_size_.height = height;
+ if (texture_id_) {
+ video_frame_.reset(new WebVideoFrameImpl(VideoFrame::WrapNativeTexture(
+ texture_id_, kGLTextureExternalOES, width, height, base::TimeDelta(),
+ base::Closure())));
+ }
}
void WebMediaPlayerAndroid::UpdateNetworkState(
@@ -505,9 +518,6 @@ void WebMediaPlayerAndroid::PlayInternal() {
CHECK(prepared_);
if (hasVideo() && stream_texture_factory_.get()) {
- if (!stream_id_)
- CreateStreamTexture();
-
if (needs_establish_peer_) {
stream_texture_factory_->EstablishPeer(stream_id_, player_id_);
needs_establish_peer_ = false;
@@ -531,29 +541,6 @@ void WebMediaPlayerAndroid::SeekInternal(float seconds) {
&WebMediaPlayerProxyAndroid::SeekCompleteCallback, proxy_));
}
-void WebMediaPlayerAndroid::CreateStreamTexture() {
- DCHECK(!stream_id_);
- DCHECK(!texture_id_);
- stream_id_ = stream_texture_factory_->CreateStreamTexture(&texture_id_);
- if (texture_id_)
- video_frame_.reset(new WebVideoFrameImpl(VideoFrame::WrapNativeTexture(
- texture_id_,
- kGLTextureExternalOES,
- texture_size_.width,
- texture_size_.height,
- base::TimeDelta(),
- base::Bind(&WebMediaPlayerAndroid::DestroyStreamTexture,
- base::Unretained(this)))));
-}
-
-void WebMediaPlayerAndroid::DestroyStreamTexture() {
- DCHECK(stream_id_);
- DCHECK(texture_id_);
- stream_texture_factory_->DestroyStreamTexture(texture_id_);
- texture_id_ = 0;
- stream_id_ = 0;
-}
-
void WebMediaPlayerAndroid::WillDestroyCurrentMessageLoop() {
manager_ = NULL;
main_loop_ = NULL;
« no previous file with comments | « webkit/media/android/webmediaplayer_android.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698