[Jack-Devel] Fwd: Possible error codes for jack_midi_event_get()?
dev at open-music-kontrollers.ch
Sat Jul 28 20:21:59 CEST 2018
On 28.07.2018 16:55, Matthias Geier wrote:
> Dear list.
> I'm the author of one of the Python bindings for JACK:
> I was a bit lazy when implementing a generator function that's
> supposed to yield all incoming MIDI events one-by-one.
> Here's the code if somebody is interested (it's using CFFI and the
> _lib object is a wrapper for the JACK API):
> def incoming_midi_events(self):
> event = self._event
> buf = _lib.jack_port_get_buffer(
> self._ptr, self._client.blocksize)
> for i in range(_lib.jack_midi_get_event_count(buf)):
> err = _lib.jack_midi_event_get(event, buf, i)
> # TODO: proper error handling if this ever happens:
> assert not err, err
> yield event.time, _ffi.buffer(event.buffer, event.size)
> As you can see, I didn't check the return value of
> jack_midi_event_get(), I just added an "assert" statement hoping that
> somebody would report it if the call to jack_midi_event_get() would
> ever fail.
> I didn't hear anything for a long time, but recently I got a bug
> report where the assertion was violated:
> This shows that jack_midi_event_get() can raise an error, even if I
> check with jack_midi_get_event_count() beforehand.
> My question is now: how should I react to this error?
For JACK1 error is only returned if midi_event_index >= midi_event_count .
For JACK2 the same is true; additionally it can fail if the MIDI port buffer is
invalid (whatever that means...) .
> Shall I ...
> * discard the current event and continue reading further events?
> * discard the current and all following events in this block?
> * raise an error?
> * do something else?
Well, there is no valid event, so ignore it ?
> Can I guarantee that no incoming MIDI events get lost?
MIDI events can only get lost while multiplexed down from multiple ports into
one (and the latter can not take them all), iirc.
> Another related question: what error code is supposed to be returned?
> The documentation
> mentions ENODATA, but according to my bug report, ENOBUFS (-105) was
> Is this a bug in JACK or an omission in the documentation?
It is in the documentation, that it can fail .
> I don't know which JACK version was used, the OS was Ubuntu 18.04 LTS 64 bits.
More information about the Jackaudio