@@ -4283,16 +4283,16 @@ static json_t *janus_audiobridge_process_synchronous_request(janus_audiobridge_s
4283
4283
goto prepare_response ;
4284
4284
}
4285
4285
4286
+ janus_mutex_lock (& participant -> qmutex );
4286
4287
participant -> muted = muted ;
4287
4288
if (participant -> muted ) {
4288
4289
JANUS_LOG (LOG_VERB , "Setting muted property: %s (room %s, user %s)\n" ,
4289
4290
participant -> muted ? "true" : "false" , participant -> room -> room_id_str , participant -> user_id_str );
4290
4291
/* Clear the queued packets waiting to be handled */
4291
- janus_mutex_lock (& participant -> qmutex );
4292
4292
janus_audiobridge_participant_clear_jitter_buffer (participant );
4293
4293
janus_audiobridge_participant_clear_inbuf (participant );
4294
- janus_mutex_unlock (& participant -> qmutex );
4295
4294
}
4295
+ janus_mutex_unlock (& participant -> qmutex );
4296
4296
4297
4297
if (audiobridge != NULL ) {
4298
4298
json_t * list = json_array ();
@@ -6963,16 +6963,16 @@ static void *janus_audiobridge_handler(void *data) {
6963
6963
}
6964
6964
if (muted || display || (participant -> stereo && spatial ) || denoise ) {
6965
6965
if (muted ) {
6966
+ janus_mutex_lock (& participant -> qmutex );
6966
6967
participant -> muted = json_is_true (muted );
6967
6968
JANUS_LOG (LOG_VERB , "Setting muted property: %s (room %s, user %s)\n" ,
6968
6969
participant -> muted ? "true" : "false" , participant -> room -> room_id_str , participant -> user_id_str );
6969
6970
if (participant -> muted ) {
6970
6971
/* Clear the queued packets waiting to be handled */
6971
- janus_mutex_lock (& participant -> qmutex );
6972
6972
janus_audiobridge_participant_clear_jitter_buffer (participant );
6973
6973
janus_audiobridge_participant_clear_inbuf (participant );
6974
- janus_mutex_unlock (& participant -> qmutex );
6975
6974
}
6975
+ janus_mutex_unlock (& participant -> qmutex );
6976
6976
}
6977
6977
if (display ) {
6978
6978
char * old_display = participant -> display ;
@@ -8708,7 +8708,6 @@ static void *janus_audiobridge_participant_thread(void *data) {
8708
8708
/* Start with packets to decode and queue for the mixer */
8709
8709
now = janus_get_monotonic_time ();
8710
8710
janus_mutex_lock (& participant -> qmutex );
8711
- gboolean locked = TRUE;
8712
8711
/* Start by reading packets to decode from the jitter buffer on a clock */
8713
8712
if (now - before >= 18000 ) {
8714
8713
before += 20000 ;
@@ -8727,9 +8726,8 @@ static void *janus_audiobridge_participant_thread(void *data) {
8727
8726
} else {
8728
8727
/* Decode the audio packet */
8729
8728
bpkt = (janus_audiobridge_buffer_packet * )jbp .data ;
8730
- janus_mutex_unlock (& participant -> qmutex );
8731
- locked = FALSE;
8732
8729
if (!g_atomic_int_compare_and_exchange (& participant -> decoding , 0 , 1 )) {
8730
+ janus_mutex_unlock (& participant -> qmutex );
8733
8731
/* This means we're cleaning up, so don't try to decode */
8734
8732
janus_audiobridge_buffer_packet_destroy (bpkt );
8735
8733
break ;
@@ -8740,9 +8738,10 @@ static void *janus_audiobridge_participant_thread(void *data) {
8740
8738
int plen = 0 ;
8741
8739
const unsigned char * payload = (const unsigned char * )janus_rtp_payload (buffer , len , & plen );
8742
8740
if (!payload ) {
8743
- g_atomic_int_set (& participant -> decoding , 0 );
8744
8741
JANUS_LOG (LOG_ERR , "[%s] Ops! got an error accessing the RTP payload\n" ,
8745
8742
participant -> codec == JANUS_AUDIOCODEC_OPUS ? "Opus" : "G.711" );
8743
+ g_atomic_int_set (& participant -> decoding , 0 );
8744
+ janus_mutex_unlock (& participant -> qmutex );
8746
8745
janus_audiobridge_buffer_packet_destroy (bpkt );
8747
8746
break ;
8748
8747
}
@@ -8776,9 +8775,7 @@ static void *janus_audiobridge_participant_thread(void *data) {
8776
8775
janus_audiobridge_participant_denoise (participant , (char * )pkt -> data , pkt -> length );
8777
8776
#endif
8778
8777
/* Queue the decoded redundant packet for the mixer */
8779
- janus_mutex_lock (& participant -> qmutex );
8780
8778
participant -> inbuf = g_list_append (participant -> inbuf , pkt );
8781
- janus_mutex_unlock (& participant -> qmutex );
8782
8779
/* Now we can process the next packet */
8783
8780
}
8784
8781
/* Decode the packet */
@@ -8797,8 +8794,9 @@ static void *janus_audiobridge_participant_thread(void *data) {
8797
8794
} else if (participant -> codec == JANUS_AUDIOCODEC_PCMA || participant -> codec == JANUS_AUDIOCODEC_PCMU ) {
8798
8795
/* G.711 */
8799
8796
if (plen != 160 ) {
8800
- g_atomic_int_set (& participant -> decoding , 0 );
8801
8797
JANUS_LOG (LOG_WARN , "[G.711] Wrong packet size (expected 160, got %d), skipping audio packet\n" , plen );
8798
+ g_atomic_int_set (& participant -> decoding , 0 );
8799
+ janus_mutex_unlock (& participant -> qmutex );
8802
8800
janus_audiobridge_buffer_packet_destroy (bpkt );
8803
8801
break ;
8804
8802
}
@@ -8832,13 +8830,12 @@ static void *janus_audiobridge_participant_thread(void *data) {
8832
8830
} else {
8833
8831
JANUS_LOG (LOG_ERR , "[G.711] Ops! got an error decoding the audio frame\n" );
8834
8832
}
8833
+ janus_mutex_unlock (& participant -> qmutex );
8835
8834
g_free (pkt -> data );
8836
8835
g_free (pkt );
8837
8836
break ;
8838
8837
}
8839
8838
/* Queue the decoded packet for the mixer */
8840
- janus_mutex_lock (& participant -> qmutex );
8841
- locked = TRUE;
8842
8839
/* Do not let queue-in grow too much */
8843
8840
guint count = g_list_length (participant -> inbuf );
8844
8841
if (count > QUEUE_IN_MAX_PACKETS ) {
@@ -8849,8 +8846,7 @@ static void *janus_audiobridge_participant_thread(void *data) {
8849
8846
}
8850
8847
}
8851
8848
}
8852
- if (locked )
8853
- janus_mutex_unlock (& participant -> qmutex );
8849
+ janus_mutex_unlock (& participant -> qmutex );
8854
8850
/* Now check if there's packets to encode */
8855
8851
mixedpkt = g_async_queue_try_pop (participant -> outbuf );
8856
8852
if (mixedpkt != NULL && g_atomic_int_get (& session -> destroyed ) == 0 && g_atomic_int_get (& session -> started )) {
0 commit comments