mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-07-23 20:21:58 +00:00
refactoring
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user