You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Add lock to new Clear() method to prevent crashes
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -772,7 +772,10 @@ void Timeline::sort_effects()
|
||||
void Timeline::Clear()
|
||||
{
|
||||
ZmqLogger::Instance()->AppendDebugMethod("Timeline::Clear");
|
||||
|
||||
|
||||
// Get lock (prevent getting frames while this happens)
|
||||
const std::lock_guard<std::recursive_mutex> guard(getFrameMutex);
|
||||
|
||||
// Close all open clips
|
||||
for (auto clip : clips)
|
||||
{
|
||||
@@ -1100,9 +1103,6 @@ Json::Value Timeline::JsonValue() const {
|
||||
// Load JSON string into this object
|
||||
void Timeline::SetJson(const std::string value) {
|
||||
|
||||
// Get lock (prevent getting frames while this happens)
|
||||
const std::lock_guard<std::recursive_mutex> lock(getFrameMutex);
|
||||
|
||||
// Parse JSON string into JSON objects
|
||||
try
|
||||
{
|
||||
@@ -1120,6 +1120,9 @@ void Timeline::SetJson(const std::string value) {
|
||||
// Load Json::Value into this object
|
||||
void Timeline::SetJsonValue(const Json::Value root) {
|
||||
|
||||
// Get lock (prevent getting frames while this happens)
|
||||
const std::lock_guard<std::recursive_mutex> lock(getFrameMutex);
|
||||
|
||||
// Close timeline before we do anything (this closes all clips)
|
||||
bool was_open = is_open;
|
||||
Close();
|
||||
|
||||
Reference in New Issue
Block a user