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

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

Issue 10533049: Adding the logic for releasing decoder resources in WebMediaPlayerManagerAndroid (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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
Index: webkit/media/android/webmediaplayer_android.cc
diff --git a/webkit/media/android/webmediaplayer_android.cc b/webkit/media/android/webmediaplayer_android.cc
index faaadaf79731cebeadb3c1947b04d0003aa3bea2..576c9dd5beb91be258f33124f73dde118e882e24 100644
--- a/webkit/media/android/webmediaplayer_android.cc
+++ b/webkit/media/android/webmediaplayer_android.cc
@@ -63,7 +63,8 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
client_(client),
buffered_(1u),
video_frame_(new WebVideoFrameImpl(VideoFrame::CreateEmptyFrame())),
- proxy_(new WebMediaPlayerProxyAndroid(base::MessageLoopProxy::current(),
+ main_loop_(MessageLoop::current()),
+ proxy_(new WebMediaPlayerProxyAndroid(main_loop_->message_loop_proxy(),
AsWeakPtr())),
prepared_(false),
duration_(0),
@@ -81,7 +82,9 @@ WebMediaPlayerAndroid::WebMediaPlayerAndroid(
stream_id_(0),
needs_establish_peer_(true),
stream_texture_factory_(factory) {
- player_id_ = manager_->RegisterMediaPlayer(this);
+ main_loop_->AddDestructionObserver(this);
+ if (manager_)
+ player_id_ = manager_->RegisterMediaPlayer(this);
if (stream_texture_factory_.get())
stream_texture_proxy_.reset(stream_texture_factory_->CreateProxy());
}
@@ -91,7 +94,11 @@ WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
media_player_->Stop();
}
- manager_->UnregisterMediaPlayer(player_id_);
+ if (manager_)
+ manager_->UnregisterMediaPlayer(player_id_);
+
+ if (main_loop_)
+ main_loop_->RemoveDestructionObserver(this);
}
void WebMediaPlayerAndroid::InitIncognito(bool incognito_mode) {
@@ -486,6 +493,9 @@ void WebMediaPlayerAndroid::InitializeMediaPlayer() {
}
media_player_->SetDataSource(url_.spec(), cookies, incognito_mode_);
+ if (manager_)
+ manager_->RequestMediaResources(player_id_);
+
media_player_->Prepare(
base::Bind(&WebMediaPlayerProxyAndroid::MediaInfoCallback, proxy_),
base::Bind(&WebMediaPlayerProxyAndroid::MediaErrorCallback, proxy_),
@@ -548,6 +558,11 @@ void WebMediaPlayerAndroid::DestroyStreamTexture() {
stream_id_ = 0;
}
+void WebMediaPlayerAndroid::WillDestroyCurrentMessageLoop() {
+ manager_ = NULL;
+ main_loop_ = NULL;
+}
+
WebVideoFrame* WebMediaPlayerAndroid::getCurrentFrame() {
if (!stream_texture_proxy_->IsInitialized() && stream_id_) {
stream_texture_proxy_->Initialize(

Powered by Google App Engine
This is Rietveld 408576698