refactoring

This commit is contained in:
Maxim Devaev
2026-07-08 11:03:23 +03:00
parent 41a8eb46ca
commit 6dd5b8709f
10 changed files with 26 additions and 22 deletions

View File

@@ -197,7 +197,7 @@ int us_capture_open(us_capture_s *cap) {
}
_LOG_DEBUG("Capture device fd=%d opened", run->fd);
if (cap->dv_timings && cap->media_path[0] != '\0') {
if (cap->dv_timings && us_str_is_ok(cap->media_path)) {
if (_capture_open_media_pads(cap) < 0) {
goto error_no_device;
}
@@ -232,7 +232,7 @@ int us_capture_open(us_capture_s *cap) {
if (cap->dv_timings && _capture_open_dv_timings(cap, true) < 0) {
goto error;
}
if (cap->dv_timings && cap->media_path[0] != '\0') {
if (cap->dv_timings && us_str_is_ok(cap->media_path)) {
US_ARRAY_ITERATE(run->media_pads, 0, pad, {
if (pad->fd >= -1 && _capture_open_media_format(cap, pad) < 0) {
goto error;

View File

@@ -100,7 +100,7 @@ INLINE void us_thread_get_name(char *name) { // Always required for logging
|| (defined(__OpenBSD__) && defined(OpenBSD) && OpenBSD >= 201905) \
|| defined(__DragonFly__)
pthread_get_name_np(pthread_self(), name, US_THREAD_NAME_SIZE); // Also null-terminated
if (name[0] != '\0') {
if (us_str_is_ok(name)) {
retval = 0;
}
# else

View File

@@ -92,6 +92,10 @@ INLINE char *us_strdup(const char *str) {
return new;
}
INLINE bool us_str_is_ok(const char *str) {
return (str != NULL && str[0] != '\0');
}
INLINE const char *us_bool_to_string(bool flag) {
return (flag ? "true" : "false");
}