From ba2820ef37e13276bbbd52ce982ce1a41539e70a Mon Sep 17 00:00:00 2001 From: stan Date: Tue, 9 Mar 2004 17:04:15 +0000 Subject: [PATCH] Fixed fixed section lengths to start on boundary. git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@936 e3e1d417-86f3-4887-817a-d78f3d33393f --- src/zm_monitor.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index a6414627d..f8da504ef 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -648,6 +648,7 @@ bool Monitor::Analyse() static struct timeval **timestamps; static Image **images; + static int last_section_mod = 0; unsigned int score = 0; if ( Ready() ) @@ -663,12 +664,18 @@ bool Monitor::Analyse() { if ( state == IDLE || state == TAPE ) { - if ( (timestamp->tv_sec - event->StartTime().tv_sec) >= section_length ) + int section_mod = timestamp->tv_sec%section_length; + if ( section_mod < last_section_mod ) { Info(( "Ended event" )); gettimeofday( &(event->EndTime()), &dummy_tz ); delete event; event = 0; + last_section_mod = 0; + } + else + { + last_section_mod = section_mod; } } } @@ -795,12 +802,18 @@ bool Monitor::Analyse() { if ( state == IDLE || state == TAPE ) { - if ( (timestamp->tv_sec - event->StartTime().tv_sec) >= section_length ) + int section_mod = timestamp->tv_sec%section_length; + if ( section_mod < last_section_mod ) { Info(( "Ended event" )); gettimeofday( &(event->EndTime()), &dummy_tz ); delete event; event = 0; + last_section_mod = 0; + } + else + { + last_section_mod = section_mod; } } }