summary refs log tree commit diff
path: root/pkgs/applications/audio/linuxsampler/linuxsampler_lv2_sfz_fix.diff
blob: 114726db19d63540d7274f802bd58b6914a7d9b6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
Index: linuxsampler-r2359/src/hostplugins/lv2/PluginLv2.cpp
===================================================================
--- linuxsampler-r2359/src/hostplugins/lv2/PluginLv2.cpp	(revision 2359)
+++ linuxsampler-r2359/src/hostplugins/lv2/PluginLv2.cpp	(working copy)
@@ -18,6 +18,8 @@
  *   MA  02110-1301  USA                                                   *
  ***************************************************************************/
 
+#define _BSD_SOURCE 1  /* for realpath() */
+
 #include <algorithm>
 #include <cassert>
 #include <cstdio>
@@ -118,6 +120,23 @@
         dmsg(2, ("linuxsampler: Deactivate\n"));
     }
 
+    static String RealPath(const String& path)
+    {
+        String out   = path;
+        char*  cpath = NULL;
+#ifdef _WIN32
+        cpath = (char*)malloc(MAX_PATH);
+        GetFullPathName(path.c_str(), MAX_PATH, cpath, NULL);
+#else
+        cpath = realpath(path.c_str(), NULL);
+#endif
+        if (cpath) {
+            out = cpath;
+            free(cpath);
+        }
+        return out;
+    }
+
     String PluginLv2::PathToState(const String& path) {
         if (MapPath) {
             char* cstr = MapPath->abstract_path(MapPath->handle, path.c_str());
@@ -131,9 +150,10 @@
     String PluginLv2::PathFromState(const String& path) {
         if (MapPath) {
             char* cstr = MapPath->absolute_path(MapPath->handle, path.c_str());
-            const String abstract_path(cstr);
+            // Resolve symbolic links so SFZ sample paths load correctly
+            const String absolute_path(RealPath(cstr));
             free(cstr);
-            return abstract_path;
+            return absolute_path;
         }
         return path;
     }