mirror of
https://github.com/pikvm/ustreamer.git
synced 2026-03-16 12:33:43 +00:00
refactoring
This commit is contained in:
@@ -199,6 +199,7 @@ int device_open(struct device_t *dev) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void device_close(struct device_t *dev) {
|
void device_close(struct device_t *dev) {
|
||||||
|
dev->run->persistent_timeout_reported = false;
|
||||||
dev->run->n_workers = 0;
|
dev->run->n_workers = 0;
|
||||||
|
|
||||||
if (dev->run->pictures) {
|
if (dev->run->pictures) {
|
||||||
@@ -292,8 +293,21 @@ int device_select(struct device_t *dev, bool *has_read, bool *has_write, bool *h
|
|||||||
*has_write = false;
|
*has_write = false;
|
||||||
*has_error = false;
|
*has_error = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("Device select() --> %d", retval);
|
LOG_DEBUG("Device select() --> %d", retval);
|
||||||
|
|
||||||
|
if (retval > 0) {
|
||||||
|
dev->run->persistent_timeout_reported = false;
|
||||||
|
} else if (retval == 0) {
|
||||||
|
if (dev->persistent) {
|
||||||
|
if (!dev->run->persistent_timeout_reported) {
|
||||||
|
LOG_ERROR("Persistent device timeout (unplugged)");
|
||||||
|
dev->run->persistent_timeout_reported = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Если устройство не персистентное, то таймаут является ошибкой
|
||||||
|
retval = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,7 @@ struct device_runtime_t {
|
|||||||
struct hw_buffer_t *hw_buffers;
|
struct hw_buffer_t *hw_buffers;
|
||||||
struct picture_t **pictures;
|
struct picture_t **pictures;
|
||||||
bool capturing;
|
bool capturing;
|
||||||
|
bool persistent_timeout_reported;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum control_mode_t {
|
enum control_mode_t {
|
||||||
|
|||||||
@@ -139,7 +139,6 @@ void stream_loop(struct stream_t *stream) {
|
|||||||
unsigned captured_fps = 0;
|
unsigned captured_fps = 0;
|
||||||
unsigned captured_fps_accum = 0;
|
unsigned captured_fps_accum = 0;
|
||||||
long long captured_fps_second = 0;
|
long long captured_fps_second = 0;
|
||||||
bool persistent_timeout_reported = false;
|
|
||||||
|
|
||||||
LOG_INFO("Capturing ...");
|
LOG_INFO("Capturing ...");
|
||||||
|
|
||||||
@@ -183,26 +182,11 @@ void stream_loop(struct stream_t *stream) {
|
|||||||
LOG_PERROR("Mainloop select() error");
|
LOG_PERROR("Mainloop select() error");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (selected == 0) { // Persistent timeout
|
||||||
} else if (selected == 0) {
|
|
||||||
# ifdef WITH_GPIO
|
# ifdef WITH_GPIO
|
||||||
gpio_set_stream_online(false);
|
gpio_set_stream_online(false);
|
||||||
# endif
|
# endif
|
||||||
|
|
||||||
if (stream->dev->persistent) {
|
|
||||||
if (!persistent_timeout_reported) {
|
|
||||||
LOG_ERROR("Mainloop select() timeout, polling ...")
|
|
||||||
persistent_timeout_reported = true;
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
} else {
|
|
||||||
LOG_ERROR("Mainloop select() timeout");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
persistent_timeout_reported = false;
|
|
||||||
|
|
||||||
if (has_read) {
|
if (has_read) {
|
||||||
LOG_DEBUG("Frame is ready");
|
LOG_DEBUG("Frame is ready");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user