Index: motion.c =================================================================== --- motion.c (revisión: 233) +++ motion.c (copia de trabajo) @@ -505,9 +505,8 @@ } } - if (cnt->track.type != 0) { + if (cnt->track.type != 0) cnt->moved = track_move(cnt, dev, &cnt->current_image->location, imgs, 0); - } } /** @@ -589,6 +588,7 @@ cnt->currenttime_tm = mymalloc(sizeof(struct tm)); cnt->eventtime_tm = mymalloc(sizeof(struct tm)); cnt->smartmask_speed = 0; + cnt->watchdog = 10; /* We initialize cnt->event_nr to 1 and cnt->prev_event to 0 (not really needed) so * that certain code below does not run until motion has been detected the first time */ @@ -880,9 +880,10 @@ /* MAIN MOTION LOOP BEGINS HERE */ /* Should go on forever... unless you bought vaporware :) */ - while (!cnt->finish || cnt->makemovie) { + while ((!cnt->finish || cnt->makemovie) && (!restart)) { /***** MOTION LOOP - PREPARE FOR NEW FRAME SECTION *****/ + cnt->watchdog = 10; /* Get current time and preserver last time for frame interval calc. */ timebefore = timenow; @@ -2103,8 +2104,16 @@ /* Crude way of waiting for all threads to finish - check the thread * counter (because we cannot do join on the detached threads). */ - while(threads_running > 0) { + while (threads_running > 0) { SLEEP(1,0); + for (i = 1; cnt_list[i]; i++) { + if (cnt_list[i]->watchdog > 0) { + cnt_list[i]->watchdog--; + } else { + restart = 1; + motion_log(LOG_DEBUG, 0, "Thread %d - Watchdog\n", cnt_list[i]->threadnr); + } + } } if (cnt_list[0]->conf.setup_mode) Index: motion.h =================================================================== --- motion.h (revisión: 233) +++ motion.h (copia de trabajo) @@ -295,6 +295,7 @@ char conf_filename[PATH_MAX]; int threadnr; int daemon; + int watchdog; struct config conf; struct images imgs; Index: video2.c =================================================================== --- video2.c (revisión: 233) +++ video2.c (copia de trabajo) @@ -770,6 +770,19 @@ sigaddset(&set, SIGHUP); pthread_sigmask(SIG_BLOCK, &set, &old); + /* Testing signal strength to detect signal lost */ + if (viddev->input < 8){ + struct v4l2_tuner tuner; + + memset(&tuner, 0, sizeof(struct v4l2_tuner)); + //tuner.input = 0; + if (xioctl(s->fd, VIDIOC_G_TUNER, &tuner) == -1) + return (0); + + motion_log(LOG_DEBUG, 0, "Signal strength %d\n", tuner.signal >> 14); + } + + if (s->pframe >= 0) { if (xioctl(s->fd, VIDIOC_QBUF, &s->buf) == -1) { motion_log(LOG_ERR, 0, "%s: VIDIOC_QBUF: %s", __FUNCTION__, strerror(errno)); @@ -794,12 +807,10 @@ s->buf.index = s->pframe; motion_log(LOG_ERR, 0, "%s: VIDIOC_DQBUF: EIO (s->pframe %d)", __FUNCTION__,s->pframe); - return (1); } motion_log(LOG_ERR, 0, "%s: VIDIOC_DQBUF: %s", __FUNCTION__, strerror(errno)); - return (-1); }