From 720a5a0f6e2a7423fdf0c8fc477d5248cd481249 Mon Sep 17 00:00:00 2001 From: MrDave Date: Sun, 20 Oct 2019 10:11:21 -0600 Subject: [PATCH] Initialize the cam on start --- src/conf.cpp | 5 +++-- src/conf_edit.cpp | 4 +++- src/motion_loop.cpp | 20 ++++++-------------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/src/conf.cpp b/src/conf.cpp index 4faaa2f6..78d9de5c 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -955,6 +955,7 @@ static void conf_parm_camera(struct ctx_motapp *motapp, char *str) { motapp->cam_list = (struct ctx_cam **)myrealloc( motapp->cam_list, sizeof(struct ctx_cam *) * (indx_cams + 2), "config_camera"); motapp->cam_list[indx_cams] = new ctx_cam; + memset(motapp->cam_list[indx_cams],0,sizeof(struct ctx_cam)); motapp->cam_list[indx_cams + 1] = NULL; conf_edit_dflt_cam(motapp->cam_list[indx_cams]); @@ -1274,7 +1275,6 @@ void conf_init_app(struct ctx_motapp *motapp, int argc, char *argv[]){ /* Now we process the motion.conf config file and close it. */ if (fp) { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO,_("Processing config file %s"), filename); conf_edit_set(motapp, -1, (char*)"conf_filename", (char*)filename); @@ -1298,6 +1298,7 @@ void conf_init_cams(struct ctx_motapp *motapp){ motapp->cam_list = (struct ctx_cam**)calloc(sizeof(struct ctx_cam *), 2); motapp->cam_list[0] = new ctx_cam; + memset(motapp->cam_list[0],0,sizeof(struct ctx_cam)); motapp->cam_list[1] = NULL; motapp->cam_list[0]->motapp = motapp; @@ -1337,7 +1338,7 @@ void conf_deinit(struct ctx_motapp *motapp) { indx = 0; while (motapp->cam_list[indx] != NULL){ conf_edit_free(motapp->cam_list[indx]); - free(motapp->cam_list[indx]); + delete motapp->cam_list[indx]; indx++; } diff --git a/src/conf_edit.cpp b/src/conf_edit.cpp index 34193fd6..2beec969 100644 --- a/src/conf_edit.cpp +++ b/src/conf_edit.cpp @@ -2822,7 +2822,9 @@ void conf_edit_set(struct ctx_motapp *motapp, int threadnbr, char *cmd, char *ar if (conf_edit_set_depr(motapp, threadnbr, cmd, arg1) == 0) return; - MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, _("Unknown config option \"%s\""), cmd); + if (threadnbr != -1){ + MOTION_LOG(ALR, TYPE_ALL, NO_ERRNO, _("Unknown config option \"%s\""), cmd); + } } diff --git a/src/motion_loop.cpp b/src/motion_loop.cpp index 0e7553b5..d5a3f562 100644 --- a/src/motion_loop.cpp +++ b/src/motion_loop.cpp @@ -385,15 +385,19 @@ static void mlp_init_buffers(struct ctx_cam *cam){ static void mlp_init_values(struct ctx_cam *cam) { + /* cam has been initialized to 0 upon creation + * so we only need to initialize non zero values*/ + clock_gettime(CLOCK_REALTIME, &cam->frame_last_ts); clock_gettime(CLOCK_REALTIME, &cam->frame_curr_ts); - cam->smartmask_speed = 0; cam->event_nr = 1; - cam->prev_event = 0; + + /* These are soon to be changed to bools so we leave the init for now*/ cam->detecting_motion = FALSE; cam->event_user = FALSE; cam->event_stop = FALSE; + cam->passflag = FALSE; //only purpose to flag first frame /* Make sure to default the high res to zero */ cam->imgs.width_high = 0; @@ -414,18 +418,6 @@ static void mlp_init_values(struct ctx_cam *cam) { cam->minimum_frame_time_downcounter = cam->conf.minimum_frame_time; cam->get_image = 1; - cam->olddiffs = 0; - cam->smartmask_ratio = 0; - cam->smartmask_count = 20; - - cam->previous_diffs = 0; - cam->previous_location_x = 0; - cam->previous_location_y = 0; - - cam->smartmask_lastrate = 0; - - cam->passflag = 0; //only purpose to flag first frame - cam->movie_passthrough = cam->conf.movie_passthrough; if ((cam->camera_type != CAMERA_TYPE_NETCAM) && (cam->movie_passthrough)) {