1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61
|
Description: Add function missing in OSS-sALSA to fix non-Linux compile;
fixup int vs. ssize_t issue in related code to ensure it will work.
Author: mirabilos <tg@debian.org>
Forwarded: not-needed
Justification: Workaround for bug in another package, Debian-specific
Bug-Debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=870787
--- a/mscore/mididriver.cpp
+++ b/mscore/mididriver.cpp
@@ -101,6 +101,28 @@ bool Port::operator<(const Port& p) cons
#include "alsa.h"
#include "alsamidi.h"
+// The following is a Debian-specific hack which is likely to
+// not work forever, but needed right now: on kfreebsd and hurd,
+// we do not have ALSA but OSS provides the salsa compatibility
+// layer, which currently lacks a single, trivial function. We
+// need to distinguish salsa from ALSA (hard because the former
+// use, in Debian, the latter’s includes); one hackish way is
+// to use the reported library version as salsa still reports
+// version 1.0.x whereas ALSA on stretch shows 1.1.x — jessie
+// also has 1.0.x, but we still can simply inline the gist as
+// the implementation is identical across OSS/jessie/buster.
+// This is now https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=870787
+#if (SND_LIB_MAJOR < 2) && (SND_LIB_MINOR < 1)
+#define snd_seq_event_length(ev) __extension__({ \
+ ssize_t snd_seq_event_length__len; \
+ \
+ snd_seq_event_length__len = sizeof(snd_seq_event_t); \
+ if (snd_seq_ev_is_variable(ev)) \
+ snd_seq_event_length__len += ev->data.ext.len; \
+ (snd_seq_event_length__len); \
+})
+#endif
+
namespace Ms {
static const unsigned int inCap = SND_SEQ_PORT_CAP_SUBS_READ;
static const unsigned int outCap = SND_SEQ_PORT_CAP_SUBS_WRITE;
@@ -532,11 +554,11 @@ void AlsaMidiDriver::write(const Event&
bool AlsaMidiDriver::putEvent(snd_seq_event_t* event)
{
- int error;
+ ssize_t error;
do {
error = snd_seq_event_output_direct(alsaSeq, event);
- int len = snd_seq_event_length(event);
+ ssize_t len = snd_seq_event_length(event);
if (error == len) {
return false;
}
@@ -551,7 +573,7 @@ bool AlsaMidiDriver::putEvent(snd_seq_ev
}
}
else
- qDebug("MidiAlsaDevice::putEvent(): midi write returns %d, expected %d: %s",
+ qDebug("MidiAlsaDevice::putEvent(): midi write returns %zd, expected %zd: %s",
error, len, snd_strerror(error));
} while (error == -12);
return true;
|