Skip to content

Commit

Permalink
Fix potential audiobridge crash when changing room (fixes #3327) (#3356)
Browse files Browse the repository at this point in the history
  • Loading branch information
atoppi committed Apr 8, 2024
1 parent cb6e491 commit e425898
Showing 1 changed file with 6 additions and 0 deletions.
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

0 comments on commit e425898

Please sign in to comment.