summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorGrigori Goronzy <greg@blackbox>2009-07-11 02:18:51 +0200
committerGrigori Goronzy <greg@blackbox>2009-07-11 02:22:18 +0200
commit2c412cdab94a7bb27c5a1e04ab902295215de888 (patch)
treec1372ebf5e6473b287e152a40c88587f3470d237 /test
parent613a22ab9b96453c10de6d75b43067652ad6d7db (diff)
downloadlibass-2c412cdab94a7bb27c5a1e04ab902295215de888.tar.bz2
libass-2c412cdab94a7bb27c5a1e04ab902295215de888.tar.xz
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]".
Diffstat (limited to 'test')
-rw-r--r--test/test.cpp11
1 files changed, 11 insertions, 0 deletions
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 <stdio.h>
#include <stdlib.h>
#include <stdexcept>
+#include <stdarg.h>
extern "C" {
#include <ass.h>
@@ -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");