2828#include <janus/config.h>
2929#include <janus/plugins/plugin.h>
3030
31+ #include "uslibs/types.h"
3132#include "uslibs/tools.h"
3233
3334#include "const.h"
3435#include "logging.h"
3536
3637
3738static char * _get_value (janus_config * jcfg , const char * section , const char * option );
39+ static uint _get_uint (janus_config * jcfg , const char * section , const char * option , uint def );
3840// static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def);
3941
4042
@@ -60,8 +62,10 @@ us_config_s *us_config_init(const char *config_dir_path) {
6062 goto error ;
6163 }
6264 if ((config -> acap_dev_name = _get_value (jcfg , "acap" , "device" )) != NULL ) {
63- if ((config -> tc358743_dev_path = _get_value (jcfg , "acap" , "tc358743" )) == NULL ) {
64- US_JLOG_INFO ("config" , "Missing config value: acap.tc358743" );
65+ config -> acap_hz = _get_uint (jcfg , "acap" , "sampling_rate" , 0 );
66+ config -> tc358743_dev_path = _get_value (jcfg , "acap" , "tc358743" );
67+ if (config -> acap_hz == 0 && config -> tc358743_dev_path == NULL ) {
68+ US_JLOG_ERROR ("config" , "Either acap.sampling_rate or acap.tc358743 required" );
6569 goto error ;
6670 }
6771 config -> aplay_dev_name = _get_value (jcfg , "aplay" , "device" );
@@ -95,6 +99,20 @@ static char *_get_value(janus_config *jcfg, const char *section, const char *opt
9599 return us_strdup (option_obj -> value );
96100}
97101
102+ static uint _get_uint (janus_config * jcfg , const char * section , const char * option , uint def ) {
103+ char * const tmp = _get_value (jcfg , section , option );
104+ uint value = def ;
105+ if (tmp != NULL ) {
106+ errno = 0 ;
107+ value = (uint )strtoul (tmp , NULL , 10 );
108+ if (errno != 0 ) {
109+ value = def ;
110+ }
111+ free (tmp );
112+ }
113+ return value ;
114+ }
115+
98116/*static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def) {
99117 char *const tmp = _get_value(jcfg, section, option);
100118 bool value = def;
0 commit comments