[beast] Fix #578686 - Audio tests for .bsewave files don't work



commit 598669b1f80dc612ecfb1e3772269db654032a91
Author: Tim Janik <timj gtk org>
Date:   Wed Oct 21 01:32:35 2009 +0200

    Fix #578686 - Audio tests for .bsewave files don't work
    
    Sat Apr 11 12:23:09 2009  Stefan Westerfeld  <stefan space twc de>
    
    	* bsemain.[hc]*: Added --bse-override-sample-path command line option
    	to override the sample path.
    
    	* bsewave.c: If the file name is specified with a relative path, search
    	for the bsewave file in the sample path; if it is absolute, proceed as
    	usual.
    	Fixes #578686 - Audio tests for .bsewave files don't work

 bse/bsemain.cc |    7 +++++++
 bse/bsemain.h  |    1 +
 bse/bsewave.c  |   28 +++++++++++++++++++++++++++-
 3 files changed, 35 insertions(+), 1 deletions(-)
---
diff --git a/bse/bsemain.cc b/bse/bsemain.cc
index fc2b6c5..524e232 100644
--- a/bse/bsemain.cc
+++ b/bse/bsemain.cc
@@ -70,6 +70,7 @@ static BseMainArgs       default_main_args = {
   NULL,                 // bse_rcfile
   NULL,                 // override_plugin_globs
   NULL,                 // override_script_path
+  NULL,			// override_sample_path
   true,                 // allow_randomization
   false,                // force_fpu
 };
@@ -660,6 +661,12 @@ bse_async_parse_args (gint           *argc_p,
           margs->override_script_path = argv[i];
 	  argv[i] = NULL;
 	}
+      else if (strcmp ("--bse-override-sample-path", argv[i]) == 0 && i + 1 < argc)
+	{
+	  argv[i++] = NULL;
+	  margs->override_sample_path = argv[i];
+	  argv[i] = NULL;
+	}
       else if (strcmp ("--bse-rcfile", argv[i]) == 0 && i + 1 < argc)
 	{
           argv[i++] = NULL;
diff --git a/bse/bsemain.h b/bse/bsemain.h
index ad0a392..13691a7 100644
--- a/bse/bsemain.h
+++ b/bse/bsemain.h
@@ -77,6 +77,7 @@ typedef struct {
   const gchar          *bse_rcfile;
   const gchar          *override_plugin_globs;
   const gchar          *override_script_path;
+  const gchar	       *override_sample_path;
   bool                  allow_randomization;	/* init-value "allow-randomization" - enables non-deterministic behavior */
   bool                  force_fpu;		/* init-value "force-fpu" */
   bool		        load_core_plugins;	/* init-value "load-core-plugins" */
diff --git a/bse/bsewave.c b/bse/bsewave.c
index 3cac5be..2e3b419 100644
--- a/bse/bsewave.c
+++ b/bse/bsewave.c
@@ -22,6 +22,7 @@
 #include "gsldatahandle.h"
 #include "bseserver.h"
 #include "bseloader.h"
+#include "topconfig.h"
 
 #include <string.h>
 
@@ -274,7 +275,32 @@ bse_wave_load_wave_file (BseWave      *self,
 
   bse_wave_clear (self);
 
-  BseWaveFileInfo *fi = bse_wave_file_info_load (file_name, &error);
+  BseWaveFileInfo *fi = NULL;
+
+  if (!g_path_is_absolute (file_name))	  /* resolve relative path using search dir */
+    {
+      char *sample_path;
+      SfiRing *files, *walk;
+      if (bse_main_args->override_sample_path)
+	sample_path = g_strdup (bse_main_args->override_sample_path);
+      else
+	sample_path = g_path_concat (BSE_PATH_SAMPLES, BSE_GCONFIG (sample_path), NULL);
+      files = sfi_file_crawler_list_files (sample_path, file_name, G_FILE_TEST_IS_REGULAR);
+
+      for (walk = files; walk; walk = sfi_ring_walk (files, walk))
+	{
+	  char *fname = walk->data;
+	  if (!fi)
+	    fi = bse_wave_file_info_load (fname, &error);
+	  g_free (fname);
+	}
+      sfi_ring_free (files);
+      g_free (sample_path);
+    }
+  else
+    {
+      fi = bse_wave_file_info_load (file_name, &error);
+    }
   if (fi)
     {
       guint i = 0;



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]