@@ -69,7 +69,7 @@ static us_janus_client_s *_g_clients = NULL;
6969static janus_callbacks * _g_gw = NULL ;
7070static us_ring_s * _g_video_ring = NULL ;
7171static us_rtpv_s * _g_rtpv = NULL ;
72- static us_rtpa_s * _g_rtpa = NULL ; // Also indicates "audio capture is available"
72+ static us_rtpa_s * _g_rtpa = NULL ;
7373
7474static pthread_t _g_video_rtp_tid ;
7575static atomic_bool _g_video_rtp_tid_created = false;
@@ -250,6 +250,10 @@ static void *_acap_thread(void *arg) {
250250 uint hz = 0 ;
251251 us_acap_s * acap = NULL ;
252252
253+ if (!us_au_probe (_g_config -> acap_dev_name )) {
254+ US_ONCE ({ US_JLOG_ERROR ("acap" , "No PCM capture device" ); });
255+ goto close_acap ;
256+ }
253257 if (_check_tc358743_acap (& hz ) < 0 ) {
254258 goto close_acap ;
255259 }
@@ -339,6 +343,11 @@ static void *_aplay_thread(void *arg) {
339343 }
340344
341345 if (dev == NULL ) {
346+ if (!us_au_probe (_g_config -> aplay_dev_name )) {
347+ US_ONCE ({ US_JLOG_ERROR ("aplay" , "No PCM playback device" ); });
348+ goto close_aplay ;
349+ }
350+
342351 int err = snd_pcm_open (& dev , _g_config -> aplay_dev_name , SND_PCM_STREAM_PLAYBACK , 0 );
343352 if (err < 0 ) {
344353 US_ONCE ({ US_JLOG_PERROR_ALSA (err , "aplay" , "Can't open PCM playback" ); });
@@ -424,7 +433,7 @@ static int _plugin_init(janus_callbacks *gw, const char *config_dir_path) {
424433
425434 US_RING_INIT_WITH_ITEMS (_g_video_ring , 64 , us_frame_init );
426435 _g_rtpv = us_rtpv_init (_relay_rtp_clients );
427- if (_g_config -> acap_dev_name != NULL && us_acap_probe ( _g_config -> acap_dev_name ) ) {
436+ if (_g_config -> acap_dev_name != NULL ) {
428437 _g_rtpa = us_rtpa_init (_relay_rtp_clients );
429438 US_THREAD_CREATE (_g_acap_tid , _acap_thread , NULL );
430439 if (_g_config -> aplay_dev_name != NULL ) {
@@ -602,13 +611,13 @@ static struct janus_plugin_result *_plugin_handle_message(
602611 {
603612 json_t * const obj = json_object_get (params , "audio" );
604613 if (obj != NULL && json_is_boolean (obj )) {
605- with_acap = (_g_rtpa != NULL && json_boolean_value (obj ));
614+ with_acap = (us_au_probe ( _g_config -> acap_dev_name ) && json_boolean_value (obj ));
606615 }
607616 }
608617 {
609618 json_t * const obj = json_object_get (params , "mic" );
610619 if (obj != NULL && json_is_boolean (obj )) {
611- with_aplay = (_g_config -> aplay_dev_name != NULL && with_acap && json_boolean_value (obj ));
620+ with_aplay = (us_au_probe ( _g_config -> aplay_dev_name ) && json_boolean_value (obj ));
612621 }
613622 }
614623 {
@@ -673,10 +682,11 @@ static struct janus_plugin_result *_plugin_handle_message(
673682
674683 } else if (!strcmp (request_str , "features" )) {
675684 const char * const ice_url = getenv ("JANUS_USTREAMER_WEB_ICE_URL" );
685+ const bool acap_avail = us_au_probe (_g_config -> acap_dev_name );
676686 json_t * const features = json_pack (
677687 "{s:b, s:b, s:{s:s?}}" ,
678- "audio" , ( _g_rtpa != NULL ) ,
679- "mic" , (_g_rtpa != NULL && _g_config -> aplay_dev_name != NULL ),
688+ "audio" , acap_avail ,
689+ "mic" , (acap_avail && us_au_probe ( _g_config -> aplay_dev_name ) ),
680690 "ice" , "url" , (ice_url != NULL ? ice_url : default_ice_url )
681691 );
682692 PUSH_STATUS ("features" , features , NULL );
0 commit comments