|
22 | 22 |
|
23 | 23 | #include "config.h"
|
24 | 24 |
|
| 25 | +#include <errno.h> |
25 | 26 | #include <stdlib.h>
|
26 | 27 | #include <string.h>
|
27 | 28 | #include <unistd.h>
|
|
36 | 37 |
|
37 | 38 |
|
38 | 39 | static char *_get_value(janus_config *jcfg, const char *section, const char *option);
|
| 40 | +static uint _get_uint(janus_config *jcfg, const char *section, const char *option, bool def); |
39 | 41 | // static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def);
|
40 | 42 |
|
41 | 43 |
|
@@ -65,6 +67,7 @@ us_config_s *us_config_init(const char *config_dir_path) {
|
65 | 67 | US_JLOG_INFO("config", "Missing config value: acap.tc358743");
|
66 | 68 | goto error;
|
67 | 69 | }
|
| 70 | + config->acap_sampling_rate = _get_uint(jcfg, "acap", "sampling_rate", 0); |
68 | 71 | if ((config->aplay_dev_name = _get_value(jcfg, "aplay", "device")) != NULL) {
|
69 | 72 | char *path = _get_value(jcfg, "aplay", "check");
|
70 | 73 | if (path != NULL) {
|
@@ -105,6 +108,20 @@ static char *_get_value(janus_config *jcfg, const char *section, const char *opt
|
105 | 108 | return us_strdup(option_obj->value);
|
106 | 109 | }
|
107 | 110 |
|
| 111 | +static uint _get_uint(janus_config *jcfg, const char *section, const char *option, bool def) { |
| 112 | + char *const tmp = _get_value(jcfg, section, option); |
| 113 | + uint value = def; |
| 114 | + if (tmp != NULL) { |
| 115 | + errno = 0; |
| 116 | + value = (uint) strtoul(tmp, NULL, 10); |
| 117 | + if (errno != 0) { |
| 118 | + value = def; |
| 119 | + } |
| 120 | + free(tmp); |
| 121 | + } |
| 122 | + return value; |
| 123 | +} |
| 124 | + |
108 | 125 | /*static bool _get_bool(janus_config *jcfg, const char *section, const char *option, bool def) {
|
109 | 126 | char *const tmp = _get_value(jcfg, section, option);
|
110 | 127 | bool value = def;
|
|
0 commit comments