Merge branch 'zma_to_thread' of github.com:connortechnology/ZoneMinder into zma_to_thread

This commit is contained in:
Isaac Connor 2018-08-17 16:15:30 -04:00
commit cd6dd28280
4 changed files with 31 additions and 20 deletions

View File

@ -516,38 +516,39 @@ void Logger::logPrint( bool hex, const char * const filepath, const int line, co
}
va_end(argPtr);
char *syslogEnd = logPtr;
strncpy( logPtr, "]\n", sizeof(logString)-(logPtr-logString) );
strncpy(logPtr, "]\n", sizeof(logString)-(logPtr-logString));
if ( level <= mTerminalLevel ) {
puts( logString );
fflush( stdout );
puts(logString);
fflush(stdout);
}
if ( level <= mFileLevel ) {
if ( mLogFileFP ) {
fputs( logString, mLogFileFP );
fputs(logString, mLogFileFP);
if ( mFlush )
fflush( mLogFileFP );
fflush(mLogFileFP);
} else {
puts("Logging to file, but file not open\n");
}
}
*syslogEnd = '\0';
if ( level <= mDatabaseLevel ) {
char sql[ZM_SQL_MED_BUFSIZ];
char escapedString[(strlen(syslogStart)*2)+1];
//if ( ! db_mutex.trylock() ) {
db_mutex.lock();
mysql_real_escape_string( &dbconn, escapedString, syslogStart, strlen(syslogStart) );
snprintf( sql, sizeof(sql), "insert into Logs ( TimeKey, Component, ServerId, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, %d, '%s', '%s', '%s', %d )", timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), staticConfig.SERVER_ID, tid, level, classString, escapedString, file, line );
if ( mysql_query(&dbconn, sql) ) {
Level tempDatabaseLevel = mDatabaseLevel;
databaseLevel(NOLOG);
Error("Can't insert log entry: sql(%s) error(%s)", sql, mysql_error(&dbconn));
databaseLevel(tempDatabaseLevel);
}
db_mutex.unlock();
char escapedString[(strlen(syslogStart)*2)+1];
mysql_real_escape_string(&dbconn, escapedString, syslogStart, strlen(syslogStart));
char sql[ZM_SQL_MED_BUFSIZ];
snprintf(sql, sizeof(sql),
"insert into Logs ( TimeKey, Component, ServerId, Pid, Level, Code, Message, File, Line ) values ( %ld.%06ld, '%s', %d, %d, %d, '%s', '%s', '%s', %d )",
timeVal.tv_sec, timeVal.tv_usec, mId.c_str(), staticConfig.SERVER_ID, tid, level, classString, escapedString, file, line );
if ( mysql_query(&dbconn, sql) ) {
Level tempDatabaseLevel = mDatabaseLevel;
databaseLevel(NOLOG);
Error("Can't insert log entry: sql(%s) error(%s)", sql, mysql_error(&dbconn));
databaseLevel(tempDatabaseLevel);
}
db_mutex.unlock();
///} else {
///Level tempDatabaseLevel = mDatabaseLevel;
///databaseLevel(NOLOG);

View File

@ -112,7 +112,7 @@ ZMPacket* zm_packetqueue::popPacket( ) {
ZMPacket *packet = pktQueue.front();
if ( *analysis_it == packet )
analysis_it ++;
++analysis_it;
pktQueue.pop_front();
if ( packet->codec_type == AVMEDIA_TYPE_VIDEO ) {

View File

@ -212,11 +212,11 @@ Image *StreamBase::prepareImage( Image *image ) {
Debug( 3, "Cropping to %d,%d -> %d,%d", last_crop.LoX(), last_crop.LoY(), last_crop.HiX(), last_crop.HiY() );
if ( !image_copied ) {
static Image copy_image;
copy_image.Assign( *image );
copy_image.Assign(*image);
image = &copy_image;
image_copied = true;
}
image->Crop( last_crop );
image->Crop(last_crop);
}
last_scale = scale;
last_zoom = zoom;

View File

@ -48,14 +48,19 @@ VideoStore::VideoStore(
monitor = p_monitor;
video_in_stream = p_video_in_stream;
video_in_stream_index = -1;
audio_in_stream = p_audio_in_stream;
audio_in_stream_index = -1;
filename = filename_in;
format = format_in;
packets_written = 0;
frame_count = 0;
in_frame = NULL;
video_in_frame = NULL;
video_in_ctx = NULL;
video_out_ctx = NULL;
video_out_codec = NULL;
video_out_stream = NULL;
@ -64,6 +69,8 @@ VideoStore::VideoStore(
audio_in_codec = NULL;
audio_in_ctx = NULL;
audio_out_stream = NULL;
audio_out_ctx = NULL;
out_frame = NULL;
#ifdef HAVE_LIBAVRESAMPLE
resample_ctx = NULL;
@ -73,6 +80,9 @@ VideoStore::VideoStore(
video_start_pts = 0;
audio_next_pts = 0;
audio_next_dts = 0;
out_format = NULL;
oc = NULL;
ret = 0;
} // VideoStore::VideoStore
bool VideoStore::open() {