diff options
author | Grigori Goronzy <greg@blackbox> | 2009-07-12 08:01:23 +0200 |
---|---|---|
committer | Grigori Goronzy <greg@blackbox> | 2009-07-12 08:02:52 +0200 |
commit | 71fc0fbbf34110050bda200d25eb230b8b044324 (patch) | |
tree | 15cc23637cf7a1c461244cfcc3f2c4bf98ab31ca /libass/ass_library.c | |
parent | d3cd5b0148d64ae0f6e288e69b09acfe639fdcce (diff) | |
download | libass-71fc0fbbf34110050bda200d25eb230b8b044324.tar.bz2 libass-71fc0fbbf34110050bda200d25eb230b8b044324.tar.xz |
Allow passing user data to callback
It is often useful or necessary to pass custom data to a callback.
Add an argument to the callback registering function to pass a void
pointer object to the callback each time it is called.
Diffstat (limited to 'libass/ass_library.c')
-rw-r--r-- | libass/ass_library.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/libass/ass_library.c b/libass/ass_library.c index 2a8f5b2..9b6da02 100644 --- a/libass/ass_library.c +++ b/libass/ass_library.c @@ -28,7 +28,7 @@ #include "ass_library.h" #include "ass_utils.h" -static void ass_msg_handler(int level, char *fmt, va_list *va) +static void ass_msg_handler(int level, char *fmt, va_list *va, void *data) { if (level > MSGL_INFO) return; @@ -132,11 +132,17 @@ void ass_clear_fonts(ass_library_t *priv) * Register a message callback function with libass. Without setting one, * a default handler is used which prints everything with MSGL_INFO or * higher to the standard output. + * + * \param msg_cb the callback function + * \param data additional data that will be passed to the callback */ void ass_set_message_cb(ass_library_t *priv, - void (*msg_cb)(int, char *, va_list *)) + void (*msg_cb)(int, char *, va_list *, void *), + void *data) { - if (msg_cb) + if (msg_cb) { priv->msg_callback = msg_cb; + priv->msg_callback_data = data; + } } |