I have an application using JACK MIDI under Linux. It works perfectly on 32 bit machines, but on my new one, which is 64 bits, I get event loss all the time.
I checked:
jack_ringbuffer_read
, they are OK (valid 2-3 bytes MIDI messages);midi_out_port
and client
, they are OK (non-null) and appearing on my JACK port list;Here's part of the code:
#define MidiMessageSize 3
jack_client_t* client;
jack_port_t* midi_out_port;
char current_message[MidiMessageSize];
jack_ringbuffer_t* midi_rb;
int process (jack_nframes_t nframes, void *arg)
{
void* output_buffer = jack_port_get_buffer(midi_out_port, nframes);
jack_midi_clear_buffer(output_buffer);
int read_space = jack_ringbuffer_read_space(midi_rb);
if (read_space == 0) return 0;
int i;
for (i = 0; i < read_space; i += MidiMessageSize)
{
jack_ringbuffer_read(midi_rb, current_message, MidiMessageSize);
jack_midi_event_write(output_buffer, i/MidiMessageSize,
(jack_midi_data_t*)current_message, MidiMessageSize);
if (jack_midi_get_lost_event_count(midi_out_port)) {
printf("Lost\n"); // I get here always
}
}
jack_ringbuffer_reset(midi_rb);
return 0;
}
What may be wrong?
Thanks,
Strangely JACK (last version) is sending all midi events right, but jack_midi_get_lost_event_count
is always returning me 1. Just ignored it and now my code is working.
Still this don't happen in 32 bit, but anyway now it's working.