From 4397b675cbe311d37e3df963a1e9aa2111348dfc Mon Sep 17 00:00:00 2001 From: Mickael Savinaud Date: Thu, 9 Aug 2012 14:00:31 +0000 Subject: [PATCH] [trunk] begin to clean the old V1 style message event management --- libopenjpeg/event.c | 26 ++++++++++++++++---------- libopenjpeg/event.h | 6 ++++++ libopenjpeg/openjpeg.c | 22 +++------------------- libopenjpeg/openjpeg.h | 6 +----- 4 files changed, 26 insertions(+), 34 deletions(-) diff --git a/libopenjpeg/event.c b/libopenjpeg/event.c index 80d42d8f..a9ef5284 100644 --- a/libopenjpeg/event.c +++ b/libopenjpeg/event.c @@ -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; +} + diff --git a/libopenjpeg/event.h b/libopenjpeg/event.h index 1b80fcb4..d34c8f60 100644 --- a/libopenjpeg/event.h +++ b/libopenjpeg/event.h @@ -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); + /*@}*/ /*@}*/ diff --git a/libopenjpeg/openjpeg.c b/libopenjpeg/openjpeg.c index be22535a..49f379d8 100644 --- a/libopenjpeg/openjpeg.c +++ b/libopenjpeg/openjpeg.c @@ -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; } diff --git a/libopenjpeg/openjpeg.h b/libopenjpeg/openjpeg.h index 922f3ed8..7e2f56a3 100644 --- a/libopenjpeg/openjpeg.h +++ b/libopenjpeg/openjpeg.h @@ -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