summaryrefslogtreecommitdiffstats
path: root/webkit/media
diff options
context:
space:
mode:
authorqinmin@chromium.org <qinmin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-01 06:21:44 +0000
committerqinmin@chromium.org <qinmin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-08-01 06:21:44 +0000
commitdf5883f0be0ec190be73e4ab148a521b4fa93275 (patch)
treee564aa7fe31294cc10c493b188f2ca9f9155cb4a /webkit/media
parent1f2d75f456115f07e89cf1e90f9e5c95be57623b (diff)
downloadchromium_src-df5883f0be0ec190be73e4ab148a521b4fa93275.zip
chromium_src-df5883f0be0ec190be73e4ab148a521b4fa93275.tar.gz
chromium_src-df5883f0be0ec190be73e4ab148a521b4fa93275.tar.bz2
Fix a renderer crash when media elements get deleted
When media elements got deleted, stream_texture_factory_ will get deleted before video_frame_. This causes the callback function to execute with a null pointer. Move the DestroyStreamTexture call in to WMPA dtor. BUG=138827 Review URL: https://chromiumcodereview.appspot.com/10828079 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149379 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/media')
-rw-r--r--webkit/media/android/webmediaplayer_android.cc41
-rw-r--r--webkit/media/android/webmediaplayer_android.h4
2 files changed, 14 insertions, 31 deletions
diff --git a/webkit/media/android/webmediaplayer_android.cc b/webkit/media/android/webmediaplayer_android.cc
index 23d1580..ef457b25 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;
diff --git a/webkit/media/android/webmediaplayer_android.h b/webkit/media/android/webmediaplayer_android.h
index 9c55b85..3bcfd3e 100644
--- a/webkit/media/android/webmediaplayer_android.h
+++ b/webkit/media/android/webmediaplayer_android.h
@@ -152,10 +152,6 @@ class WebMediaPlayerAndroid :
void UpdateNetworkState(WebKit::WebMediaPlayer::NetworkState state);
void UpdateReadyState(WebKit::WebMediaPlayer::ReadyState state);
- // Methods for creation and deletion of stream texture.
- void CreateStreamTexture();
- void DestroyStreamTexture();
-
// whether the current process is incognito mode
static bool incognito_mode_;