]> git.sesse.net Git - mlt/blobdiff - src/framework/mlt_factory.c
Fix crash in glDeleteSync() called on wrong thread.
[mlt] / src / framework / mlt_factory.c
index bf4a0a0ad4d8a2b48af14e3b50f7b6a1bb05f386..b49f16b4b4dc1e19fe0efb6530a48096f28a12d2 100644 (file)
@@ -27,6 +27,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <locale.h>
+#include <libgen.h>
 
 #ifdef WIN32
 #include <windows.h>
 #define PREFIX_DATA "\\share\\mlt"
 #elif defined(__DARWIN__) && defined(RELOCATABLE)
 #include <mach-o/dyld.h>
-#include <libgen.h>
 /** the default subdirectory of the libdir for holding modules (plugins) */
 #define PREFIX_LIB "/lib/mlt"
 /** the default subdirectory of the install prefix for holding module (plugin) data */
 #define PREFIX_DATA "/share/mlt"
-#else
-/** the default subdirectory of the libdir for holding modules (plugins) */
-#define PREFIX_LIB LIBDIR "/mlt"
-/** the default subdirectory of the install prefix for holding module (plugin) data */
-#define PREFIX_DATA PREFIX "/share/mlt"
 #endif
 
 /** holds the full path to the modules directory - initialized and retained for the entire session */
@@ -124,8 +119,22 @@ mlt_repository mlt_factory_init( const char *directory )
                mlt_properties_set_or_default( global_properties, "MLT_CONSUMER", getenv( "MLT_CONSUMER" ), "sdl" );
                mlt_properties_set( global_properties, "MLT_TEST_CARD", getenv( "MLT_TEST_CARD" ) );
                mlt_properties_set_or_default( global_properties, "MLT_PROFILE", getenv( "MLT_PROFILE" ), "dv_pal" );
-
                mlt_properties_set_or_default( global_properties, "MLT_DATA", getenv( "MLT_DATA" ), PREFIX_DATA );
+#if defined(WIN32)
+               char path[1024];
+               DWORD size = sizeof( path );
+               GetModuleFileName( NULL, path, size );
+#elif defined(__DARWIN__)  && defined(RELOCATABLE)
+               char path[1024];
+               uint32_t size = sizeof( path );
+               _NSGetExecutablePath( path, &size );
+#endif
+#if defined(WIN32) || (defined(__DARWIN__) && defined(RELOCATABLE))
+               char *path2 = strdup( path );
+               char *appdir = dirname( path2 );
+               mlt_properties_set( global_properties, "MLT_APPDIR", appdir );
+               free( path2 );
+#endif
        }
 
        // Only initialise once
@@ -140,29 +149,22 @@ mlt_repository mlt_factory_init( const char *directory )
                        directory = PREFIX_LIB;
 
                // Store the prefix for later retrieval
-#if defined(WIN32)
-               LPTSTR path[1024];
-               DWORD size = sizeof( path );
-               GetModuleFileName( NULL, path, &size );
-#elif defined(__DARWIN__)  && defined(RELOCATABLE)
-               char path[1024];
-               uint32_t size = sizeof( path );
-               _NSGetExecutablePath( path, &size );
-#else
-               mlt_directory = strdup( directory );
-#endif
 #if defined(WIN32) || (defined(__DARWIN__) && defined(RELOCATABLE))
+               char *exedir = mlt_environment( "MLT_APPDIR" );
+               size_t size = strlen( exedir );
                if ( global_properties && !getenv( "MLT_DATA" ) )
                {
                        mlt_directory = calloc( 1, size + strlen( PREFIX_DATA ) + 1 );
-                       strcpy( mlt_directory, dirname( path ) );
+                       strcpy( mlt_directory, exedir );
                        strcat( mlt_directory, PREFIX_DATA );
                        mlt_properties_set( global_properties, "MLT_DATA", mlt_directory );
                        free( mlt_directory );
                }
                mlt_directory = calloc( 1, size + strlen( directory ) + 1 );
-               strcpy( mlt_directory, dirname( path ) );
+               strcpy( mlt_directory, exedir );
                strcat( mlt_directory, directory );
+#else
+               mlt_directory = strdup( directory );
 #endif
                
                // Initialise the pool
@@ -406,8 +408,12 @@ void mlt_factory_close( )
        {
                mlt_properties_close( event_object );
                event_object = NULL;
+#if !defined(WIN32)
+               // XXX something in here is causing Shotcut/Win32 to not exit completely
+               // under certain conditions: e.g. play a playlist.
                mlt_properties_close( global_properties );
                global_properties = NULL;
+#endif
                if ( repository )
                {
                        mlt_repository_close( repository );