Add lock to new Clear() method to prevent crashes

This commit is contained in:
Jonathan Thomas
2022-10-06 21:59:11 -05:00
parent 934ca786ed
commit 32a89cfce9
2 changed files with 10 additions and 7 deletions

View File

@@ -206,6 +206,9 @@ int FFmpegReader::IsHardwareDecodeSupported(int codecid)
void FFmpegReader::Open() {
// Open reader if not already open
if (!is_open) {
// Prevent calls to GetFrame when Closing
const std::lock_guard<std::recursive_mutex> lock(processingMutex);
// Initialize format context
pFormatCtx = NULL;
{
@@ -2035,9 +2038,6 @@ std::shared_ptr<Frame> FFmpegReader::CreateFrame(int64_t requested_frame) {
std::shared_ptr<Frame> output = working_cache.GetFrame(requested_frame);
if (!output) {
// Lock
const std::lock_guard<std::recursive_mutex> lock(processingMutex);
// (re-)Check working cache
output = working_cache.GetFrame(requested_frame);
if(output) return output;