mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-07-18 01:31:54 +00:00
refactoring
This commit is contained in:
@@ -38,7 +38,7 @@ bool us_au_probe(const char *name) {
|
||||
// the existence of it in /proc/asound/.
|
||||
// It's enough for our case.
|
||||
|
||||
if (name == NULL) {
|
||||
if (!us_str_is_ok(name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ us_config_s *us_config_init(const char *config_dir_path) {
|
||||
if ((config->acap_dev_name = _get_value(jcfg, "acap", "device")) != NULL) {
|
||||
config->acap_hz = _get_uint(jcfg, "acap", "sampling_rate", 0);
|
||||
config->tc358743_dev_path = _get_value(jcfg, "acap", "tc358743");
|
||||
if (config->acap_hz == 0 && config->tc358743_dev_path == NULL) {
|
||||
if (config->acap_hz == 0 && !us_str_is_ok(config->tc358743_dev_path)) {
|
||||
US_LOG_ERROR("Either acap.sampling_rate or acap.tc358743 required");
|
||||
goto error;
|
||||
}
|
||||
@@ -95,7 +95,7 @@ void us_config_destroy(us_config_s *config) {
|
||||
static char *_get_value(janus_config *jcfg, const char *section, const char *option) {
|
||||
janus_config_category *section_obj = janus_config_get_create(jcfg, NULL, janus_config_type_category, section);
|
||||
janus_config_item *option_obj = janus_config_get(jcfg, section_obj, janus_config_type_item, option);
|
||||
if (option_obj == NULL || option_obj->value == NULL || option_obj->value[0] == '\0') {
|
||||
if (option_obj == NULL || !us_str_is_ok(option_obj->value)) {
|
||||
return NULL;
|
||||
}
|
||||
return us_strdup(option_obj->value);
|
||||
|
||||
@@ -192,10 +192,7 @@ static int _get_acap_hz(uint *hz) {
|
||||
*hz = _g_config->acap_hz;
|
||||
return 0;
|
||||
}
|
||||
if (_g_config->tc358743_dev_path == NULL) {
|
||||
US_LOG_ERROR("No configured sampling rate");
|
||||
return -1;
|
||||
}
|
||||
US_A(us_str_is_ok(_g_config->tc358743_dev_path));
|
||||
const int fd = open(_g_config->tc358743_dev_path, O_RDWR);
|
||||
if (fd < 0) {
|
||||
US_LOG_PERROR("Can't open TC358743 V4L2 device");
|
||||
@@ -408,7 +405,10 @@ static int _plugin_init(janus_callbacks *gw, const char *config_dir_path) {
|
||||
US_LOGGING_INIT;
|
||||
|
||||
US_LOG_INFO("Initializing PiKVM uStreamer plugin %s ...", US_VERSION);
|
||||
if (gw == NULL || config_dir_path == NULL || ((_g_config = us_config_init(config_dir_path)) == NULL)) {
|
||||
if (gw == NULL || !us_str_is_ok(config_dir_path)) {
|
||||
return -1;
|
||||
}
|
||||
if ((_g_config = us_config_init(config_dir_path)) == NULL) {
|
||||
return -1;
|
||||
}
|
||||
_g_gw = gw;
|
||||
|
||||
Reference in New Issue
Block a user