From 415fa18ad93493b7073a69cda3af27863537185b Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sat, 29 Aug 2015 18:32:11 +0200 Subject: jpeg-utils: Unify media libraries initialization Both MagickWand and exiv2 needs some initialization and cleanup, move it to jpeg-utils for clean includes in cgg.c. Also add explicit exiv2 XMP initialization as stated on http://dev.exiv2.org/projects/exiv2/wiki/Thread_safety: "The XMP SDK initialization function is not mutex protected, thus Exiv2::XmpParser::initialize is not thread-safe. Therefore, multi-threaded applications need to ensure that this XMP function is serialized, e.g., by calling them from an initialization section which is run before any threads are started." See also https://bugs.kde.org/show_bug.cgi?id=166424 --- src/jpeg-utils.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src/jpeg-utils.cpp') diff --git a/src/jpeg-utils.cpp b/src/jpeg-utils.cpp index 965d751..2d85d3b 100644 --- a/src/jpeg-utils.cpp +++ b/src/jpeg-utils.cpp @@ -35,6 +35,26 @@ struct ExifDataPrivate { }; +/* + * Thread-safe ImageMagick and exiv2 libraries initialization and cleanup + */ +void +init_jpeg_utils (void) +{ + MagickWandGenesis(); + /* http://dev.exiv2.org/projects/exiv2/wiki/Thread_safety */ + /* https://bugs.kde.org/show_bug.cgi?id=166424 */ + Exiv2::XmpParser::initialize(); +} + +void +destroy_jpeg_utils (void) +{ + Exiv2::XmpParser::terminate(); + MagickWandTerminus(); +} + + static void shift_time (struct tm *tm, int offset_min) { -- cgit v1.2.3