summaryrefslogtreecommitdiff
path: root/linux
diff options
context:
space:
mode:
authorfalkTX <falktx@falktx.com>2019-10-05 21:17:42 +0100
committerfalkTX <falktx@falktx.com>2019-10-05 21:17:42 +0100
commitc8fd3f6a0f6f6c34cf34572eb8947aed05075148 (patch)
tree6b8b4fd9f5c274343572f3aec6eded388eddaebd /linux
parentfdfe11cf96ef0204dd8be1f23c4cb1df6bdcc69a (diff)
downloadjack2-c8fd3f6a0f6f6c34cf34572eb8947aed05075148.tar.gz
Set "seq" alsa midi driver to maximum resolution possible
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat (limited to 'linux')
-rw-r--r--linux/alsa/alsa_seqmidi.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/linux/alsa/alsa_seqmidi.c b/linux/alsa/alsa_seqmidi.c
index 96c18566..a59e3e82 100644
--- a/linux/alsa/alsa_seqmidi.c
+++ b/linux/alsa/alsa_seqmidi.c
@@ -47,6 +47,7 @@
#include <pthread.h>
#include <time.h>
#include <ctype.h>
+#include <limits.h>
#include "midiport.h"
#include "ringbuffer.h"
@@ -95,6 +96,7 @@ typedef struct alsa_seqmidi {
jack_client_t *jack;
snd_seq_t *seq;
+ snd_seq_queue_timer_t* timer;
int client_id;
int port_id;
int queue;
@@ -275,6 +277,10 @@ int alsa_seqmidi_attach(alsa_midi_t *m)
error_log("failed to open alsa seq");
return err;
}
+ if ((err = snd_seq_queue_timer_malloc(&self->timer)) < 0) {
+ error_log("failed to allocate timer");
+ return err;
+ }
snd_seq_set_client_name(self->seq, self->alsa_name);
self->port_id = snd_seq_create_simple_port(self->seq, "port",
SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_WRITE
@@ -284,8 +290,17 @@ int alsa_seqmidi_attach(alsa_midi_t *m)
,SND_SEQ_PORT_TYPE_APPLICATION);
self->client_id = snd_seq_client_id(self->seq);
- self->queue = snd_seq_alloc_queue(self->seq);
- snd_seq_start_queue(self->seq, self->queue, 0);
+ self->queue = snd_seq_alloc_queue(self->seq);
+
+ // set high resolution
+ if (snd_seq_get_queue_timer(self->seq, self->queue, self->timer) == 0) {
+ snd_seq_queue_timer_set_resolution(self->timer, UINT_MAX);
+ snd_seq_set_queue_timer(self->seq, self->queue, self->timer);
+ } else {
+ error_log("failed to set alsa timer in high resolution");
+ }
+
+ snd_seq_start_queue(self->seq, self->queue, 0);
stream_attach(self, PORT_INPUT);
stream_attach(self, PORT_OUTPUT);
@@ -313,6 +328,8 @@ int alsa_seqmidi_detach(alsa_midi_t *m)
stream_detach(self, PORT_INPUT);
stream_detach(self, PORT_OUTPUT);
+ snd_seq_queue_timer_free(self->timer);
+
snd_seq_close(self->seq);
self->seq = NULL;