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

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: addressing feedbacks 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..08e4598044823f83ae301d486847fe81b9f01f9d 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,17 +82,19 @@ 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());
}
WebMediaPlayerAndroid::~WebMediaPlayerAndroid() {
- if (media_player_.get()) {
- media_player_->Stop();
- }
+ if (manager_)
+ manager_->UnregisterMediaPlayer(player_id_);
- manager_->UnregisterMediaPlayer(player_id_);
+ if (main_loop_)
+ main_loop_->RemoveDestructionObserver(this);
}
void WebMediaPlayerAndroid::InitIncognito(bool incognito_mode) {
@@ -473,6 +476,10 @@ void WebMediaPlayerAndroid::ReleaseMediaResources() {
prepared_ = false;
}
+bool WebMediaPlayerAndroid::IsInitialized() const {
+ return (media_player_ != NULL);
+}
+
void WebMediaPlayerAndroid::InitializeMediaPlayer() {
CHECK(!media_player_.get());
prepared_ = false;
@@ -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(
« no previous file with comments | « webkit/media/android/webmediaplayer_android.h ('k') | webkit/media/android/webmediaplayer_manager_android.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698