# HG changeset patch # User František Kučera # Date 1601494621 -7200 # Node ID 6be3464ccb2bf228306b0fbc1cb565b312a5564b # Parent 65dfbf0494a3488f4eb6b7b6f5aa1d98e287dfbd wait for a port connection diff -r 65dfbf0494a3 -r 6be3464ccb2b src/JackHandler.h --- a/src/JackHandler.h Wed Sep 30 20:54:39 2020 +0200 +++ b/src/JackHandler.h Wed Sep 30 21:37:01 2020 +0200 @@ -96,6 +96,10 @@ int jackError = jack_activate(jackClient); if (jackError) throw JackException(L"Could not activate client."); + + // Wait for a port connection, because it does not make much sense to send MIDI events nowhere: + // TODO: configurable waiting? + while (jack_port_connected(jackPort) == 0) usleep(10000); } void startRelation(const relpipe::common::type::StringX name, std::vector attributes) override { @@ -150,6 +154,7 @@ MidiMessage m; jack_ringbuffer_read(ringBuffer, (char*) &m, sizeof (MidiMessage)); // TODO: send events from the ring buffer to JACK + correct timing + // FIXME: do not block here in the while loop; check frames std::cout << "will process MidiMessage: " << &m << "" << std::endl; // TODO: remove debug message } pthread_cond_wait(&dataReady, &messageThreadLock);