summaryrefslogtreecommitdiff
path: root/libs
diff options
context:
space:
mode:
authorJohn Emmas <johne53@tiscali.co.uk>2014-05-27 14:48:44 +0100
committerJohn Emmas <johne53@tiscali.co.uk>2014-05-27 14:48:44 +0100
commit458d4dc6de6e26c8cf45d197f1db29c19767e6db (patch)
tree49ffe4dab83bf13b6caf10b4896714edbaa46473 /libs
parent5b4cb15dfc6e2ba169fce62cafeab5822a2a7109 (diff)
(Windows) Add support for finding the bundled version of Jack which comes with Mixbus
A few things need to be tested / completed:- 1) The code is currently guarded by #ifdef COMPILER_MSVC. This is just precautionary. If it builds okay with MinGW ,the guard can be removed. 2) Windows Playback and Capture devices almost always have different names. This needs to get accommodated in our Backend dialog (as in Mixbus) 3) Windows Playback and Capture devices will almost always contain spaces. We need to accommodate this when writing to .jackdrc (surround them in quote marks)
Diffstat (limited to 'libs')
-rw-r--r--libs/backends/jack/jack_utils.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/libs/backends/jack/jack_utils.cc b/libs/backends/jack/jack_utils.cc
index 1e74a5315f..fcb0d7a169 100644
--- a/libs/backends/jack/jack_utils.cc
+++ b/libs/backends/jack/jack_utils.cc
@@ -29,6 +29,11 @@
#include <mach-o/dyld.h>
#endif
+#ifdef PLATFORM_WINDOWS
+#include <shobjidl.h> // Needed for
+#include <shlguid.h> // 'IShellLink'
+#endif
+
#ifdef HAVE_PORTAUDIO
#include <portaudio.h>
#endif
@@ -584,6 +589,60 @@ ARDOUR::get_jack_server_dir_paths (vector<std::string>& server_dir_paths)
Searchpath sp(string(g_getenv("PATH")));
#ifdef PLATFORM_WINDOWS
+// N.B. The #define (immediately below) can be safely removed once we know that this code builds okay with mingw
+#ifdef COMPILER_MSVC
+ IShellLinkA *pISL = NULL;
+ IPersistFile *ppf = NULL;
+
+ // Mixbus creates a Windows shortcut giving the location of its
+ // own (bundled) version of Jack. Let's see if that shortcut exists
+ if (SUCCEEDED (CoCreateInstance(CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, IID_IShellLink, (void**)&pISL)))
+ {
+ if (SUCCEEDED (pISL->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf)))
+ {
+ char target_path[MAX_PATH];
+ char shortcut_pathA[MAX_PATH];
+ WCHAR shortcut_pathW[MAX_PATH];
+
+ // Our Windows installer should have created a shortcut to the Jack
+ // server so let's start by finding out what drive it got installed on
+ if (char *env_path = getenv ("windir"))
+ {
+ strcpy (shortcut_pathA, env_path);
+ shortcut_pathA[2] = '\0'; // Gives us just the drive letter and colon
+ }
+ else // Assume 'C:'
+ strcpy (shortcut_pathA, "C:");
+
+ strcat (shortcut_pathA, "\\Program Files (x86)\\Jack\\Start Jack.lnk");
+
+ MultiByteToWideChar (CP_ACP, MB_PRECOMPOSED, shortcut_pathA, -1, shortcut_pathW, MAX_PATH);
+
+ // If it did, load the shortcut into our persistent file
+ if (SUCCEEDED (ppf->Load(shortcut_pathW, 0)))
+ {
+ // Read the target information from the shortcut object
+ if (S_OK == (pISL->GetPath (target_path, MAX_PATH, NULL, SLGP_UNCPRIORITY)))
+ {
+ char *p = strrchr (target_path, '\\');
+
+ if (p)
+ {
+ *p = NULL;
+ sp.push_back (target_path);
+ }
+ }
+ }
+ }
+ }
+
+ if (ppf)
+ ppf->Release();
+
+ if (pISL)
+ pISL->Release();
+#endif
+
gchar *install_dir = g_win32_get_package_installation_directory_of_module (NULL);
if (install_dir) {
sp.push_back (install_dir);