X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_repository.c;h=9e0b1a879e9f98e272a03eb7e15a573583b2abe2;hb=ad829dbc7677a2acc063635db14ce717eb40be50;hp=0928b371965bbef65d248e795ffc34e7b891345a;hpb=4ed2712bbdac2182c7c0d6477ac77c9f92aaf02a;p=melted diff --git a/src/framework/mlt_repository.c b/src/framework/mlt_repository.c index 0928b37..9e0b1a8 100644 --- a/src/framework/mlt_repository.c +++ b/src/framework/mlt_repository.c @@ -29,7 +29,6 @@ struct mlt_repository_s { struct mlt_properties_s parent; - mlt_properties object_list; }; static char *construct_full_file( char *output, char *prefix, char *file ) @@ -50,8 +49,7 @@ static char *chomp( char *input ) static mlt_properties construct_object( char *prefix, char *id ) { - mlt_properties output = calloc( sizeof( struct mlt_properties_s ), 1 ); - mlt_properties_init( output, NULL ); + mlt_properties output = mlt_properties_new( ); mlt_properties_set( output, "prefix", prefix ); mlt_properties_set( output, "id", id ); return output; @@ -59,14 +57,13 @@ static mlt_properties construct_object( char *prefix, char *id ) static mlt_properties construct_service( mlt_properties object, char *id ) { - mlt_properties output = calloc( sizeof( struct mlt_properties_s ), 1 ); - mlt_properties_init( output, NULL ); + mlt_properties output = mlt_properties_new( ); mlt_properties_set_data( output, "object", object, 0, NULL, NULL ); mlt_properties_set( output, "id", id ); return output; } -void *construct_instance( mlt_properties service_properties, char *symbol, void *input ) +static void *construct_instance( mlt_properties service_properties, char *symbol, void *input ) { // Extract the service char *service = mlt_properties_get( service_properties, "id" ); @@ -94,9 +91,11 @@ void *construct_instance( mlt_properties service_properties, char *symbol, void // Open the shared object object = dlopen( full_file, RTLD_NOW | RTLD_GLOBAL ); + if ( object == NULL ) + fprintf( stderr, "Failed to load plugin: %s\n", dlerror() ); // Set it on the properties - mlt_properties_set_data( object_properties, "dlopen", object, 0, ( void (*)( void * ) )dlclose, NULL ); + mlt_properties_set_data( object_properties, "dlopen", object, 0, ( mlt_destructor )dlclose, NULL ); } // Now check if we have this symbol pointer @@ -113,12 +112,6 @@ void *construct_instance( mlt_properties service_properties, char *symbol, void return symbol_ptr != NULL ? symbol_ptr( service, input ) : NULL; } -void destroy_properties( void *arg ) -{ - mlt_properties_close( arg ); - free( arg ); -} - mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, char *data, char *symbol ) { char full_file[ 512 ]; @@ -126,14 +119,11 @@ mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, ch // Construct the repository mlt_repository this = calloc( sizeof( struct mlt_repository_s ), 1 ); - mlt_properties_init( &this->parent, NULL ); + mlt_properties_init( &this->parent, this ); // Add the symbol to THIS repository properties. mlt_properties_set( &this->parent, "_symbol", symbol ); - // Asociate the repository to the global object_list - this->object_list = object_list; - // Construct full file construct_full_file( full_file, prefix, data ); @@ -163,14 +153,14 @@ mlt_repository mlt_repository_init( mlt_properties object_list, char *prefix, ch object_properties = construct_object( prefix, object ); // Add it to the object list - mlt_properties_set_data( object_list, object, object_properties, 0, destroy_properties, NULL ); + mlt_properties_set_data( object_list, object, object_properties, 0, ( mlt_destructor )mlt_properties_close, NULL ); } // Now construct a property for the service mlt_properties service_properties = construct_service( object_properties, service ); // Add it to the repository - mlt_properties_set_data( &this->parent, service, service_properties, 0, destroy_properties, NULL ); + mlt_properties_set_data( &this->parent, service, service_properties, 0, ( mlt_destructor )mlt_properties_close, NULL ); } }