mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
libobs: Increment new frame ref when first copying
When caching a new frame, keep a reference to the frame while copying to ensure that the frame is not potentially destroyed for whatever reason while that data is being copied.
This commit is contained in:
parent
dde1a73132
commit
ab65df74e0
@ -1687,9 +1687,17 @@ static inline struct obs_source_frame *cache_video(struct obs_source *source,
|
||||
da_push_back(source->async_cache, &new_af);
|
||||
}
|
||||
|
||||
os_atomic_inc_long(&new_frame->refs);
|
||||
|
||||
pthread_mutex_unlock(&source->async_mutex);
|
||||
|
||||
copy_frame_data(new_frame, frame);
|
||||
|
||||
if (os_atomic_dec_long(&new_frame->refs) == 0) {
|
||||
obs_source_frame_destroy(new_frame);
|
||||
new_frame = NULL;
|
||||
}
|
||||
|
||||
return new_frame;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user