Cannot build: snd_seq_ump_ev_clear was not declared in this scope
Building on Linux I am getting an error with midi2usb. Possibly related to #7. I have ALSA v1.2.10. Was there a change in v1.2.11 that needs to be accounted for to be compatible with both versions? See https://www.alsa-project.org/wiki/Detailed_changes_v1.2.10_v1.2.11#Sequencer_API
make: Entering directory '/REDACTED/MIDI2.0Workbench/node_modules/usb_midi_2/build'
CXX(target) Release/obj.target/ALSA/alsabindings.o
../alsabindings.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE get_UMP_Endpoints(Nan::NAN_METHOD_ARGS_TYPE)’:
../alsabindings.cc:202:13: warning: unused variable ‘errEP’ [-Wunused-variable]
int errEP = snd_seq_get_ump_endpoint_info(seq, client, ep);
^~~~~
../alsabindings.cc:262:14: warning: unused variable ‘err’ [-Wunused-variable]
int err = snd_seq_connect_from(seq, localPort, client, portNum);
^~~
../alsabindings.cc: In function ‘Nan::NAN_METHOD_RETURN_TYPE sendUMP(Nan::NAN_METHOD_ARGS_TYPE)’:
../alsabindings.cc:373:5: error: ‘snd_seq_ump_ev_clear’ was not declared in this scope
snd_seq_ump_ev_clear(&ev);
^~~~~~~~~~~~~~~~~~~~
../alsabindings.cc:373:5: note: suggested alternative: ‘snd_seq_ev_clear’
snd_seq_ump_ev_clear(&ev);
^~~~~~~~~~~~~~~~~~~~
snd_seq_ev_clear
../alsabindings.cc:392:9: warning: unused variable ‘senRes’ [-Wunused-variable]
int senRes = snd_seq_ump_event_output(seq, &ev);
^~~~~~
make: *** [ALSA.target.mk:108: Release/obj.target/ALSA/alsabindings.o] Error 1
make: Leaving directory '/REDACTED/MIDI2.0Workbench/node_modules/usb_midi_2/build'
Looks like we could use SND_LIB_MAJOR/SND_LIB_MINOR/SND_LIB_SUBMINOR to find the version from alsa-lib's version.h:
https://github.com/alsa-project/alsa-lib/blob/f70653fda79742cd1ff93e7a521ae3a333d21882/include/Makefile.am#L82-L101
@DaAwesomeP You are correct that the snd_seq_ump_ev_clear waas only added in 1.2.11 :/ I will try adding some checks for this.
@DaAwesomeP if you put
#ifdef SND_LIB_SUBMINOR => 11
snd_seq_ump_ev_clear(&ev);
#endif
in /midi2usb/alsabindings.cc on line 373
Does this fix your compile issue?
I was able to get it to compile by swapping snd_seq_ump_ev_clear for snd_seq_ev_clear on that line. I'll try your specific patch tomorrow! Thanks!
slight improvement:
#ifdef SND_LIB_MAJOR > 1 || (SND_LIB_MAJOR == 1 && (SND_LIB_MINOR > 2 || (SND_LIB_MINOR == 2 && SND_LIB_SUBMINOR >= 11)))
snd_seq_ump_ev_clear(&ev);
#else
snd_seq_ev_clear(&ev);
#endif
I changed #ifdef to #if and it works! Thanks! I only tested on my older ALSA version.
I also needed to update node-gyp (I tried 11.1.0) in both /package.json and /midi2usb/package.json to get it to build.