equal
deleted
inserted
replaced
94 |
94 |
95 if (mlockall(MCL_CURRENT | MCL_FUTURE)) fwprintf(stderr, L"Warning: Can not lock memory.\n"); |
95 if (mlockall(MCL_CURRENT | MCL_FUTURE)) fwprintf(stderr, L"Warning: Can not lock memory.\n"); |
96 |
96 |
97 int jackError = jack_activate(jackClient); |
97 int jackError = jack_activate(jackClient); |
98 if (jackError) throw JackException(L"Could not activate client."); |
98 if (jackError) throw JackException(L"Could not activate client."); |
|
99 |
|
100 // Wait for a port connection, because it does not make much sense to send MIDI events nowhere: |
|
101 // TODO: configurable waiting? |
|
102 while (jack_port_connected(jackPort) == 0) usleep(10000); |
99 } |
103 } |
100 |
104 |
101 void startRelation(const relpipe::common::type::StringX name, std::vector<relpipe::reader::handlers::AttributeMetadata> attributes) override { |
105 void startRelation(const relpipe::common::type::StringX name, std::vector<relpipe::reader::handlers::AttributeMetadata> attributes) override { |
102 // TODO: validate metadata and prepare attribute mappings (names and types are important, order does not matter) |
106 // TODO: validate metadata and prepare attribute mappings (names and types are important, order does not matter) |
103 |
107 |
148 const size_t queuedMessages = jack_ringbuffer_read_space(ringBuffer) / sizeof (MidiMessage); |
152 const size_t queuedMessages = jack_ringbuffer_read_space(ringBuffer) / sizeof (MidiMessage); |
149 for (size_t i = 0; i < queuedMessages; ++i) { |
153 for (size_t i = 0; i < queuedMessages; ++i) { |
150 MidiMessage m; |
154 MidiMessage m; |
151 jack_ringbuffer_read(ringBuffer, (char*) &m, sizeof (MidiMessage)); |
155 jack_ringbuffer_read(ringBuffer, (char*) &m, sizeof (MidiMessage)); |
152 // TODO: send events from the ring buffer to JACK + correct timing |
156 // TODO: send events from the ring buffer to JACK + correct timing |
|
157 // FIXME: do not block here in the while loop; check frames |
153 std::cout << "will process MidiMessage: " << &m << "" << std::endl; // TODO: remove debug message |
158 std::cout << "will process MidiMessage: " << &m << "" << std::endl; // TODO: remove debug message |
154 } |
159 } |
155 pthread_cond_wait(&dataReady, &messageThreadLock); |
160 pthread_cond_wait(&dataReady, &messageThreadLock); |
156 } |
161 } |
157 pthread_mutex_unlock(&messageThreadLock); |
162 pthread_mutex_unlock(&messageThreadLock); |