equal
deleted
inserted
replaced
55 * Is passed through the ring buffer |
55 * Is passed through the ring buffer |
56 * from the relpipe-reading thread to the jack-writing thread (callback). |
56 * from the relpipe-reading thread to the jack-writing thread (callback). |
57 */ |
57 */ |
58 struct MidiMessage { |
58 struct MidiMessage { |
59 uint8_t buffer[4096] = {0}; |
59 uint8_t buffer[4096] = {0}; |
60 uint32_t size; |
60 size_t size; |
61 uint32_t time; |
61 jack_nframes_t time; |
62 }; |
62 }; |
63 |
63 |
64 /** |
64 /** |
65 * JACK callbacks (called from the real-time thread) |
65 * JACK callbacks (called from the real-time thread) |
66 */ |
66 */ |
82 for (size_t i = 0; i < queuedMessages && i < frames; i++) { |
82 for (size_t i = 0; i < queuedMessages && i < frames; i++) { |
83 // TODO: correct timing? |
83 // TODO: correct timing? |
84 MidiMessage m; |
84 MidiMessage m; |
85 jack_ringbuffer_read(ringBuffer, (char*) &m, sizeof (MidiMessage)); |
85 jack_ringbuffer_read(ringBuffer, (char*) &m, sizeof (MidiMessage)); |
86 jack_midi_data_t* midiData = jack_midi_event_reserve(jackPortBuffer, m.time, m.size); |
86 jack_midi_data_t* midiData = jack_midi_event_reserve(jackPortBuffer, m.time, m.size); |
87 memcpy(midiData, m.buffer, m.size); |
87 if (midiData) memcpy(midiData, m.buffer, m.size); |
|
88 else /* error: not enough space TODO: store and send later */; |
88 } |
89 } |
89 |
90 |
90 if (pthread_mutex_trylock(&processingLock) == 0) { |
91 if (pthread_mutex_trylock(&processingLock) == 0) { |
91 pthread_cond_signal(&processingDone); |
92 pthread_cond_signal(&processingDone); |
92 pthread_mutex_unlock(&processingLock); |
93 pthread_mutex_unlock(&processingLock); |