Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix potential audiobridge crash when changing room (fixes #3327) #3356

Merged
merged 1 commit into from Apr 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/plugins/janus_audiobridge.c
Expand Up @@ -7276,12 +7276,18 @@ static void *janus_audiobridge_handler(void *data) {
}
participant->reset = FALSE;
/* Destroy the previous encoder/decoder and update the references */
while(!g_atomic_int_compare_and_exchange(&participant->encoding, 0, 1))
g_usleep(5000);
if(participant->encoder)
opus_encoder_destroy(participant->encoder);
participant->encoder = new_encoder;
g_atomic_int_set(&participant->encoding, 0);
while(!g_atomic_int_compare_and_exchange(&participant->decoding, 0, 1))
g_usleep(5000);
if(participant->decoder)
opus_decoder_destroy(participant->decoder);
participant->decoder = new_decoder;
g_atomic_int_set(&participant->decoding, 0);
}
if(quality)
opus_encoder_ctl(participant->encoder, OPUS_SET_COMPLEXITY(participant->opus_complexity));
Expand Down