diff src/amidi-plug/i_configure.c @ 437:e1c6b223431e trunk

[svn] - amidiplug: on midi backend init, pass a function that helps the backend to get the location of amidi-plug.conf
author giacomo
date Mon, 15 Jan 2007 13:25:41 -0800
parents a668576342e0
children fe9ffc829b5f
line wrap: on
line diff
--- a/src/amidi-plug/i_configure.c	Mon Jan 15 12:46:38 2007 -0800
+++ b/src/amidi-plug/i_configure.c	Mon Jan 15 13:25:41 2007 -0800
@@ -21,6 +21,7 @@
 
 #include "i_configure.h"
 #include "i_configure_private.h"
+#include "i_configure_file.h"
 #include "i_backend.h"
 #include "i_configure-ap.h"
 #include "i_configure-alsa.h"
@@ -272,7 +273,7 @@
     {
       DEBUGMSG( "the selected backend is already loaded, so just perform backend cleanup and reinit\n" );
       backend.cleanup();
-      backend.init();
+      backend.init( i_configure_cfg_get_file );
     }
   }
 
@@ -311,10 +312,8 @@
 void i_configure_cfg_backend_read( void )
 {
   pcfg_t *cfgfile;
-  gchar * config_datadir = (gchar*)audacious_get_localdir();
-  gchar * config_pathfilename = g_build_filename( config_datadir , "amidi-plug.conf" , NULL );
+  gchar *config_pathfilename = i_configure_cfg_get_file();
 
-  g_free( config_datadir );
   cfgfile = i_pcfg_new_from_file( config_pathfilename );
 
   i_configure_cfg_alsa_read( cfgfile ); /* get alsa backend configuration */
@@ -331,10 +330,8 @@
 void i_configure_cfg_backend_save( void )
 {
   pcfg_t *cfgfile;
-  gchar * config_datadir = (gchar*)audacious_get_localdir();
-  gchar * config_pathfilename = g_build_filename( config_datadir , "amidi-plug.conf" , NULL );
+  gchar *config_pathfilename = i_configure_cfg_get_file();
 
-  g_free( config_datadir );
   cfgfile = i_pcfg_new_from_file( config_pathfilename );
 
   if (!cfgfile)
@@ -354,10 +351,8 @@
 void i_configure_cfg_ap_read( void )
 {
   pcfg_t *cfgfile;
-  gchar * config_datadir = (gchar*)audacious_get_localdir();
-  gchar * config_pathfilename = g_build_filename( config_datadir , "amidi-plug.conf" , NULL );
+  gchar *config_pathfilename = i_configure_cfg_get_file();
 
-  g_free( config_datadir );
   cfgfile = i_pcfg_new_from_file( config_pathfilename );
 
   if (!cfgfile)
@@ -394,10 +389,7 @@
 void i_configure_cfg_ap_save( void )
 {
   pcfg_t *cfgfile;
-  gchar * config_datadir = (gchar*)audacious_get_localdir();
-  gchar * config_pathfilename = g_build_filename( config_datadir , "amidi-plug.conf" , NULL );
-
-  g_free( config_datadir );
+  gchar *config_pathfilename = i_configure_cfg_get_file();
   cfgfile = i_pcfg_new_from_file( config_pathfilename );
 
   if (!cfgfile)
@@ -421,3 +413,12 @@
   i_pcfg_free( cfgfile );
   g_free( config_pathfilename );
 }
+
+
+gchar * i_configure_cfg_get_file( void )
+{
+  gchar * config_datadir = (gchar*)audacious_get_localdir();
+  gchar * config_pathfilename = g_build_filename( config_datadir , "amidi-plug.conf" , NULL );
+  g_free( config_datadir );
+  return config_pathfilename;
+}