commit 5be30e2e3e064ecd9b5fd1ee41826e2d091ce605
parent e84dadbe2bac425b27c187d2e9f90c32872fb92b
Author: fundamental <mark.d.mccurry@gmail.com>
Date: Fri, 29 May 2015 18:24:07 -0400
Fix Jack Quick Detect
Diffstat:
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/Nio/Nio.cpp b/src/Nio/Nio.cpp
@@ -5,6 +5,7 @@
#include "MidiIn.h"
#include "AudioOut.h"
#include "WavEngine.h"
+#include <cstring>
#include <iostream>
#include <algorithm>
using std::string;
@@ -118,9 +119,18 @@ string Nio::getSink()
#include <jack/jack.h>
void Nio::preferedSampleRate(unsigned &rate)
{
- //XXX hello non portable code
- if(system("ps aux | grep jack"))
+#if __linux__
+ //avoid checking in with jack if it's off
+ FILE *ps = popen("ps aux", "r");
+ char buffer[4096];
+ while(fgets(buffer, sizeof(buffer), ps))
+ if(strstr(buffer, "jack"))
+ break;
+ fclose(ps);
+
+ if(!strstr(buffer, "jack"))
return;
+#endif
jack_client_t *client = jack_client_open("temp-client",
JackNoStartServer, 0);