Skip to content

Commit 7e8a942

Browse files
committed
Slightly reduce lock usage
Locking the frame_buffer mutex to reference the input frame into the tmp_frame is unnecessary.
1 parent 8e4d3be commit 7e8a942

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/src/frame_buffer.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ swap_frames(AVFrame **lhs, AVFrame **rhs) {
5151
bool
5252
sc_frame_buffer_push(struct sc_frame_buffer *fb, const AVFrame *frame,
5353
bool *previous_frame_skipped) {
54-
sc_mutex_lock(&fb->mutex);
55-
5654
// Use a temporary frame to preserve pending_frame in case of error.
5755
// tmp_frame is an empty frame, no need to call av_frame_unref() beforehand.
5856
int r = av_frame_ref(fb->tmp_frame, frame);
@@ -61,6 +59,8 @@ sc_frame_buffer_push(struct sc_frame_buffer *fb, const AVFrame *frame,
6159
return false;
6260
}
6361

62+
sc_mutex_lock(&fb->mutex);
63+
6464
// Now that av_frame_ref() succeeded, we can replace the previous
6565
// pending_frame
6666
swap_frames(&fb->pending_frame, &fb->tmp_frame);

0 commit comments

Comments
 (0)