Merge sjc04p1fviap02.teslamotors.com:ZoneMinder into storageareas
commit
a6ccf9a689
|
@ -131,16 +131,17 @@ void Logger::initialise( const std::string &id, const Options &options ) {
|
|||
this->id( id );
|
||||
|
||||
std::string tempLogFile;
|
||||
if ( options.mLogPath.size() ) {
|
||||
mLogPath = options.mLogPath;
|
||||
tempLogFile = mLogPath+"/"+mId+".log";
|
||||
}
|
||||
if ( options.mLogFile.size() )
|
||||
tempLogFile = options.mLogFile;
|
||||
else
|
||||
tempLogFile = mLogPath+"/"+mId+".log";
|
||||
|
||||
if ( (envPtr = getTargettedEnv( "LOG_FILE" )) )
|
||||
tempLogFile = envPtr;
|
||||
else if ( options.mLogFile.size() )
|
||||
tempLogFile = options.mLogFile;
|
||||
else {
|
||||
if ( options.mLogPath.size() ) {
|
||||
mLogPath = options.mLogPath;
|
||||
}
|
||||
tempLogFile = mLogPath+"/"+mId+".log";
|
||||
}
|
||||
|
||||
Level tempLevel = INFO;
|
||||
Level tempTermLevel = mTermLevel;
|
||||
|
@ -560,7 +561,7 @@ void logInit( const char *name, const Logger::Options &options ) {
|
|||
if ( !Logger::smInstance )
|
||||
Logger::smInstance = new Logger();
|
||||
Logger::Options tempOptions = options;
|
||||
tempOptions.mLogPath = staticConfig.PATH_LOGS.c_str();
|
||||
tempOptions.mLogPath = staticConfig.PATH_LOGS;
|
||||
Logger::smInstance->initialise( name, tempOptions );
|
||||
}
|
||||
|
||||
|
|
|
@ -56,8 +56,7 @@ public:
|
|||
typedef std::map<Level,std::string> StringMap;
|
||||
typedef std::map<Level,int> IntMap;
|
||||
|
||||
class Options
|
||||
{
|
||||
class Options {
|
||||
public:
|
||||
int mTermLevel;
|
||||
int mDatabaseLevel;
|
||||
|
@ -166,8 +165,7 @@ public:
|
|||
}
|
||||
Level level( Level=NOOPT );
|
||||
|
||||
bool debugOn()
|
||||
{
|
||||
bool debugOn() {
|
||||
return( mEffectiveLevel >= DEBUG1 );
|
||||
}
|
||||
|
||||
|
@ -190,20 +188,16 @@ public:
|
|||
|
||||
void logInit( const char *name, const Logger::Options &options=Logger::Options() );
|
||||
void logTerm();
|
||||
inline const std::string &logId()
|
||||
{
|
||||
inline const std::string &logId() {
|
||||
return( Logger::fetch()->id() );
|
||||
}
|
||||
inline Logger::Level logLevel()
|
||||
{
|
||||
inline Logger::Level logLevel() {
|
||||
return( Logger::fetch()->level() );
|
||||
}
|
||||
inline void logCapLevel( Logger::Level level )
|
||||
{
|
||||
inline void logCapLevel( Logger::Level level ) {
|
||||
Logger::fetch()->level( level );
|
||||
}
|
||||
inline Logger::Level logDebugging()
|
||||
{
|
||||
inline Logger::Level logDebugging() {
|
||||
return( Logger::fetch()->debugOn() );
|
||||
}
|
||||
|
||||
|
|
|
@ -1198,7 +1198,7 @@ bool Monitor::Analyse() {
|
|||
int pending_frames = shared_data->last_write_index - shared_data->last_read_index;
|
||||
if ( pending_frames < 0 ) pending_frames += image_buffer_count;
|
||||
|
||||
Debug( 4, "RI:%d, WI: %d, PF = %d, RM = %d, Step = %d", shared_data->last_read_index, shared_data->last_write_index, pending_frames, read_margin, step );
|
||||
Debug( 4, "ReadIndex:%d, WriteIndex: %d, PendingFrames = %d, ReadMargin = %d, Step = %d", shared_data->last_read_index, shared_data->last_write_index, pending_frames, read_margin, step );
|
||||
if ( step <= pending_frames ) {
|
||||
index = (shared_data->last_read_index+step)%image_buffer_count;
|
||||
} else {
|
||||
|
|
47
src/zma.cpp
47
src/zma.cpp
|
@ -57,8 +57,7 @@ behind.
|
|||
#include "zm_signal.h"
|
||||
#include "zm_monitor.h"
|
||||
|
||||
void Usage()
|
||||
{
|
||||
void Usage() {
|
||||
fprintf( stderr, "zma -m <monitor_id>\n" );
|
||||
fprintf( stderr, "Options:\n" );
|
||||
fprintf( stderr, " -m, --monitor <monitor_id> : Specify which monitor to use\n" );
|
||||
|
@ -67,8 +66,7 @@ void Usage()
|
|||
exit( 0 );
|
||||
}
|
||||
|
||||
int main( int argc, char *argv[] )
|
||||
{
|
||||
int main( int argc, char *argv[] ) {
|
||||
self = argv[0];
|
||||
|
||||
srand( getpid() * time( 0 ) );
|
||||
|
@ -82,18 +80,15 @@ int main( int argc, char *argv[] )
|
|||
{0, 0, 0, 0}
|
||||
};
|
||||
|
||||
while (1)
|
||||
{
|
||||
while (1) {
|
||||
int option_index = 0;
|
||||
|
||||
int c = getopt_long (argc, argv, "m:h:v", long_options, &option_index);
|
||||
if (c == -1)
|
||||
{
|
||||
if ( c == -1 ) {
|
||||
break;
|
||||
}
|
||||
|
||||
switch (c)
|
||||
{
|
||||
switch (c) {
|
||||
case 'm':
|
||||
id = atoi(optarg);
|
||||
break;
|
||||
|
@ -110,8 +105,7 @@ int main( int argc, char *argv[] )
|
|||
}
|
||||
}
|
||||
|
||||
if (optind < argc)
|
||||
{
|
||||
if (optind < argc) {
|
||||
fprintf( stderr, "Extraneous options, " );
|
||||
while (optind < argc)
|
||||
printf ("%s ", argv[optind++]);
|
||||
|
@ -119,8 +113,7 @@ int main( int argc, char *argv[] )
|
|||
Usage();
|
||||
}
|
||||
|
||||
if ( id < 0 )
|
||||
{
|
||||
if ( id < 0 ) {
|
||||
fprintf( stderr, "Bogus monitor %d\n", id );
|
||||
Usage();
|
||||
exit( 0 );
|
||||
|
@ -137,8 +130,7 @@ int main( int argc, char *argv[] )
|
|||
|
||||
Monitor *monitor = Monitor::Load( id, true, Monitor::ANALYSIS );
|
||||
|
||||
if ( monitor )
|
||||
{
|
||||
if ( monitor ) {
|
||||
Info( "In mode %d/%d, warming up", monitor->GetFunction(), monitor->Enabled() );
|
||||
|
||||
zmSetDefaultHupHandler();
|
||||
|
@ -154,43 +146,34 @@ int main( int argc, char *argv[] )
|
|||
monitor->UpdateAdaptiveSkip();
|
||||
last_analysis_update_time = time( 0 );
|
||||
|
||||
while( !zm_terminate )
|
||||
{
|
||||
while( !zm_terminate ) {
|
||||
// Process the next image
|
||||
sigprocmask( SIG_BLOCK, &block_set, 0 );
|
||||
|
||||
// Some periodic updates are required for variable capturing framerate
|
||||
if ( analysis_update_delay )
|
||||
{
|
||||
if ( analysis_update_delay ) {
|
||||
cur_time = time( 0 );
|
||||
if ( (unsigned int)( cur_time - last_analysis_update_time ) > analysis_update_delay )
|
||||
{
|
||||
if ( (unsigned int)( cur_time - last_analysis_update_time ) > analysis_update_delay ) {
|
||||
analysis_rate = monitor->GetAnalysisRate();
|
||||
monitor->UpdateAdaptiveSkip();
|
||||
last_analysis_update_time = cur_time;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !monitor->Analyse() )
|
||||
{
|
||||
if ( !monitor->Analyse() ) {
|
||||
usleep( monitor->Active()?ZM_SAMPLE_RATE:ZM_SUSPENDED_RATE );
|
||||
}
|
||||
else if ( analysis_rate )
|
||||
{
|
||||
} else if ( analysis_rate ) {
|
||||
usleep( analysis_rate );
|
||||
}
|
||||
|
||||
if ( zm_reload )
|
||||
{
|
||||
if ( zm_reload ) {
|
||||
monitor->Reload();
|
||||
zm_reload = false;
|
||||
}
|
||||
sigprocmask( SIG_UNBLOCK, &block_set, 0 );
|
||||
}
|
||||
delete monitor;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fprintf( stderr, "Can't find monitor with id of %d\n", id );
|
||||
}
|
||||
Image::Deinitialise();
|
||||
|
|
Loading…
Reference in New Issue