From 49319990fa3e1b3e3cd39607d07cef57cfc5f6bc Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Wed, 26 Jul 2017 10:38:18 -0400 Subject: [PATCH] Don't keep setting the event_file unnecessarily. Add some code comments --- src/zm_monitor.cpp | 16 +++++++++------- src/zm_monitorstream.cpp | 5 +++-- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp index 1f1c2413e..88683a698 100644 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1319,14 +1319,15 @@ bool Monitor::Analyse() { score += motion_score; } noteSetMap[MOTION_CAUSE] = zoneSet; - - } + } // end if motion_score shared_data->active = signal; - } + } // end if signal change + if ( (!signal_change && signal) && n_linked_monitors > 0 ) { bool first_link = true; Event::StringSet noteSet; for ( int i = 0; i < n_linked_monitors; i++ ) { + // TODO: Shouldn't we try to connect? if ( linked_monitors[i]->isConnected() ) { if ( linked_monitors[i]->hasAlarmed() ) { if ( !event ) { @@ -1352,11 +1353,12 @@ bool Monitor::Analyse() { if ( (!signal_change && signal) && (function == RECORD || function == MOCORD) ) { if ( event ) { //TODO: We shouldn't have to do this every time. Not sure why it clears itself if this isn't here?? - snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile()); + //snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile()); Debug( 3, "Detected new event at (%d.%d)", timestamp->tv_sec,timestamp->tv_usec ); if ( section_length ) { - int section_mod = timestamp->tv_sec%section_length; + // TODO: Wouldn't this be clearer if we just did something like if now - event->start > section_length ? + int section_mod = timestamp->tv_sec % section_length; Debug( 3, "Section length (%d) Last Section Mod(%d), new section mod(%d)", section_length, last_section_mod, section_mod ); if ( section_mod < last_section_mod ) { //if ( state == IDLE || state == TAPE || event_close_mode == CLOSE_TIME ) { @@ -1374,8 +1376,8 @@ bool Monitor::Analyse() { } else { last_section_mod = section_mod; } - } - } // end if section_length + } // end if section_length + } // end if event if ( ! event ) { diff --git a/src/zm_monitorstream.cpp b/src/zm_monitorstream.cpp index 699ad6644..aaa5e8289 100644 --- a/src/zm_monitorstream.cpp +++ b/src/zm_monitorstream.cpp @@ -732,8 +732,9 @@ void MonitorStream::runStream() { if ( rmdir( swap_path ) < 0 ) { Error( "Can't rmdir '%s': %s", swap_path, strerror(errno) ); } - } - } + } // end if checking for swap_path + } // end if buffered_playback + if ( swap_path ) free( swap_path ); closeComms(); }