Guard against calls to OnEncodedFrame after Release.
Bug: b/126961661 Change-Id: I62ad5cb2fac5d0ae2b781390ec3b847d8a2b739c Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/125725 Reviewed-by: Magnus Jedvert <magjed@webrtc.org> Commit-Queue: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#26998}
This commit is contained in:
committed by
Commit Bot
parent
6117068af4
commit
67f862ea96
@ -45,7 +45,10 @@ int32_t VideoEncoderWrapper::InitEncode(const VideoCodec* codec_settings,
|
||||
number_of_cores_ = number_of_cores;
|
||||
codec_settings_ = *codec_settings;
|
||||
num_resets_ = 0;
|
||||
encoder_queue_ = rtc::TaskQueue::Current();
|
||||
{
|
||||
rtc::CritScope lock(&encoder_queue_crit_);
|
||||
encoder_queue_ = rtc::TaskQueue::Current();
|
||||
}
|
||||
|
||||
return InitEncodeInternal(jni);
|
||||
}
|
||||
@ -106,7 +109,10 @@ int32_t VideoEncoderWrapper::Release() {
|
||||
RTC_LOG(LS_INFO) << "release: " << status;
|
||||
frame_extra_infos_.clear();
|
||||
initialized_ = false;
|
||||
encoder_queue_ = nullptr;
|
||||
{
|
||||
rtc::CritScope lock(&encoder_queue_crit_);
|
||||
encoder_queue_ = nullptr;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -284,10 +290,15 @@ void VideoEncoderWrapper::OnEncodedFrame(JNIEnv* jni,
|
||||
}
|
||||
};
|
||||
|
||||
encoder_queue_->PostTask(
|
||||
Lambda{this, std::move(buffer_copy), qp, encoded_width, encoded_height,
|
||||
capture_time_ns, frame_type, rotation, complete_frame,
|
||||
&frame_extra_infos_, callback_});
|
||||
{
|
||||
rtc::CritScope lock(&encoder_queue_crit_);
|
||||
if (encoder_queue_ != nullptr) {
|
||||
encoder_queue_->PostTask(
|
||||
Lambda{this, std::move(buffer_copy), qp, encoded_width,
|
||||
encoded_height, capture_time_ns, frame_type, rotation,
|
||||
complete_frame, &frame_extra_infos_, callback_});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int32_t VideoEncoderWrapper::HandleReturnCode(JNIEnv* jni,
|
||||
|
||||
@ -91,7 +91,8 @@ class VideoEncoderWrapper : public VideoEncoder {
|
||||
const ScopedJavaGlobalRef<jobject> encoder_;
|
||||
const ScopedJavaGlobalRef<jclass> int_array_class_;
|
||||
|
||||
rtc::TaskQueue* encoder_queue_;
|
||||
rtc::CriticalSection encoder_queue_crit_;
|
||||
rtc::TaskQueue* encoder_queue_ RTC_GUARDED_BY(encoder_queue_crit_);
|
||||
std::deque<FrameExtraInfo> frame_extra_infos_;
|
||||
EncodedImageCallback* callback_;
|
||||
bool initialized_;
|
||||
|
||||
Reference in New Issue
Block a user