Skip to content

Commit

Permalink
swmix: Coverity fixes
Browse files Browse the repository at this point in the history
- suppressed CID 424203 - move old audio data free outside the lock
(to indicate that network_audio_buffer is not needed to be guarded by
the lock)

- suppressed CID 424228 - assign video frame data from network buffer
in the locked section - similarly as for the above, it is actually not
guarded by the lock but this is just done to suppress the warning (and
is also shorter to assign on single line)
  • Loading branch information
MartinPulec committed Dec 1, 2023
1 parent 5d3411c commit 35fa1b7
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions src/video_capture/swmix.c
Original file line number Diff line number Diff line change
Expand Up @@ -1309,6 +1309,10 @@ vidcap_swmix_grab(void *state, struct audio_frame **audio)
struct vidcap_swmix_state *s = (struct vidcap_swmix_state *) state;

*audio = NULL;
if (s->network_audio_buffer) {
free(s->network_audio_buffer);
s->network_audio_buffer = NULL;
}

pthread_mutex_lock(&s->lock);
while(s->completed_buffer == NULL) {
Expand All @@ -1318,20 +1322,14 @@ vidcap_swmix_grab(void *state, struct audio_frame **audio)
simple_linked_list_append(s->free_buffer_queue, s->network_buffer);
pthread_cond_signal(&s->free_buffer_queue_not_empty_cv);
}
if(s->network_audio_buffer) {
free(s->network_audio_buffer);
s->network_audio_buffer = NULL;
}
s->network_buffer = s->completed_buffer;
s->frame->tiles[0].data = s->network_buffer = s->completed_buffer;
s->completed_buffer = NULL;
s->network_audio_buffer = s->completed_audio_buffer;
s->completed_audio_buffer = NULL;
s->audio.data_len = s->completed_audio_buffer_len;
pthread_cond_signal(&s->frame_sent_cv);
pthread_mutex_unlock(&s->lock);

s->frame->tiles[0].data = s->network_buffer;

s->frames++;
gettimeofday(&s->t, NULL);
double seconds = tv_diff(s->t, s->t0);
Expand Down

0 comments on commit 35fa1b7

Please sign in to comment.