[trunk] begin to clean the old V1 style message event management

This commit is contained in:
Mickael Savinaud 2012-08-09 14:00:31 +00:00
parent 9ed88f6a8d
commit 4397b675cb
4 changed files with 26 additions and 34 deletions

View File

@ -62,16 +62,11 @@ _itoa(int i, char *a, int r) {
#endif
/* ----------------------------------------------------------------------- */
opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context) {
if(cinfo) {
opj_event_mgr_t *previous = cinfo->event_mgr;
cinfo->event_mgr = event_mgr;
cinfo->client_data = context;
return previous;
}
return NULL;
}
/**
* Default callback function.
* Do nothing.
*/
static void opj_default_callback (const char *msg, void *client_data){};
/* ----------------------------------------------------------------------- */
opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ...) {
@ -171,3 +166,14 @@ opj_bool opj_event_msg_v2(opj_event_mgr_t* p_event_mgr, int event_type, const ch
return OPJ_TRUE;
}
void opj_set_default_event_handler(opj_event_mgr_t * p_manager)
{
p_manager->m_error_data = 00;
p_manager->m_warning_data = 00;
p_manager->m_info_data = 00;
p_manager->error_handler = opj_default_callback;
p_manager->info_handler = opj_default_callback;
p_manager->warning_handler = opj_default_callback;
}

View File

@ -89,6 +89,12 @@ opj_bool opj_event_msg(opj_common_ptr cinfo, int event_type, const char *fmt, ..
*/
opj_bool opj_event_msg_v2(opj_event_mgr_t* event_mgr, int event_type, const char *fmt, ...);
/* ----------------------------------------------------------------------- */
/**
* Set the event manager with the default callback function for the 3 levels.
*/
void opj_set_default_event_handler(opj_event_mgr_t * p_manager);
/*@}*/
/*@}*/

View File

@ -149,23 +149,7 @@ typedef struct opj_codec_private
opj_codec_private_t;
/* ---------------------------------------------------------------------- */
/**
* Default callback function.
* Do nothing.
*/
void opj_default_callback (const char *msg, void *client_data)
{
}
void set_default_event_handler(opj_event_mgr_t * p_manager)
{
p_manager->m_error_data = 00;
p_manager->m_warning_data = 00;
p_manager->m_info_data = 00;
p_manager->error_handler = opj_default_callback;
p_manager->info_handler = opj_default_callback;
p_manager->warning_handler = opj_default_callback;
}
/* Functions to set info_handler */
opj_bool OPJ_CALLCONV opj_set_info_handler( opj_codec_t * p_codec,
opj_msg_callback p_callback,
@ -435,7 +419,7 @@ opj_codec_t* OPJ_CALLCONV opj_create_decompress(OPJ_CODEC_FORMAT p_format)
return 00;
}
set_default_event_handler(&(l_codec->m_event_mgr));
opj_set_default_event_handler(&(l_codec->m_event_mgr));
return (opj_codec_t*) l_codec;
}
@ -791,7 +775,7 @@ opj_codec_t* OPJ_CALLCONV opj_create_compress(OPJ_CODEC_FORMAT p_format)
return 00;
}
set_default_event_handler(&(l_codec->m_event_mgr));
opj_set_default_event_handler(&(l_codec->m_event_mgr));
return (opj_codec_t*) l_codec;
}

View File

@ -221,7 +221,7 @@ typedef void (*opj_msg_callback) (const char *msg, void *client_data);
/** SHOULD BE MOVE IN EVET.H when we remove old functions
/** SHOULD BE MOVE IN EVET.H when we remove old functions TODO MSD
Message handler object
used for
<ul>
@ -1181,10 +1181,6 @@ OPJ_API opj_bool OPJ_CALLCONV opj_set_info_handler(opj_codec_t * p_codec, opj_ms
OPJ_API opj_bool OPJ_CALLCONV opj_set_warning_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data);
OPJ_API opj_bool OPJ_CALLCONV opj_set_error_handler(opj_codec_t * p_codec, opj_msg_callback p_callback,void * p_user_data);
/**
*/
DEPRECATED( OPJ_API opj_event_mgr_t* OPJ_CALLCONV opj_set_event_mgr(opj_common_ptr cinfo, opj_event_mgr_t *event_mgr, void *context));
/*
==========================================================
codec functions definitions