From 6967e58ddd118f3fd0e071cfaeff89c56fd612c5 Mon Sep 17 00:00:00 2001 From: ddennedy Date: Thu, 7 Feb 2008 05:57:43 +0000 Subject: [PATCH] cleanup some names since we are changing the interface mlt_repository.[hc]: change mlt_repository_fetch to mlt_repository_create mlt_factory.[hc]: change mlt_factory_prefix to mlt_factory_directory git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1059 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/framework/mlt_factory.c | 38 +++++++++++++++++++------------------- src/framework/mlt_factory.h | 4 ++-- src/framework/mlt_repository.c | 12 ++++++++---- src/framework/mlt_repository.h | 4 ++-- 4 files changed, 31 insertions(+), 27 deletions(-) diff --git a/src/framework/mlt_factory.c b/src/framework/mlt_factory.c index ec885b6..d7c6f00 100644 --- a/src/framework/mlt_factory.c +++ b/src/framework/mlt_factory.c @@ -31,7 +31,7 @@ /** Singleton repositories */ -static char *mlt_prefix = NULL; +static char *mlt_directory = NULL; static mlt_properties global_properties = NULL; static mlt_repository repository = NULL; static mlt_properties event_object = NULL; @@ -55,21 +55,21 @@ static void mlt_factory_create_done( mlt_listener listener, mlt_properties owner /** Construct the factories. */ -mlt_repository mlt_factory_init( const char *prefix ) +mlt_repository mlt_factory_init( const char *directory ) { // Only initialise once - if ( mlt_prefix == NULL ) + if ( mlt_directory == NULL ) { // Allow user over rides - if ( prefix == NULL || !strcmp( prefix, "" ) ) - prefix = getenv( "MLT_REPOSITORY" ); + if ( directory == NULL || !strcmp( directory, "" ) ) + directory = getenv( "MLT_REPOSITORY" ); // If no directory is specified, default to install directory - if ( prefix == NULL ) - prefix = PREFIX_LIB; + if ( directory == NULL ) + directory = PREFIX_LIB; // Store the prefix for later retrieval - mlt_prefix = strdup( prefix ); + mlt_directory = strdup( directory ); // Initialise the pool mlt_pool_init( ); @@ -90,7 +90,7 @@ mlt_repository mlt_factory_init( const char *prefix ) global_properties = mlt_properties_new( ); // Create the repository of services - repository = mlt_repository_init( prefix ); + repository = mlt_repository_init( directory ); // Force a clean up when app closes atexit( mlt_factory_close ); @@ -119,12 +119,12 @@ mlt_properties mlt_factory_event_object( ) return event_object; } -/** Fetch the prefix used in this instance. +/** Fetch the module directory used in this instance. */ -const char *mlt_factory_prefix( ) +const char *mlt_factory_directory( ) { - return mlt_prefix; + return mlt_directory; } /** Get a value from the environment. @@ -176,7 +176,7 @@ mlt_producer mlt_factory_producer( mlt_profile profile, const char *service, voi // Try to instantiate via the specified service if ( obj == NULL ) { - obj = mlt_repository_fetch( repository, profile, producer_type, service, input ); + obj = mlt_repository_create( repository, profile, producer_type, service, input ); mlt_events_fire( event_object, "producer-create-done", service, input, obj, NULL ); if ( obj != NULL ) { @@ -199,7 +199,7 @@ mlt_filter mlt_factory_filter( mlt_profile profile, const char *service, void *i if ( obj == NULL ) { - obj = mlt_repository_fetch( repository, profile, filter_type, service, input ); + obj = mlt_repository_create( repository, profile, filter_type, service, input ); mlt_events_fire( event_object, "filter-create-done", service, input, obj, NULL ); } @@ -223,7 +223,7 @@ mlt_transition mlt_factory_transition( mlt_profile profile, const char *service, if ( obj == NULL ) { - obj = mlt_repository_fetch( repository, profile, transition_type, service, input ); + obj = mlt_repository_create( repository, profile, transition_type, service, input ); mlt_events_fire( event_object, "transition-create-done", service, input, obj, NULL ); } @@ -250,7 +250,7 @@ mlt_consumer mlt_factory_consumer( mlt_profile profile, const char *service, voi if ( obj == NULL ) { - obj = mlt_repository_fetch( repository, profile, consumer_type, service, input ); + obj = mlt_repository_create( repository, profile, consumer_type, service, input ); mlt_events_fire( event_object, "consumer-create-done", service, input, obj, NULL ); } @@ -277,13 +277,13 @@ void mlt_factory_register_for_clean_up( void *ptr, mlt_destructor destructor ) void mlt_factory_close( ) { - if ( mlt_prefix != NULL ) + if ( mlt_directory != NULL ) { mlt_properties_close( event_object ); mlt_properties_close( global_properties ); mlt_repository_close( repository ); - free( mlt_prefix ); - mlt_prefix = NULL; + free( mlt_directory ); + mlt_directory = NULL; mlt_pool_close( ); } } diff --git a/src/framework/mlt_factory.h b/src/framework/mlt_factory.h index 82dc3ef..f2a9d22 100644 --- a/src/framework/mlt_factory.h +++ b/src/framework/mlt_factory.h @@ -25,8 +25,8 @@ #include "mlt_profile.h" #include "mlt_repository.h" -extern mlt_repository mlt_factory_init( const char *prefix ); -extern const char *mlt_factory_prefix( ); +extern mlt_repository mlt_factory_init( const char *directory ); +extern const char *mlt_factory_directory( ); extern char *mlt_environment( const char *name ); extern int mlt_environment_set( const char *name, const char *value ); extern mlt_properties mlt_factory_event_object( ); diff --git a/src/framework/mlt_repository.c b/src/framework/mlt_repository.c index 7f474f3..3ab95be 100644 --- a/src/framework/mlt_repository.c +++ b/src/framework/mlt_repository.c @@ -35,8 +35,12 @@ struct mlt_repository_s mlt_properties transitions; }; -mlt_repository mlt_repository_init( const char *prefix ) +mlt_repository mlt_repository_init( const char *directory ) { + // Safety check + if ( directory == NULL || strcmp( directory, "" ) == 0 ) + return NULL; + // Construct the repository mlt_repository this = calloc( sizeof( struct mlt_repository_s ), 1 ); mlt_properties_init( &this->parent, this ); @@ -44,10 +48,10 @@ mlt_repository mlt_repository_init( const char *prefix ) this->filters = mlt_properties_new(); this->producers = mlt_properties_new(); this->transitions = mlt_properties_new(); - + // Get the directory list mlt_properties dir = mlt_properties_new(); - int count = mlt_properties_dir_list( dir, prefix, NULL, 0 ); + int count = mlt_properties_dir_list( dir, directory, NULL, 0 ); int i; // Iterate over files @@ -108,7 +112,7 @@ void mlt_repository_register( mlt_repository this, mlt_service_type service_type } } -void *mlt_repository_fetch( mlt_repository this, mlt_profile profile, mlt_service_type type, const char *service, void *input ) +void *mlt_repository_create( mlt_repository this, mlt_profile profile, mlt_service_type type, const char *service, void *input ) { void *( *symbol_ptr )( mlt_profile, mlt_service_type, const char *, void * ) = NULL; diff --git a/src/framework/mlt_repository.h b/src/framework/mlt_repository.h index c4e4142..d8d65b1 100644 --- a/src/framework/mlt_repository.h +++ b/src/framework/mlt_repository.h @@ -38,9 +38,9 @@ typedef struct mlt_repository_s *mlt_repository; /** Public functions. */ -extern mlt_repository mlt_repository_init( const char *prefix ); +extern mlt_repository mlt_repository_init( const char *directory ); extern void mlt_repository_register( mlt_repository self, mlt_service_type service_type, const char *service, void *symbol ); -extern void *mlt_repository_fetch( mlt_repository self, mlt_profile profile, mlt_service_type type, const char *service, void *input ); +extern void *mlt_repository_create( mlt_repository self, mlt_profile profile, mlt_service_type type, const char *service, void *arg ); extern void mlt_repository_close( mlt_repository self ); #endif -- 1.7.4.4