Slight reorganisation of shm member data, also blats shm on destruction.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@1848 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
d4e16016ba
commit
9dcdcb8508
|
@ -111,9 +111,14 @@ Monitor::~Monitor()
|
||||||
shared_data->state = state = IDLE;
|
shared_data->state = state = IDLE;
|
||||||
shared_data->last_read_index = image_buffer_count;
|
shared_data->last_read_index = image_buffer_count;
|
||||||
}
|
}
|
||||||
|
else if ( purpose == CAPTURE )
|
||||||
|
{
|
||||||
|
shared_data->valid = false;
|
||||||
|
memset( shm_ptr, 0, shm_size );
|
||||||
|
}
|
||||||
|
|
||||||
struct shmid_ds shm_data;
|
struct shmid_ds shm_data;
|
||||||
if ( shmctl( shmid, IPC_STAT, &shm_data ) )
|
if ( shmctl( shm_id, IPC_STAT, &shm_data ) )
|
||||||
{
|
{
|
||||||
Error(( "Can't shmctl: %s", strerror(errno)));
|
Error(( "Can't shmctl: %s", strerror(errno)));
|
||||||
exit( -1 );
|
exit( -1 );
|
||||||
|
@ -121,7 +126,7 @@ Monitor::~Monitor()
|
||||||
|
|
||||||
if ( shm_data.shm_nattch <= 1 )
|
if ( shm_data.shm_nattch <= 1 )
|
||||||
{
|
{
|
||||||
if ( shmctl( shmid, IPC_RMID, 0 ) )
|
if ( shmctl( shm_id, IPC_RMID, 0 ) )
|
||||||
{
|
{
|
||||||
Error(( "Can't shmctl: %s", strerror(errno)));
|
Error(( "Can't shmctl: %s", strerror(errno)));
|
||||||
exit( -1 );
|
exit( -1 );
|
||||||
|
@ -148,19 +153,19 @@ void Monitor::Setup()
|
||||||
|
|
||||||
Debug( 1, ( "monitor purpose=%d", purpose ));
|
Debug( 1, ( "monitor purpose=%d", purpose ));
|
||||||
|
|
||||||
int shared_data_size = sizeof(SharedData)
|
shm_size = sizeof(SharedData)
|
||||||
+ sizeof(TriggerData)
|
+ sizeof(TriggerData)
|
||||||
+ (image_buffer_count*sizeof(struct timeval))
|
+ (image_buffer_count*sizeof(struct timeval))
|
||||||
+ (image_buffer_count*camera->ImageSize());
|
+ (image_buffer_count*camera->ImageSize());
|
||||||
|
|
||||||
Debug( 1, ( "shm.size=%d", shared_data_size ));
|
Debug( 1, ( "shm.size=%d", shm_size ));
|
||||||
shmid = shmget( (config.shm_key&0xffffff00)|id, shared_data_size, IPC_CREAT|0700 );
|
shm_id = shmget( (config.shm_key&0xffffff00)|id, shm_size, IPC_CREAT|0700 );
|
||||||
if ( shmid < 0 )
|
if ( shm_id < 0 )
|
||||||
{
|
{
|
||||||
Error(( "Can't shmget, probably not enough shared memory space free: %s", strerror(errno)));
|
Error(( "Can't shmget, probably not enough shared memory space free: %s", strerror(errno)));
|
||||||
exit( -1 );
|
exit( -1 );
|
||||||
}
|
}
|
||||||
unsigned char *shm_ptr = (unsigned char *)shmat( shmid, 0, 0 );
|
shm_ptr = (unsigned char *)shmat( shm_id, 0, 0 );
|
||||||
if ( shm_ptr < 0 )
|
if ( shm_ptr < 0 )
|
||||||
{
|
{
|
||||||
Error(( "Can't shmat: %s", strerror(errno)));
|
Error(( "Can't shmat: %s", strerror(errno)));
|
||||||
|
@ -174,7 +179,7 @@ void Monitor::Setup()
|
||||||
|
|
||||||
if ( purpose == CAPTURE )
|
if ( purpose == CAPTURE )
|
||||||
{
|
{
|
||||||
memset( shared_data, 0, shared_data_size );
|
memset( shm_ptr, 0, shm_size );
|
||||||
shared_data->size = sizeof(SharedData);
|
shared_data->size = sizeof(SharedData);
|
||||||
shared_data->valid = true;
|
shared_data->valid = true;
|
||||||
shared_data->active = enabled;
|
shared_data->active = enabled;
|
||||||
|
|
|
@ -72,6 +72,46 @@ public:
|
||||||
TAPE
|
TAPE
|
||||||
} State;
|
} State;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
typedef enum { GET_SETTINGS=0x1, SET_SETTINGS=0x2, RELOAD=0x4, SUSPEND=0x10, RESUME=0x20 } Action;
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
bool valid;
|
||||||
|
bool active;
|
||||||
|
bool signal;
|
||||||
|
State state;
|
||||||
|
int last_write_index;
|
||||||
|
int last_read_index;
|
||||||
|
time_t last_image_time;
|
||||||
|
int last_event;
|
||||||
|
int action;
|
||||||
|
int brightness;
|
||||||
|
int hue;
|
||||||
|
int colour;
|
||||||
|
int contrast;
|
||||||
|
int alarm_x;
|
||||||
|
int alarm_y;
|
||||||
|
} SharedData;
|
||||||
|
|
||||||
|
typedef enum { TRIGGER_CANCEL, TRIGGER_ON, TRIGGER_OFF } TriggerState;
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
int size;
|
||||||
|
TriggerState trigger_state;
|
||||||
|
int trigger_score;
|
||||||
|
char trigger_cause[32];
|
||||||
|
char trigger_text[256];
|
||||||
|
char trigger_showtext[32];
|
||||||
|
} TriggerData;
|
||||||
|
|
||||||
|
typedef struct Snapshot
|
||||||
|
{
|
||||||
|
struct timeval *timestamp;
|
||||||
|
Image *image;
|
||||||
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// These are read from the DB and thereafter remain unchanged
|
// These are read from the DB and thereafter remain unchanged
|
||||||
int id;
|
int id;
|
||||||
|
@ -119,51 +159,16 @@ protected:
|
||||||
time_t start_time;
|
time_t start_time;
|
||||||
time_t last_fps_time;
|
time_t last_fps_time;
|
||||||
time_t auto_resume_time;
|
time_t auto_resume_time;
|
||||||
int shmid;
|
|
||||||
|
|
||||||
typedef struct Snapshot
|
int shm_id;
|
||||||
{
|
int shm_size;
|
||||||
struct timeval *timestamp;
|
unsigned char *shm_ptr;
|
||||||
Image *image;
|
|
||||||
};
|
|
||||||
|
|
||||||
Snapshot *image_buffer;
|
|
||||||
|
|
||||||
typedef enum { GET_SETTINGS=0x1, SET_SETTINGS=0x2, RELOAD=0x4, SUSPEND=0x10, RESUME=0x20 } Action;
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
bool valid;
|
|
||||||
bool active;
|
|
||||||
bool signal;
|
|
||||||
State state;
|
|
||||||
int last_write_index;
|
|
||||||
int last_read_index;
|
|
||||||
time_t last_image_time;
|
|
||||||
int last_event;
|
|
||||||
int action;
|
|
||||||
int brightness;
|
|
||||||
int hue;
|
|
||||||
int colour;
|
|
||||||
int contrast;
|
|
||||||
int alarm_x;
|
|
||||||
int alarm_y;
|
|
||||||
} SharedData;
|
|
||||||
|
|
||||||
typedef enum { TRIGGER_CANCEL, TRIGGER_ON, TRIGGER_OFF } TriggerState;
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
int size;
|
|
||||||
TriggerState trigger_state;
|
|
||||||
int trigger_score;
|
|
||||||
char trigger_cause[32];
|
|
||||||
char trigger_text[256];
|
|
||||||
char trigger_showtext[32];
|
|
||||||
} TriggerData;
|
|
||||||
|
|
||||||
SharedData *shared_data;
|
SharedData *shared_data;
|
||||||
TriggerData *trigger_data;
|
TriggerData *trigger_data;
|
||||||
|
|
||||||
|
Snapshot *image_buffer;
|
||||||
|
|
||||||
Camera *camera;
|
Camera *camera;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue