diff --git a/starboard/shared/ffmpeg/ffmpeg_video_decoder_impl.cc b/starboard/shared/ffmpeg/ffmpeg_video_decoder_impl.cc index 8a7c8980851ef..877869ec9223b 100644 --- a/starboard/shared/ffmpeg/ffmpeg_video_decoder_impl.cc +++ b/starboard/shared/ffmpeg/ffmpeg_video_decoder_impl.cc @@ -207,6 +207,7 @@ void VideoDecoderImpl::Reset() { InitializeCodec(); } + ScopedLock lock(decode_target_and_frames_mutex_); decltype(frames_) frames; frames_ = std::queue>(); } @@ -310,6 +311,7 @@ bool VideoDecoderImpl::DecodePacket(AVPacket* packet) { bool result = true; if (output_mode_ == kSbPlayerOutputModeDecodeToTexture) { + ScopedLock lock(decode_target_and_frames_mutex_); frames_.push(frame); } @@ -396,7 +398,7 @@ void VideoDecoderImpl::TeardownCodec() { ffmpeg_->FreeFrame(&av_frame_); if (output_mode_ == kSbPlayerOutputModeDecodeToTexture) { - ScopedLock lock(decode_target_mutex_); + ScopedLock lock(decode_target_and_frames_mutex_); if (SbDecodeTargetIsValid(decode_target_)) { DecodeTargetRelease(decode_target_graphics_context_provider_, decode_target_); @@ -411,7 +413,7 @@ SbDecodeTarget VideoDecoderImpl::GetCurrentDecodeTarget() { // We must take a lock here since this function can be called from a // separate thread. - ScopedLock lock(decode_target_mutex_); + ScopedLock lock(decode_target_and_frames_mutex_); while (frames_.size() > 1 && frames_.front()->HasOneRef()) { frames_.pop(); } diff --git a/starboard/shared/ffmpeg/ffmpeg_video_decoder_impl.h b/starboard/shared/ffmpeg/ffmpeg_video_decoder_impl.h index aa9faab7985ce..5f680e263247e 100644 --- a/starboard/shared/ffmpeg/ffmpeg_video_decoder_impl.h +++ b/starboard/shared/ffmpeg/ffmpeg_video_decoder_impl.h @@ -143,9 +143,8 @@ class VideoDecoderImpl : public VideoDecoder { // GetCurrentDecodeTarget() needs to be called from an arbitrary thread // to obtain the current decode target (which ultimately ends up being a // copy of |decode_target_|), we need to safe-guard access to |decode_target_| - // and we do so through this mutex. - Mutex decode_target_mutex_; - // Mutex frame_mutex_; + // and |frames_|, we do so through this mutex. + Mutex decode_target_and_frames_mutex_; // int frame_last_rendered_pts_; // scoped_refptr frame_;