aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--VERSION2
-rw-r--r--app/synthpod_app.c16
-rw-r--r--bin/synthpod_jack.115
-rw-r--r--bin/synthpod_jack.c65
4 files changed, 57 insertions, 41 deletions
diff --git a/VERSION b/VERSION
index 3658a8b8..d8efc7c3 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-0.1.6059
+0.1.6061
diff --git a/app/synthpod_app.c b/app/synthpod_app.c
index f545f12a..07c0ce75 100644
--- a/app/synthpod_app.c
+++ b/app/synthpod_app.c
@@ -650,13 +650,17 @@ _dsp_slave_thread(void *data)
const int num = dsp_slave - dsp_master->dsp_slaves + 1;
//printf("thread: %i\n", num);
- struct sched_param schedp;
- memset(&schedp, 0, sizeof(struct sched_param));
- schedp.sched_priority = app->driver->audio_prio - 1;
-
const pthread_t self = pthread_self();
- if(pthread_setschedparam(self, SCHED_FIFO, &schedp))
- sp_app_log_error(app, "%s: pthread_setschedparam error\n", __func__);
+
+ if(app->driver->audio_prio)
+ {
+ struct sched_param schedp;
+ memset(&schedp, 0, sizeof(struct sched_param));
+ schedp.sched_priority = app->driver->audio_prio - 1;
+
+ if(pthread_setschedparam(self, SCHED_FIFO, &schedp))
+ sp_app_log_error(app, "%s: pthread_setschedparam error\n", __func__);
+ }
if(app->driver->cpu_affinity)
{
diff --git a/bin/synthpod_jack.1 b/bin/synthpod_jack.1
index 108c58e9..7afe906d 100644
--- a/bin/synthpod_jack.1
+++ b/bin/synthpod_jack.1
@@ -66,16 +66,6 @@ Enable CPU affinity
Disable CPU affinity (default)
.HP
-\fB\-w\fR worker-priority
-.IP
-Worker thread realtime priority (60)
-
-.HP
-\fB\-W\fR
-.IP
-Disable worker thread realtime priority
-
-.HP
\fB\-l\fR
.IP
Socket link path (shm:///synthpod), e.g. tcp://*:9090
@@ -86,11 +76,6 @@ Socket link path (shm:///synthpod), e.g. tcp://*:9090
Connect to named JACK daemon
.HP
-\fB\-u\fR client-uuid
-.IP
-Client UUID for JACK session management
-
-.HP
\fB\-s\fR sequence-size
.IP
Minimal byte size of event sequence buffers (8192)
diff --git a/bin/synthpod_jack.c b/bin/synthpod_jack.c
index 252d40be..60a6267f 100644
--- a/bin/synthpod_jack.c
+++ b/bin/synthpod_jack.c
@@ -32,6 +32,7 @@ typedef cpuset_t cpu_set_t;
#include <jack/jack.h>
#include <jack/midiport.h>
#include <jack/transport.h>
+#include <jack/thread.h>
#if defined(JACK_HAS_METADATA_API)
# include <jack/metadata.h>
# include <jack/uuid.h>
@@ -69,7 +70,6 @@ struct _prog_t {
atomic_int kill;
char *server_name;
- char *session_id;
jack_client_t *client;
uint32_t seq_size;
@@ -743,18 +743,49 @@ _xrun(void *data)
}
static int
+_jack_probe_prio(prog_t *handle)
+{
+ jack_options_t opts = JackNullOption | JackNoStartServer;
+ if(handle->server_name)
+ opts |= JackServerName;
+
+ const pid_t pid = getpid();
+
+ char id [32];
+ snprintf(id, sizeof(id), "Syntphod-JACK-%i", pid);
+
+ jack_client_t *client;
+ jack_status_t status;
+ if(!(client = jack_client_open(id, opts, &status,
+ handle->server_name ? handle->server_name : NULL)))
+ {
+ return -1;
+ }
+
+ const int audio_prio = jack_client_real_time_priority(client);
+
+ jack_client_close(client);
+
+ if(audio_prio != -1) // is JACK running with realtime priorities ?
+ {
+ // overwrite audio/worker priorities
+ handle->bin.audio_prio = audio_prio;
+ handle->bin.worker_prio = (audio_prio >= 10) ? (audio_prio - 10) : 0;
+ }
+
+ return 0;
+}
+
+static int
_jack_init(prog_t *handle, const char *id)
{
jack_options_t opts = JackNullOption | JackNoStartServer;
if(handle->server_name)
opts |= JackServerName;
- if(handle->session_id)
- opts |= JackSessionID;
jack_status_t status;
if(!(handle->client = jack_client_open(id, opts, &status,
- handle->server_name ? handle->server_name : handle->session_id,
- handle->server_name ? handle->session_id : NULL)))
+ handle->server_name ? handle->server_name : NULL)))
{
return -1;
}
@@ -967,11 +998,10 @@ main(int argc, char **argv)
bin_t *bin = &handle.bin;
handle.server_name = NULL;
- handle.session_id = NULL;
handle.seq_size = SEQ_SIZE;
- bin->audio_prio = 70; // not used
- bin->worker_prio = 60;
+ bin->audio_prio = 0; // disabled by default
+ bin->worker_prio = 0; // disabled by default
bin->num_slaves = sysconf(_SC_NPROCESSORS_ONLN) - 1;
bin->bad_plugins = false;
bin->has_gui = false;
@@ -986,7 +1016,7 @@ main(int argc, char **argv)
"Released under Artistic License 2.0 by Open Music Kontrollers\n");
int c;
- while((c = getopt(argc, argv, "vhgGkKbBaAw:Wl:n:u:s:c:f:")) != -1)
+ while((c = getopt(argc, argv, "vhgGkKbBaAl:n:s:c:f:")) != -1)
{
switch(c)
{
@@ -1057,21 +1087,12 @@ main(int argc, char **argv)
case 'A':
bin->cpu_affinity = false;
break;
- case 'w':
- bin->worker_prio = atoi(optarg);
- break;
- case 'W':
- bin->worker_prio = 0;
- break;
case 'l':
snprintf(bin->socket_path, sizeof(bin->socket_path), "%s", optarg);
break;
case 'n':
handle.server_name = optarg;
break;
- case 'u':
- handle.session_id = optarg;
- break;
case 's':
handle.seq_size = MAX(SEQ_SIZE, atoi(optarg));
break;
@@ -1083,7 +1104,7 @@ main(int argc, char **argv)
bin->update_rate = atoi(optarg);
break;
case '?':
- if( (optopt == 'n') || (optopt == 'u') || (optopt == 's') || (optopt == 'c')
+ if( (optopt == 'n') || (optopt == 's') || (optopt == 'c')
|| (optopt == 'l') || (optopt == 'f') )
fprintf(stderr, "Option `-%c' requires an argument.\n", optopt);
else if(isprint(optopt))
@@ -1096,6 +1117,12 @@ main(int argc, char **argv)
}
}
+ if(_jack_probe_prio(&handle))
+ {
+ fprintf(stderr, "Unable to probe JACK for thread priorities\n");
+ return -1;
+ }
+
bin_init(bin, 48000); //FIXME
LV2_URID_Map *map = bin->map;