Cleaner shutdown for webu stream

This commit is contained in:
MrDave
2021-03-23 21:07:23 -06:00
committed by Mr-Dave
parent e0f2011d69
commit 79f9b1d260
2 changed files with 11 additions and 1 deletions

View File

@@ -62,10 +62,12 @@ static void motion_signal_process(struct ctx_motapp *motapp)
motapp->restart_all = true;
/*FALLTHROUGH*/
case MOTION_SIGNAL_SIGTERM: /* Quit application */
motapp->webcontrol_finish = true;
if (motapp->cam_list != NULL) {
indx = 0;
while (motapp->cam_list[indx]) {
motapp->webcontrol_finish = true;
motapp->cam_list[indx]->event_stop = true;
motapp->cam_list[indx]->finish_cam = true;
motapp->cam_list[indx]->restart_cam = false;

View File

@@ -49,6 +49,10 @@ static void webu_stream_mjpeg_delay(struct webui_ctx *webui)
struct timespec time_curr;
long stream_delay;
if (webui->cam->motapp->webcontrol_finish) {
return;
}
clock_gettime(CLOCK_REALTIME, &time_curr);
/* The stream rate MUST be less than 1000000000 otherwise undefined behaviour
@@ -82,6 +86,10 @@ static void webu_stream_mjpeg_getimg(struct webui_ctx *webui)
int header_len;
struct ctx_stream_data *local_stream;
if (webui->cam->motapp->webcontrol_finish) {
return;
}
memset(webui->resp_image, '\0', webui->resp_size);
/* Assign to a local pointer the stream we want */