From 2c412cdab94a7bb27c5a1e04ab902295215de888 Mon Sep 17 00:00:00 2001 From: Grigori Goronzy Date: Sat, 11 Jul 2009 02:18:51 +0200 Subject: Message callback funtionality Introduce functionality for providing a message callback that is used for passing messages to the controlling application instead of simply printing them to standard output. The function pointer to the callback is stored in the ass_library_t instance. ass_msg needs access to it, so in many places the library instance needs to be passed around now. The default behavior is the old one: messages of MSGL_INFO or lower are printed to the standard output, prefixed with "[ass]". --- test/test.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'test') diff --git a/test/test.cpp b/test/test.cpp index 816d779..9728590 100644 --- a/test/test.cpp +++ b/test/test.cpp @@ -1,6 +1,7 @@ #include #include #include +#include extern "C" { #include @@ -16,6 +17,15 @@ struct image_t { ass_library_t* ass_library; ass_renderer_t* ass_renderer; +void msg_callback(int level, char *fmt, va_list *va) +{ + if (level > 6) + return; + printf("libass: "); + vprintf(fmt, *va); + printf("\n"); +} + static void write_png(char *fname, image_t* img) { FILE * fp; @@ -71,6 +81,7 @@ static void init(int frame_w, int frame_h) { ass_set_fonts_dir(ass_library, ""); ass_set_extract_fonts(ass_library, 0); ass_set_style_overrides(ass_library, NULL); + ass_set_message_cb(ass_library, msg_callback); ass_renderer = ass_renderer_init(ass_library); if (!ass_renderer) throw std::runtime_error("ass_renderer_init failed"); -- cgit v1.2.3