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

Unified Diff: media/gpu/android_video_encode_accelerator.cc

Issue 2601003002: Android: Fix random crash in HW encode accelerator (Closed)
Patch Set: address comments Created 4 years 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 | « media/gpu/android_video_encode_accelerator.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/gpu/android_video_encode_accelerator.cc
diff --git a/media/gpu/android_video_encode_accelerator.cc b/media/gpu/android_video_encode_accelerator.cc
index b16f933222866fe2bb9bcae46c1883d6a9eeecb7..2e8559dd27f21814c2cf186172240a4d39d626da 100644
--- a/media/gpu/android_video_encode_accelerator.cc
+++ b/media/gpu/android_video_encode_accelerator.cc
@@ -47,9 +47,9 @@ enum PixelFormat {
do { \
if (!(result)) { \
DLOG(ERROR) << log; \
- if (client_ptr_factory_->GetWeakPtr()) { \
+ if (!error_occurred_) { \
client_ptr_factory_->GetWeakPtr()->NotifyError(error); \
- client_ptr_factory_.reset(); \
+ error_occurred_ = true; \
} \
return; \
} \
@@ -94,7 +94,7 @@ static bool GetSupportedColorFormatForMime(const std::string& mime,
}
AndroidVideoEncodeAccelerator::AndroidVideoEncodeAccelerator()
- : num_buffers_at_codec_(0), last_set_bitrate_(0) {}
+ : num_buffers_at_codec_(0), last_set_bitrate_(0), error_occurred_(false) {}
AndroidVideoEncodeAccelerator::~AndroidVideoEncodeAccelerator() {
DCHECK(thread_checker_.CalledOnValidThread());
@@ -150,6 +150,7 @@ bool AndroidVideoEncodeAccelerator::Initialize(
<< ", initial_bitrate: " << initial_bitrate;
DCHECK(!media_codec_);
DCHECK(thread_checker_.CalledOnValidThread());
+ DCHECK(client);
client_ptr_factory_.reset(new base::WeakPtrFactory<Client>(client));
@@ -301,7 +302,7 @@ void AndroidVideoEncodeAccelerator::DoIOTask() {
}
void AndroidVideoEncodeAccelerator::QueueInput() {
- if (!client_ptr_factory_->GetWeakPtr() || pending_frames_.empty())
+ if (error_occurred_ || pending_frames_.empty())
return;
int input_buf_index = 0;
@@ -368,8 +369,8 @@ void AndroidVideoEncodeAccelerator::QueueInput() {
}
void AndroidVideoEncodeAccelerator::DequeueOutput() {
- if (!client_ptr_factory_->GetWeakPtr() ||
- available_bitstream_buffers_.empty() || num_buffers_at_codec_ == 0) {
+ if (error_occurred_ || available_bitstream_buffers_.empty() ||
+ num_buffers_at_codec_ == 0) {
return;
}
« no previous file with comments | « media/gpu/android_video_encode_accelerator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698