From d78d499505ccdaa2caa02730a5f038d1b156d687 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20M=C3=BCller?= Date: Tue, 19 Mar 2019 00:20:58 +0100 Subject: [PATCH] linuxsampler: Fix build & packing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Andreas Müller --- ...lock_gettime-when-configured-with-di.patch | 71 ++++++++++ ...l-of-snd_pcm_hw_params_set_rate_near.patch | 38 ++++++ ...ics-when-configured-with-disable-asm.patch | 126 ++++++++++++++++++ .../linuxsampler/linuxsampler_2.1.0.bb | 26 +++- .../packagegroups/musicians-world.bb | 1 + 5 files changed, 261 insertions(+), 1 deletion(-) create mode 100644 recipes-musicians/linuxsampler/linuxsampler/0002-RTMath.cpp-use-clock_gettime-when-configured-with-di.patch create mode 100644 recipes-musicians/linuxsampler/linuxsampler/0003-Use-correct-call-of-snd_pcm_hw_params_set_rate_near.patch create mode 100644 recipes-musicians/linuxsampler/linuxsampler/0004-use-c-11-atomics-when-configured-with-disable-asm.patch diff --git a/recipes-musicians/linuxsampler/linuxsampler/0002-RTMath.cpp-use-clock_gettime-when-configured-with-di.patch b/recipes-musicians/linuxsampler/linuxsampler/0002-RTMath.cpp-use-clock_gettime-when-configured-with-di.patch new file mode 100644 index 0000000..160305f --- /dev/null +++ b/recipes-musicians/linuxsampler/linuxsampler/0002-RTMath.cpp-use-clock_gettime-when-configured-with-di.patch @@ -0,0 +1,71 @@ +From 2e0abe2365de2d4a03aabe0784faa6cce827c159 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20M=C3=BCller?= +Date: Mon, 18 Mar 2019 21:48:41 +0100 +Subject: [PATCH] RTMath.cpp: use clock_gettime when configured with + --disable-asm +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Pending + +Signed-off-by: Andreas Müller +--- + src/common/RTMath.cpp | 21 +++++++++------------ + 1 file changed, 9 insertions(+), 12 deletions(-) + +diff --git a/src/common/RTMath.cpp b/src/common/RTMath.cpp +index f228c08..27dc5b0 100644 +--- a/src/common/RTMath.cpp ++++ b/src/common/RTMath.cpp +@@ -38,22 +38,18 @@ typedef uint64_t time_stamp_t; + #endif + + /* +- * Creates a real time stamp for the current moment. Out of efficiency this +- * is implemented in inline assembly for each CPU independently; we currently +- * don't use a generic solution for CPUs that are not yet covered by the +- * assembly code, instead an error message is prompted on compile time, forcing +- * the user to contact us. ++ * Creates a real time stamp for the current moment. + */ + RTMathBase::time_stamp_t RTMathBase::CreateTimeStamp() { +- #if defined(__i386__) || defined(__x86_64__) ++ #if CONFIG_ASM && (defined(__i386__) || defined(__x86_64__)) + uint64_t t; + __asm__ __volatile__ ("rdtsc" : "=A" (t)); + return time_stamp_t(t >> 8); +- #elif defined(__ia64__) ++ #elif CONFIG_ASM && defined(__ia64__) + time_stamp_t t; + __asm__ __volatile__ ("mov %0=ar.itc" : "=r"(t)); + return t; +- #elif defined(__powerpc__) ++ #elif CONFIG_ASM && defined(__powerpc__) + time_stamp_t t; + __asm__ __volatile__ ( + "98: mftb %0\n" +@@ -67,15 +63,16 @@ RTMathBase::time_stamp_t RTMathBase::CreateTimeStamp() { + : "=r" (t) : "i" (0x00000100) + ); + return t; +- #elif defined(__alpha__) ++ #elif CONFIG_ASM && defined(__alpha__) + time_stamp_t t; + __asm__ __volatile__ ("rpcc %0" : "=r"(t)); + return t; + #elif defined(__APPLE__) + return (time_stamp_t) mach_absolute_time(); +- #else // we don't want to use a slow generic solution +- # error "Sorry, LinuxSampler lacks time stamp code for your system." +- # error "Please report this error and the CPU you are using to the LinuxSampler developers mailing list!" ++ #else ++ timespec tp; ++ clock_gettime(CLOCK_MONOTONIC, &tp); ++ return tp.tv_nsec; + #endif + } + +-- +2.20.1 + diff --git a/recipes-musicians/linuxsampler/linuxsampler/0003-Use-correct-call-of-snd_pcm_hw_params_set_rate_near.patch b/recipes-musicians/linuxsampler/linuxsampler/0003-Use-correct-call-of-snd_pcm_hw_params_set_rate_near.patch new file mode 100644 index 0000000..dbc25ac --- /dev/null +++ b/recipes-musicians/linuxsampler/linuxsampler/0003-Use-correct-call-of-snd_pcm_hw_params_set_rate_near.patch @@ -0,0 +1,38 @@ +From 49dce161261712d8c5217e00f08114d4b050bbb1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20M=C3=BCller?= +Date: Mon, 18 Mar 2019 22:04:23 +0100 +Subject: [PATCH] Use correct call of snd_pcm_hw_params_set_rate_near +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +configure does not detect als version due to AC_RUN_IFELSE so hardcode maching +call to snd_pcm_hw_params_set_rate_near. This is the only plac with +alsa-version specific code. + +Upstream-Status: Pending + +Signed-off-by: Andreas Müller +--- + src/drivers/audio/AudioOutputDeviceAlsa.cpp | 4 ---- + 1 file changed, 4 deletions(-) + +diff --git a/src/drivers/audio/AudioOutputDeviceAlsa.cpp b/src/drivers/audio/AudioOutputDeviceAlsa.cpp +index 1953eda..dcf54d8 100644 +--- a/src/drivers/audio/AudioOutputDeviceAlsa.cpp ++++ b/src/drivers/audio/AudioOutputDeviceAlsa.cpp +@@ -572,11 +572,7 @@ namespace LinuxSampler { + + /* Set sample rate. If the exact rate is not supported */ + /* by the hardware, use nearest possible rate. */ +- #if ALSA_MAJOR > 0 + if((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, &uiSamplerate, &dir)) < 0) +- #else +- if((err = snd_pcm_hw_params_set_rate_near(pcm_handle, hwparams, uiSamplerate, &dir)) < 0) +- #endif + { + throw AudioOutputException(String("Error setting sample rate: ") + snd_strerror(err)); + } +-- +2.20.1 + diff --git a/recipes-musicians/linuxsampler/linuxsampler/0004-use-c-11-atomics-when-configured-with-disable-asm.patch b/recipes-musicians/linuxsampler/linuxsampler/0004-use-c-11-atomics-when-configured-with-disable-asm.patch new file mode 100644 index 0000000..62569b6 --- /dev/null +++ b/recipes-musicians/linuxsampler/linuxsampler/0004-use-c-11-atomics-when-configured-with-disable-asm.patch @@ -0,0 +1,126 @@ +From d46974c22d11870123fa2d1de5c75e8f14c08e68 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20M=C3=BCller?= +Date: Mon, 18 Mar 2019 23:36:41 +0100 +Subject: [PATCH] use c++11 atomics when configured with --disable-asm +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Upstream-Status: Pending + +Signed-off-by: Andreas Müller +--- + src/common/ChangeFlagRelaxed.h | 4 ++ + src/common/atomic.h | 54 ++++++++++++++++++++++++++ + src/drivers/midi/VirtualMidiDevice.cpp | 6 +++ + 3 files changed, 64 insertions(+) + +diff --git a/src/common/ChangeFlagRelaxed.h b/src/common/ChangeFlagRelaxed.h +index bf2246f..47fdd91 100644 +--- a/src/common/ChangeFlagRelaxed.h ++++ b/src/common/ChangeFlagRelaxed.h +@@ -20,7 +20,11 @@ + class ChangeFlagRelaxed { + public: + ChangeFlagRelaxed() { ++#if CONFIG_ASM + newval = (atomic_t) ATOMIC_INIT(0); ++#else ++ newval = 0; ++#endif + oldval = 0; + } + +diff --git a/src/common/atomic.h b/src/common/atomic.h +index b1f5c43..4096a60 100644 +--- a/src/common/atomic.h ++++ b/src/common/atomic.h +@@ -38,6 +38,7 @@ + #define CONFIG_SMP /* ... the macro the kernel headers use */ + #endif + ++#if CONFIG_ASM + #if defined(__linux__) || defined(WIN32) || defined(__APPLE__) + #ifdef _ARCH_PPC + +@@ -1287,4 +1288,57 @@ atomic_dec (atomic_t * a) { + } + + #endif /* linux */ ++#else ++ ++#include ++ ++constexpr std::memory_order mem_order = std::memory_order_seq_cst; ++ ++using atomic_t = std::atomic_int; ++ ++#define ATOMIC_INIT(i) { (i) } ++ ++inline ++int ++atomic_read (const atomic_t * a) { ++ return a->load(mem_order); ++} ++ ++inline ++void ++atomic_set (atomic_t * a, int v) { ++ a->store(v, mem_order); ++} ++ ++static __inline__ void atomic_inc(atomic_t *a) ++{ ++ *a++; ++} ++ ++static __inline__ void atomic_dec(atomic_t *a) ++{ ++ *a--; ++} ++ ++static __inline__ void atomic_add(int i, atomic_t *a) ++{ ++ *a += i; ++} ++ ++static __inline__ void atomic_sub(int i, atomic_t *a) ++{ ++ *a -= i; ++} ++ ++static __inline__ int atomic_dec_and_test(atomic_t *a) ++{ ++ return a->fetch_add(1)+1 == 0; ++} ++ ++static __inline__ int atomic_inc_and_test(atomic_t *a) ++{ ++ return a->fetch_sub(1)-1 == 0; ++} ++ ++#endif /* CONFIG_ASM */ + #endif /* __linuxsampler_atomic_h__ */ +diff --git a/src/drivers/midi/VirtualMidiDevice.cpp b/src/drivers/midi/VirtualMidiDevice.cpp +index 78d49af..635d696 100644 +--- a/src/drivers/midi/VirtualMidiDevice.cpp ++++ b/src/drivers/midi/VirtualMidiDevice.cpp +@@ -32,9 +32,15 @@ namespace LinuxSampler { + }; + + VirtualMidiDevice::VirtualMidiDevice() : p(new private_data_t) { ++#if CONFIG_ASM + atomic_t zero = ATOMIC_INIT(0); + atomic_t defaultVelocity = ATOMIC_INIT(127); + atomic_t defaultCCValue = ATOMIC_INIT(0); ++#else ++ int zero = 0; ++ int defaultVelocity = 127; ++ int defaultCCValue = 0; ++#endif + p->notesChanged = zero; + p->ccsChanged = zero; + for (int i = 0; i < MIDI_KEYS; i++) { +-- +2.20.1 + diff --git a/recipes-musicians/linuxsampler/linuxsampler_2.1.0.bb b/recipes-musicians/linuxsampler/linuxsampler_2.1.0.bb index c220899..bad922b 100644 --- a/recipes-musicians/linuxsampler/linuxsampler_2.1.0.bb +++ b/recipes-musicians/linuxsampler/linuxsampler_2.1.0.bb @@ -5,7 +5,7 @@ LIC_FILES_CHKSUM = " \ file://COPYING;md5=0640e0c29fde7334746a009461544030 \ " -inherit autotools pkgconfig +inherit autotools pkgconfig pack_audio_plugins DEPENDS = " \ bison-native \ @@ -19,12 +19,36 @@ DEPENDS = " \ SRC_URI = " \ http://download.linuxsampler.org/packages/${BPN}-${PV}.tar.bz2 \ file://0001-configure.ac-Do-not-try-to-run-code-to-check-for-UNI.patch \ + file://0002-RTMath.cpp-use-clock_gettime-when-configured-with-di.patch \ + file://0003-Use-correct-call-of-snd_pcm_hw_params_set_rate_near.patch \ + file://0004-use-c-11-atomics-when-configured-with-disable-asm.patch \ " SRC_URI[md5sum] = "c57fbd1310e9189ee72acf81e63bf3d5" SRC_URI[sha256sum] = "4e0a49efeae9c26a223094247b7e01108d829a69618492282a203a290fbfbd39" +# arch specific override - default (tested) is ARM -> no assember (ARM assembler is not suppoted) +USE_ASM = "--disable-asm" + EXTRA_OECONF = " \ + ${USE_ASM} \ --enable-unsigned-triang-algo=intmathabs \ --enable-signed-triang-algo=intmathabs \ " +FILES_SOLIBSDEV = "${libdir}/${BPN}/lib*${SOLIBSDEV}" + +PACKAGES =+ "${PN}-standalone ${PN}-tools" +FILES_${PN}-standalone = " \ + ${bindir}/${BPN} \ +" + +FILES_${PN}-tools = " \ + ${bindir}/lscp \ + ${bindir}/ls_instr_script \ +" + +RDEPENDS_${PN}-dssi += "${PN}" +RDEPENDS_${PN}-lv2 += "${PN}" +RDEPENDS_${PN}-vst += "${PN}" +RDEPENDS_${PN}-standalone += "${PN}" + diff --git a/recipes-support/packagegroups/musicians-world.bb b/recipes-support/packagegroups/musicians-world.bb index f51770c..450a028 100644 --- a/recipes-support/packagegroups/musicians-world.bb +++ b/recipes-support/packagegroups/musicians-world.bb @@ -69,6 +69,7 @@ RDEPENDS_${PN} += " \ libmp4v2 \ libsmf \ libxmp \ + linuxsampler-standalone linuxsampler-tools linuxsampler-dssi linuxsampler-lv2 \ \ libgig-bin \ \