comparison src/amidi-plug/i_backend.c @ 1295:d2e508857ded

"Don't touch debug stuff !" commit. ;-)
author Stany HENRY <StrassBoy@gmail.com>
date Thu, 19 Jul 2007 03:16:44 +0200
parents 5daedb3af7c9
children
comparison
equal deleted inserted replaced
1294:ea7c0a4fe793 1295:d2e508857ded
49 gchar * module_pathfilename = g_strjoin( "" , AMIDIPLUGBACKENDDIR , "/" , 49 gchar * module_pathfilename = g_strjoin( "" , AMIDIPLUGBACKENDDIR , "/" ,
50 backend_directory_entry , NULL ); 50 backend_directory_entry , NULL );
51 /* seems to be a backend for amidi-plug , try to load it */ 51 /* seems to be a backend for amidi-plug , try to load it */
52 module = g_module_open( module_pathfilename , G_MODULE_BIND_LOCAL ); 52 module = g_module_open( module_pathfilename , G_MODULE_BIND_LOCAL );
53 if ( module == NULL ) 53 if ( module == NULL )
54 g_warning( _("Error loading module %s - %s\n") , module_pathfilename , g_module_error() ); 54 g_warning( "Error loading module %s - %s\n" , module_pathfilename , g_module_error() );
55 else 55 else
56 { 56 {
57 /* try to get the module name */ 57 /* try to get the module name */
58 if ( g_module_symbol( module , "backend_info_get" , (gpointer*)&getapmoduleinfo ) ) 58 if ( g_module_symbol( module , "backend_info_get" , (gpointer*)&getapmoduleinfo ) )
59 { 59 {
60 /* module name found, ok! add its name and filename to the list */ 60 /* module name found, ok! add its name and filename to the list */
61 amidiplug_sequencer_backend_name_t * mn = g_malloc(sizeof(amidiplug_sequencer_backend_name_t)); 61 amidiplug_sequencer_backend_name_t * mn = g_malloc(sizeof(amidiplug_sequencer_backend_name_t));
62 /* name and desc dinamically allocated */ 62 /* name and desc dinamically allocated */
63 getapmoduleinfo( &mn->name , &mn->longname , &mn->desc , &mn->ppos ); 63 getapmoduleinfo( &mn->name , &mn->longname , &mn->desc , &mn->ppos );
64 mn->filename = g_strdup(module_pathfilename); /* dinamically allocated */ 64 mn->filename = g_strdup(module_pathfilename); /* dinamically allocated */
65 DEBUGMSG( _("Backend found and added in list, filename: %s and lname: %s\n") , 65 DEBUGMSG( "Backend found and added in list, filename: %s and lname: %s\n" ,
66 mn->filename, mn->longname ); 66 mn->filename, mn->longname );
67 backend_list = g_slist_append( backend_list , mn ); 67 backend_list = g_slist_append( backend_list , mn );
68 } 68 }
69 else 69 else
70 { 70 {
71 /* module name not found, this is not a backend for amidi-plug */ 71 /* module name not found, this is not a backend for amidi-plug */
72 g_warning( _("File %s is not a backend for amidi-plug!\n") , module_pathfilename ); 72 g_warning( "File %s is not a backend for amidi-plug!\n" , module_pathfilename );
73 } 73 }
74 g_module_close( module ); 74 g_module_close( module );
75 } 75 }
76 } 76 }
77 backend_directory_entry = g_dir_read_name( backend_directory ); 77 backend_directory_entry = g_dir_read_name( backend_directory );
78 } 78 }
79 g_dir_close( backend_directory ); 79 g_dir_close( backend_directory );
80 } 80 }
81 else 81 else
82 g_warning( _("Unable to open the backend directory %s\n") , AMIDIPLUGBACKENDDIR ); 82 g_warning( "Unable to open the backend directory %s\n" , AMIDIPLUGBACKENDDIR );
83 83
84 return backend_list; 84 return backend_list;
85 } 85 }
86 86
87 87
102 102
103 103
104 gint i_backend_load( gchar * module_name ) 104 gint i_backend_load( gchar * module_name )
105 { 105 {
106 gchar * module_pathfilename = g_strjoin( "" , AMIDIPLUGBACKENDDIR , "/ap-" , module_name , ".so" , NULL ); 106 gchar * module_pathfilename = g_strjoin( "" , AMIDIPLUGBACKENDDIR , "/ap-" , module_name , ".so" , NULL );
107 DEBUGMSG( _("loading backend '%s'\n") , module_pathfilename ); 107 DEBUGMSG( "loading backend '%s'\n" , module_pathfilename );
108 backend.gmodule = g_module_open( module_pathfilename , 0 ); 108 backend.gmodule = g_module_open( module_pathfilename , 0 );
109 109
110 if ( backend.gmodule != NULL ) 110 if ( backend.gmodule != NULL )
111 { 111 {
112 gchar * (*getapmoduleinfo)( gchar ** , gchar ** , gchar ** , gint * ); 112 gchar * (*getapmoduleinfo)( gchar ** , gchar ** , gchar ** , gint * );
138 g_module_symbol( backend.gmodule , "sequencer_get_port_count" , (gpointer *)&backend.seq_get_port_count ); 138 g_module_symbol( backend.gmodule , "sequencer_get_port_count" , (gpointer *)&backend.seq_get_port_count );
139 g_module_symbol( backend.gmodule , "backend_info_get" , (gpointer*)&getapmoduleinfo ); 139 g_module_symbol( backend.gmodule , "backend_info_get" , (gpointer*)&getapmoduleinfo );
140 g_module_symbol( backend.gmodule , "audio_check_autonomous" , (gpointer*)&checkautonomousaudio ); 140 g_module_symbol( backend.gmodule , "audio_check_autonomous" , (gpointer*)&checkautonomousaudio );
141 getapmoduleinfo( &backend.name , NULL , NULL , NULL ); 141 getapmoduleinfo( &backend.name , NULL , NULL , NULL );
142 backend.autonomous_audio = checkautonomousaudio(); 142 backend.autonomous_audio = checkautonomousaudio();
143 DEBUGMSG( _("backend %s (name '%s') successfully loaded\n") , module_pathfilename , backend.name ); 143 DEBUGMSG( "backend %s (name '%s') successfully loaded\n" , module_pathfilename , backend.name );
144 backend.init( i_configure_cfg_get_file ); 144 backend.init( i_configure_cfg_get_file );
145 g_free( module_pathfilename ); 145 g_free( module_pathfilename );
146 return 1; 146 return 1;
147 } 147 }
148 else 148 else
149 { 149 {
150 backend.name = NULL; 150 backend.name = NULL;
151 g_warning( _("unable to load backend '%s'\n") , module_pathfilename ); 151 g_warning( "unable to load backend '%s'\n" , module_pathfilename );
152 g_free( module_pathfilename ); 152 g_free( module_pathfilename );
153 return 0; 153 return 0;
154 } 154 }
155 } 155 }
156 156
157 157
158 gint i_backend_unload( void ) 158 gint i_backend_unload( void )
159 { 159 {
160 if ( backend.gmodule != NULL ) 160 if ( backend.gmodule != NULL )
161 { 161 {
162 DEBUGMSG( _("unloading backend '%s'\n") , backend.name ); 162 DEBUGMSG( "unloading backend '%s'\n" , backend.name );
163 backend.cleanup(); 163 backend.cleanup();
164 g_module_close( backend.gmodule ); 164 g_module_close( backend.gmodule );
165 DEBUGMSG( _("backend '%s' unloaded\n") , backend.name ); 165 DEBUGMSG( "backend '%s' unloaded\n" , backend.name );
166 g_free( backend.name ); 166 g_free( backend.name );
167 backend.gmodule = NULL; 167 backend.gmodule = NULL;
168 return 1; 168 return 1;
169 } 169 }
170 else 170 else
171 { 171 {
172 g_warning( _("attempting to unload backend, but no backend is loaded\n") ); 172 g_warning( "attempting to unload backend, but no backend is loaded\n" );
173 return 0; 173 return 0;
174 } 174 }
175 } 175 }