]> git.sesse.net Git - mlt/commitdiff
mlt_factory.c: guard against setting mlt_environment before it is available
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sat, 2 Feb 2008 08:52:39 +0000 (08:52 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Sat, 2 Feb 2008 08:52:39 +0000 (08:52 +0000)
mlt_profile.c: use getenv instead of mlt_environment in case profile is created before factory

git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1052 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_factory.c
src/framework/mlt_profile.c

index cd19b158df71a1af3e8a2ad83744fe032ab94953..0b4508c505b2a8615fb1333cb989dd5edd48213f 100644 (file)
@@ -147,7 +147,10 @@ char *mlt_environment( const char *name )
 
 int mlt_environment_set( const char *name, const char *value )
 {
-       return mlt_properties_set( global_properties, name, value );
+       if ( global_properties )
+               return mlt_properties_set( global_properties, name, value );
+       else
+               return -1;
 }
 
 static void set_common_properties( mlt_properties properties, mlt_profile profile, const char *type, const char *service )
index 778bb538098dadd26aef839b3f38ded2948c57c3..b9e230f68b834d5b85fdf72a2e1823c8e5de77b5 100644 (file)
@@ -89,9 +89,9 @@ mlt_profile mlt_profile_init( const char *name )
        {
                // MLT_PROFILE is preferred environment variable
                if ( getenv( "MLT_PROFILE" ) )
-                       profile = mlt_profile_select( mlt_environment( "MLT_PROFILE" ) );
+                       profile = mlt_profile_select( getenv( "MLT_PROFILE" ) );
                // MLT_NORMALISATION backwards compatibility
-               else if ( strcmp( mlt_environment( "MLT_NORMALISATION" ), "PAL" ) )
+               else if ( getenv( "MLT_NORMALISATION" ) && strcmp( getenv( "MLT_NORMALISATION" ), "PAL" ) )
                        profile = mlt_profile_select( "dv_ntsc" );
                else
                        profile = mlt_profile_select( "dv_pal" );
@@ -144,20 +144,22 @@ mlt_profile mlt_profile_load_file( const char *file )
        }
 
        // Set MLT_NORMALISATION to appease legacy modules
-       char *profile_name = mlt_environment( "MLT_PROFILE" );
-       if ( strstr( profile_name, "_ntsc" ) ||
-            strstr( profile_name, "_60" ) ||
-            strstr( profile_name, "_30" ) )
+       char *profile_name = getenv( "MLT_PROFILE" );
+       if ( profile_name )
        {
-               mlt_environment_set( "MLT_NORMALISATION", "NTSC" );
-       }
-       else if ( strstr( profile_name, "_pal" ) ||
-                 strstr( profile_name, "_50" ) ||
-                 strstr( profile_name, "_25" ) )
-       {
-               mlt_environment_set( "MLT_NORMALISATION", "PAL" );
+               if ( strstr( profile_name, "_ntsc" ) ||
+                       strstr( profile_name, "_60" ) ||
+                       strstr( profile_name, "_30" ) )
+               {
+                       mlt_environment_set( "MLT_NORMALISATION", "NTSC" );
+               }
+               else if ( strstr( profile_name, "_pal" ) ||
+                               strstr( profile_name, "_50" ) ||
+                               strstr( profile_name, "_25" ) )
+               {
+                       mlt_environment_set( "MLT_NORMALISATION", "PAL" );
+               }
        }
-
        return profile;
 }