Skip to content

Commit aec8431

Browse files
committed
verbose on-screen error messages
1 parent 5b18e29 commit aec8431

3 files changed

Lines changed: 30 additions & 6 deletions

File tree

src/libs/capture.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,12 @@ int us_capture_open(us_capture_s *cap) {
193193
_LOG_DEBUG("Capture device fd=%d opened", run->fd);
194194

195195
if (cap->dv_timings && cap->persistent) {
196+
struct v4l2_control ctl = {.id = V4L2_CID_DV_RX_POWER_PRESENT};
197+
if (!us_xioctl(run->fd, VIDIOC_G_CTRL, &ctl)) {
198+
if (!ctl.value) {
199+
goto error_no_cable;
200+
}
201+
}
196202
_LOG_DEBUG("Probing DV-timings or QuerySTD ...");
197203
if (_capture_open_dv_timings(cap, false) < 0) {
198204
US_ONCE_FOR(run->open_error_once, __LINE__, {
@@ -248,6 +254,10 @@ int us_capture_open(us_capture_s *cap) {
248254
us_capture_close(cap);
249255
return US_ERROR_NO_DEVICE;
250256

257+
error_no_cable:
258+
us_capture_close(cap);
259+
return US_ERROR_NO_CABLE;
260+
251261
error_no_signal:
252262
us_capture_close(cap);
253263
return US_ERROR_NO_DATA;

src/libs/errors.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,5 @@
2424

2525
#define US_ERROR_COMMON -1
2626
#define US_ERROR_NO_DEVICE -2
27-
#define US_ERROR_NO_DATA -3
27+
#define US_ERROR_NO_CABLE -3
28+
#define US_ERROR_NO_DATA -4

src/ustreamer/stream.c

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ static int _stream_init_loop(us_stream_s *stream) {
529529

530530
int once = 0;
531531
while (!atomic_load(&stream->run->stop)) {
532+
char *blank_reason = "< NO SIGNAL >";
533+
532534
# ifdef WITH_GPIO
533535
us_gpio_set_stream_online(false);
534536
# endif
@@ -554,16 +556,27 @@ static int _stream_init_loop(us_stream_s *stream) {
554556
switch (us_capture_open(stream->cap)) {
555557
case 0: break;
556558
case US_ERROR_NO_DEVICE:
559+
blank_reason = "< NO CAPTURE DEVICE >";
560+
goto known_error;
561+
case US_ERROR_NO_CABLE:
562+
blank_reason = "< NO VIDEO SOURCE >";
563+
goto known_error;
557564
case US_ERROR_NO_DATA:
558-
US_ONCE({ US_LOG_INFO("Waiting for the capture device ..."); });
559-
goto offline_and_retry;
565+
goto known_error;
560566
default:
561-
once = 0;
562-
goto offline_and_retry;
567+
goto unknown_error;
563568
}
564569
us_encoder_open(stream->enc, stream->cap);
565570
return 0;
566571

572+
known_error:
573+
US_ONCE({ US_LOG_INFO("Waiting for the capture device ..."); });
574+
goto offline_and_retry;
575+
576+
unknown_error:
577+
once = 0;
578+
goto offline_and_retry;
579+
567580
offline_and_retry:
568581
for (uint count = 0; count < stream->error_delay * 10; ++count) {
569582
if (atomic_load(&run->stop)) {
@@ -577,7 +590,7 @@ static int _stream_init_loop(us_stream_s *stream) {
577590
width = stream->cap->width;
578591
height = stream->cap->height;
579592
}
580-
us_blank_draw(run->blank, "< NO SIGNAL >", width, height);
593+
us_blank_draw(run->blank, blank_reason, width, height);
581594

582595
_stream_update_captured_fpsi(stream, run->blank->raw, false);
583596
_stream_expose_jpeg(stream, run->blank->jpeg);

0 commit comments

Comments
 (0)