From cc75798572d48e4ca6b3419cc9ea1ded1451a84f Mon Sep 17 00:00:00 2001 From: KO Myung-Hun Date: Tue, 14 Sep 2021 20:15:25 +0900 Subject: [PATCH] Import fluidsynth v2.2.3 --- .azure/azure-pipelines-mac.yml | 18 ++- .github/workflows/linux.yml | 16 +-- .obs/workflows.yml | 5 + AUTHORS | 1 + CMakeLists.txt | 30 +++-- contrib/baselibs.conf | 1 + contrib/debian.changelog | 23 ++++ contrib/debian.compat | 1 + contrib/debian.control | 34 ++++++ contrib/debian.copyright | 30 +++++ contrib/debian.fluidsynth.install | 2 + contrib/debian.libfluidsynth-dev.install | 3 + contrib/debian.libfluidsynth1.install | 1 + contrib/debian.rules | 98 +++++++++++++++ contrib/debian.series | 0 contrib/fluidsynth.dsc | 8 ++ contrib/fluidsynth.spec | 142 ++++++++++++++++++++++ doc/fluidsettings.xml | 9 ++ doc/fluidsynth-v20-devdoc.txt | 4 +- fluidsynth.spec.in | 76 ------------ include/fluidsynth/sfont.h | 2 +- src/bindings/fluid_ladspa.c | 13 +- src/config.cmake | 3 + src/drivers/fluid_coreaudio.c | 16 +++ src/drivers/fluid_oboe.cpp | 145 ++++++++++++++++------- src/utils/fluid_sys.h | 3 + 26 files changed, 535 insertions(+), 149 deletions(-) create mode 100644 .obs/workflows.yml create mode 100644 contrib/baselibs.conf create mode 100644 contrib/debian.changelog create mode 100644 contrib/debian.compat create mode 100644 contrib/debian.control create mode 100644 contrib/debian.copyright create mode 100644 contrib/debian.fluidsynth.install create mode 100644 contrib/debian.libfluidsynth-dev.install create mode 100644 contrib/debian.libfluidsynth1.install create mode 100644 contrib/debian.rules create mode 100644 contrib/debian.series create mode 100644 contrib/fluidsynth.dsc create mode 100644 contrib/fluidsynth.spec delete mode 100644 fluidsynth.spec.in diff --git a/.azure/azure-pipelines-mac.yml b/.azure/azure-pipelines-mac.yml index 64a6c66..18b87de 100644 --- a/.azure/azure-pipelines-mac.yml +++ b/.azure/azure-pipelines-mac.yml @@ -15,23 +15,35 @@ trigger: jobs: - job: macOS + strategy: + matrix: + 10_14: + imageName: 'macOS-10.14' + 10_15: + imageName: 'macOS-10.15' + 11_0: + imageName: 'macos-11' + pool: - vmImage: 'macOS-10.14' + vmImage: $(imageName) # recommended by https://github.com/Homebrew/brew/issues/2491#issuecomment-294207661 # brew update || brew update # brew upgrade $PACKAGES steps: - script: | + set -ex PACKAGES="glib gobject-introspection libsndfile pkg-config jack dbus-glib pulseaudio portaudio sdl2 libomp" brew install $PACKAGES displayName: 'Prerequisites' - script: | + set -ex mkdir build && cd build export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig" cmake -Werror=dev -DCMAKE_INSTALL_PREFIX=$(Build.ArtifactStagingDirectory) -DCMAKE_BUILD_TYPE=Release -DCMAKE_VERBOSE_MAKEFILE=1 -DNO_GUI=1 .. - make -j`nproc` + make -j3 displayName: 'Compile fluidsynth' - script: | + set -ex cd build || exit -1 - make -j`nproc` check || exit -1 + make -j3 check || exit -1 displayName: 'Execute Unittests' diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index 19f6a63..f9fd428 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -25,26 +25,22 @@ jobs: matrix: CC: [""] CXX: [""] - CMAKE_FLAGS: ["-Denable-profiling=1","-Denable-floats=1 -Denable-profiling=1","-Denable-floats=1","-Denable-trap-on-fpe=1","-Denable-fpe-check=1","-Denable-ipv6=0","-Denable-network=0","-Denable-aufile=0","-DBUILD_SHARED_LIBS=0","-Denable-ubsan=1 -Denable-debug=1"] + CMAKE_FLAGS: ["-Denable-profiling=1","-Denable-floats=1 -Denable-profiling=1","-Denable-floats=1","-Denable-trap-on-fpe=1","-Denable-fpe-check=1","-Denable-ipv6=0","-Denable-network=0","-Denable-aufile=0","-DBUILD_SHARED_LIBS=0","-Denable-ubsan=1 -Denable-debug=1", "-Denable-debug=1 -DCMAKE_C_FLAGS_DEBUG=-fuse-ld=gold"] include: - - CC: "gcc-7" - CXX: "g++-7" - CMAKE_FLAGS: "" - - CC: "gcc-8" - CXX: "g++-8" - CMAKE_FLAGS: "-Denable-debug=1 -DCMAKE_C_FLAGS_DEBUG=-fuse-ld=gold" - CC: "clang-7" CXX: "clang++-7" CMAKE_FLAGS: "" - CC: "clang-8" CXX: "clang++-8" CMAKE_FLAGS: "" - - CC: "clang-9" - CXX: "clang++-9" - CMAKE_FLAGS: "" - CC: "clang-10" CXX: "clang++-10" CMAKE_FLAGS: "" + - CC: "clang-12" + CXX: "clang++-12" + CMAKE_FLAGS: "" +# clang9 is covered by openSUSE Leap 15.2 +# clang11 is covered by openSUSE Leap 15.3 steps: - uses: actions/checkout@v2 diff --git a/.obs/workflows.yml b/.obs/workflows.yml new file mode 100644 index 0000000..afde3e9 --- /dev/null +++ b/.obs/workflows.yml @@ -0,0 +1,5 @@ +workflow: + steps: + - branch_package: + source_project: home:derselbst:anmp + source_package: fluidsynth diff --git a/AUTHORS b/AUTHORS index 14fc45b..0b20745 100644 --- a/AUTHORS +++ b/AUTHORS @@ -152,3 +152,4 @@ Marcus Weseloh Jean-jacques Ceresa Vladimir Davidovich Tamás Korodi +Evan Miller diff --git a/CMakeLists.txt b/CMakeLists.txt index d029336..8b6994b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,7 @@ if(POLICY CMP0091) endif() project ( FluidSynth C CXX ) -set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_admin ) +list( APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake_admin ) # FluidSynth package name set ( PACKAGE "fluidsynth" ) @@ -38,7 +38,7 @@ set ( PACKAGE "fluidsynth" ) # FluidSynth package version set ( FLUIDSYNTH_VERSION_MAJOR 2 ) set ( FLUIDSYNTH_VERSION_MINOR 2 ) -set ( FLUIDSYNTH_VERSION_MICRO 2 ) +set ( FLUIDSYNTH_VERSION_MICRO 3 ) set ( VERSION "${FLUIDSYNTH_VERSION_MAJOR}.${FLUIDSYNTH_VERSION_MINOR}.${FLUIDSYNTH_VERSION_MICRO}" ) set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" ) @@ -53,7 +53,7 @@ set ( FLUIDSYNTH_VERSION "\"${VERSION}\"" ) # This is not exactly the same algorithm as the libtool one, but the results are the same. set ( LIB_VERSION_CURRENT 3 ) set ( LIB_VERSION_AGE 0 ) -set ( LIB_VERSION_REVISION 2 ) +set ( LIB_VERSION_REVISION 3 ) set ( LIB_VERSION_INFO "${LIB_VERSION_CURRENT}.${LIB_VERSION_AGE}.${LIB_VERSION_REVISION}" ) @@ -200,12 +200,12 @@ unset ( FLUID_LIBS CACHE ) unset ( ENABLE_UBSAN CACHE ) if ( CMAKE_COMPILER_IS_GNUCC OR CMAKE_C_COMPILER_ID MATCHES "Clang" OR CMAKE_C_COMPILER_ID STREQUAL "Intel" ) - if ( NOT APPLE AND NOT OS2 ) + if ( NOT APPLE AND NOT OS2 AND NOT EMSCRIPTEN ) set ( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--as-needed" ) set ( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" ) - endif ( NOT APPLE AND NOT OS2 ) + endif ( NOT APPLE AND NOT OS2 AND NOT EMSCRIPTEN ) # define some warning flags set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -W -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wno-unused-parameter -Wdeclaration-after-statement -Werror=implicit-function-declaration" ) @@ -774,6 +774,18 @@ if ( enable-ipv6 ) endif ( HAVE_INETNTOP ) endif ( enable-ipv6 ) +unset ( HAVE_SOCKLEN_T CACHE ) +set ( CMAKE_EXTRA_INCLUDE_FILES_SAVE ${CMAKE_EXTRA_INCLUDE_FILES} ) +if ( WIN32 ) + set ( CMAKE_EXTRA_INCLUDE_FILES "winsock2.h;ws2tcpip.h" ) +else ( WIN32 ) + set ( CMAKE_EXTRA_INCLUDE_FILES sys/socket.h ) +endif ( WIN32 ) +check_type_size ( socklen_t SOCKLEN_T ) +set ( CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES_SAVE} ) +if ( HAVE_SOCKLEN_T ) + set ( HAVE_SOCKLEN_T 1 ) +endif ( HAVE_SOCKLEN_T ) # General configuration file configure_file ( ${CMAKE_SOURCE_DIR}/src/config.cmake @@ -816,7 +828,7 @@ else () set ( includedir "\${prefix}/${INCLUDE_INSTALL_DIR}" ) endif () -if ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.12.0" ) +if ( CMAKE_VERSION VERSION_EQUAL "3.12.0" OR CMAKE_VERSION VERSION_GREATER "3.12.0" ) # retrieve all the private libs we depend on get_target_property ( LIBS_PRIVATE libfluidsynth INTERFACE_LINK_LIBRARIES) # make a copy @@ -837,7 +849,7 @@ else () set ( LIBS_PRIVATE "" ) set ( LIBS_PRIVATE_WITH_PATH "" ) message ( DEPRECATION "Your version of CMake is old. A complete pkg-config file can not created. Get cmake 3.13.3 or newer." ) -endif ( CMAKE_VERSION VERSION_GREATER_EQUAL "3.12.0" ) +endif ( CMAKE_VERSION VERSION_EQUAL "3.12.0" OR CMAKE_VERSION VERSION_GREATER "3.12.0" ) configure_file ( fluidsynth.pc.in ${CMAKE_BINARY_DIR}/fluidsynth.pc IMMEDIATE @ONLY ) @@ -846,10 +858,6 @@ install ( FILES ${CMAKE_BINARY_DIR}/fluidsynth.pc # Extra targets for Unix build environments if ( UNIX ) - # RPM spec - configure_file ( fluidsynth.spec.in - ${CMAKE_BINARY_DIR}/fluidsynth.spec IMMEDIATE @ONLY ) - if ( DEFINED FLUID_DAEMON_ENV_FILE) configure_file ( fluidsynth.service.in ${CMAKE_BINARY_DIR}/fluidsynth.service @ONLY ) diff --git a/contrib/baselibs.conf b/contrib/baselibs.conf new file mode 100644 index 0000000..7fbcb00 --- /dev/null +++ b/contrib/baselibs.conf @@ -0,0 +1 @@ +libfluidsynth2 diff --git a/contrib/debian.changelog b/contrib/debian.changelog new file mode 100644 index 0000000..ce8d307 --- /dev/null +++ b/contrib/debian.changelog @@ -0,0 +1,23 @@ +fluidsynth (1.1.8-1) unstable; urgency=low + + - Update to version 1.1.8: + * fix build against glib < 2.30 (#202) + * fix dsound audio driver on windows (#215) + * fix a bug around `synth.audio-groups` setting, which caused improper multi-channel rendering (#225) + * cmake 3.0.2 is now required + * compilation with clang is now possible + * build fixes on OS/2 (thanks to @komh) + + -- Tom Moebert Fri, 13 Oct 2017 15:53:00 +0000 + +fluidsynth (1.1.7-1) unstable; urgency=low + + * OBS snapshot. + + -- Rui Nuno Capela Tue, 5 Sep 2017 20:00:00 +0000 + +fluidsynth (1.1.6-1) unstable; urgency=low + + * OBS snapshot. + + -- Rui Nuno Capela Sun, 19 Aug 2012 23:45:01 +0000 diff --git a/contrib/debian.compat b/contrib/debian.compat new file mode 100644 index 0000000..ec63514 --- /dev/null +++ b/contrib/debian.compat @@ -0,0 +1 @@ +9 diff --git a/contrib/debian.control b/contrib/debian.control new file mode 100644 index 0000000..f2b7c87 --- /dev/null +++ b/contrib/debian.control @@ -0,0 +1,34 @@ +Source: fluidsynth +Priority: optional +Section: sound +Maintainer: Rui Nuno Capela +Build-Depends: debhelper (>= 5.0.0), cmake, pkg-config, libdb-dev, libjack-dev, libasound2-dev, + libsndfile-dev, libglib2.0-dev +Standards-Version: 3.7.2 + +Package: libfluidsynth1 +Section: libs +Architecture: any +Depends: ${shlibs:Depends}, ${misc:Depends} +Description: FluidSynth is a real-time software synthesizer + FluidSynth is a real-time software synthesizer based on + the SoundFont 2 specifications. + +Package: libfluidsynth-dev +Section: libdevel +Architecture: any +Depends: libfluidsynth1 (= ${source:Version}) +Description: FluidSynth is a real-time software synthesizer + FluidSynth is a real-time software synthesizer based on + the SoundFont 2 specifications. + This package contains the header file required for compiling + hosts and plugins. + +Package: fluidsynth +Section: sound +Architecture: any +Depends: libfluidsynth1 (= ${source:Version}) +Description: FluidSynth is a real-time software synthesizer + FluidSynth is a real-time software synthesizer based on + the SoundFont 2 specifications. + This package contains the command-line utilities. diff --git a/contrib/debian.copyright b/contrib/debian.copyright new file mode 100644 index 0000000..0ef4301 --- /dev/null +++ b/contrib/debian.copyright @@ -0,0 +1,30 @@ +This package was debianized by Rui Nuno Capela on +Mon, 25 Jun 2007 10:42:40 +0100. + +It was downloaded from http://www.fluidsynth.org + +Upstream Author: Rui Nuno Capela + +Copyright: + + Copyright (C) 2003-2015, rncbc aka Rui Nuno Capela. All rights reserved. + +License: + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + as published by the Free Software Foundation; either version 2 + of the License, or (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +The Debian packaging is (C) 2007-2013, Rui Nuno Capela and +is licensed under the GPL, see `/usr/share/common-licenses/GPL'. + diff --git a/contrib/debian.fluidsynth.install b/contrib/debian.fluidsynth.install new file mode 100644 index 0000000..6b70198 --- /dev/null +++ b/contrib/debian.fluidsynth.install @@ -0,0 +1,2 @@ +debian/tmp/usr/bin/* +debian/tmp/usr/share/* diff --git a/contrib/debian.libfluidsynth-dev.install b/contrib/debian.libfluidsynth-dev.install new file mode 100644 index 0000000..e2813ff --- /dev/null +++ b/contrib/debian.libfluidsynth-dev.install @@ -0,0 +1,3 @@ +debian/tmp/usr/include/* +debian/tmp/usr/lib*/*.so +debian/tmp/usr/lib*/pkgconfig/*.pc diff --git a/contrib/debian.libfluidsynth1.install b/contrib/debian.libfluidsynth1.install new file mode 100644 index 0000000..46e8d60 --- /dev/null +++ b/contrib/debian.libfluidsynth1.install @@ -0,0 +1 @@ +debian/tmp/usr/lib*/lib*.so.* diff --git a/contrib/debian.rules b/contrib/debian.rules new file mode 100644 index 0000000..2ab1792 --- /dev/null +++ b/contrib/debian.rules @@ -0,0 +1,98 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# GNU copyright 1997 to 1999 by Joey Hess. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +# This is the debhelper compatibility version to use. +#export DH_COMPAT=7 + +# These are used for cross-compiling and for saving the configure script +# from having to guess our platform (since we know it already) +DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) +DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) + + +ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS))) + CFLAGS += -g +endif +ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) + INSTALL_PROGRAM += -s +endif + +config.status: CMakeLists.txt + dh_testdir + + # Add here commands to configure the package. + cmake -DCMAKE_INSTALL_PREFIX=/usr -DLIB_INSTALL_DIR=/usr/lib . + +build: build-stamp +build-stamp: config.status + dh_testdir + + # Add here commands to compile the package. + $(MAKE) + + # the build should fail if the tests are not successful + #$(MAKE) check + + touch build-stamp + +clean: + dh_testdir + dh_testroot + rm -f build-stamp + + # Add here commands to clean up after the build process. + #-$(MAKE) distclean + + dh_clean -a + +install: build + dh_testdir + dh_testroot + dh_clean -k -a + dh_installdirs + + # Add here commands to install the package into debian/tmp + $(MAKE) install DESTDIR=$(CURDIR)/debian/tmp + +# Build architecture-independent files here. +binary-indep: build install +# We have nothing to do by default. + +# Build architecture-dependent files here. +binary-arch: build install + dh_testdir + dh_testroot + dh_install -a --list-missing +# dh_installchangelogs -a ChangeLog +# dh_installdocs -a +# dh_installexamples +# dh_installmenu +# dh_installdebconf +# dh_installlogrotate +# dh_installemacsen +# dh_installpam +# dh_installmime +# dh_installinit +# dh_installcron +# dh_installinfo +# dh_installman +# dh_link + dh_strip -a + dh_compress -a + dh_fixperms -a +# dh_perl +# dh_python + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install diff --git a/contrib/debian.series b/contrib/debian.series new file mode 100644 index 0000000..e69de29 diff --git a/contrib/fluidsynth.dsc b/contrib/fluidsynth.dsc new file mode 100644 index 0000000..664e40b --- /dev/null +++ b/contrib/fluidsynth.dsc @@ -0,0 +1,8 @@ +Format: 1.0 +Source: fluidsynth +Version: 2.2.0-1 +Binary: fluidsynth, libfluidsynth1, libfluidsynth-dev +Maintainer: Rui Nuno Capela +Architecture: any +Standards-Version: 3.7.2 +Build-Depends: debhelper (>= 5.0.0), cmake, pkg-config, libdb-dev, libjack-dev, libasound2-dev, libsndfile-dev, libglib2.0-dev diff --git a/contrib/fluidsynth.spec b/contrib/fluidsynth.spec new file mode 100644 index 0000000..7401f36 --- /dev/null +++ b/contrib/fluidsynth.spec @@ -0,0 +1,142 @@ +# +# spec file for package fluidsynth +# +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# +# All modifications and additions to the file contributed by third parties +# remain the property of their copyright owners, unless otherwise agreed +# upon. The license for this file, and modifications and additions to the +# file, is the same license as for the pristine package itself (unless the +# license for the pristine package is not an Open Source License, in which +# case the license is the MIT License). An "Open Source License" is a +# license that conforms to the Open Source Definition (Version 1.9) +# published by the Open Source Initiative. + +# Please submit bugfixes or comments via https://bugs.opensuse.org/ +# + + +# fix build for older distros and architectures where _fillupdir is +# not yet defined by using the old path as recommended by +# https://en.opensuse.org/openSUSE:Packaging_Conventions_RPM_Macros#.25_fillupdir +%if ! %{defined _fillupdir} + %define _fillupdir /var/adm/fillup-templates +%endif + +Name: fluidsynth +Version: 2.2.2 +Release: 0 +Summary: A Real-Time Software Synthesizer That Uses Soundfont(tm) +License: LGPL-2.1-or-later +Group: Productivity/Multimedia/Sound/Midi +Url: http://www.fluidsynth.org/ +Source: https://github.com/FluidSynth/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz +Source1000: baselibs.conf +BuildRequires: cmake >= 3.1.0 +BuildRequires: gcc-c++ +%if 0%{?is_opensuse} +BuildRequires: ladspa-devel +%endif +BuildRequires: pkgconfig +BuildRequires: readline-devel +BuildRequires: pkgconfig(alsa) +BuildRequires: pkgconfig(dbus-1) +BuildRequires: pkgconfig(jack) +BuildRequires: pkgconfig(libinstpatch-1.0) >= 1.1.0 +BuildRequires: pkgconfig(libpulse) +BuildRequires: pkgconfig(sndfile) +%if 0%{?suse_version} +%{?systemd_requires} +PreReq: %fillup_prereq +%endif + +%description +FluidSynth (formerly IIWU Synth) is a real-time software synthesizer +based on the SoundFont(tm) 2 specifications. It can read MIDI events +from the MIDI input device and render them to the audio device. It +can also play MIDI files. + +%package devel +Summary: Development package for the fluidsynth library +Group: Development/Libraries/C and C++ +Requires: glibc-devel +Requires: libfluidsynth3 = %{version} +Provides: libfluidsynth-devel = %{version} + +%description devel +This package contains the files needed to compile programs that use the +fluidsynth library. + +%package -n libfluidsynth3 +Summary: Library for Fluidsynth +Group: System/Libraries + +%description -n libfluidsynth3 +This package contains the shared library for Fluidsynth. + +%prep +%setup -q + +%build +%cmake \ + -DFLUID_DAEMON_ENV_FILE=%{_fillupdir}/sysconfig.%{name} \ + -Denable-lash=0 +%cmake_build + +%check +%cmake +%if 0%{?fedora_version} || 0%{?mageia} +%cmake_build --target check +%else +%cmake_build check +%endif + +%install +%cmake_install + +%if 0%{?suse_version} + +# manually install systemd service files +install -Dm 644 build/fluidsynth.conf %{buildroot}%{_fillupdir}/sysconfig.%{name} +install -Dm 644 build/fluidsynth.service %{buildroot}%{_unitdir}/%{name}.service +install -d %{buildroot}%{_sbindir} +ln -s %{_sbindir}/service %{buildroot}%{_sbindir}/rc%{name} + +%pre +%service_add_pre %{name}.service + +%post +%fillup_only +%service_add_post %{name}.service + +%preun +%service_del_preun %{name}.service + +%postun +%service_del_postun %{name}.service + +%endif + +%post -n libfluidsynth3 -p /sbin/ldconfig +%postun -n libfluidsynth3 -p /sbin/ldconfig + +%files +%license LICENSE +%doc AUTHORS ChangeLog README.md THANKS TODO +%{_mandir}/man?/* +%{_bindir}/* +%if 0%{?suse_version} +%{_unitdir}/%{name}.service +%{_sbindir}/rc%{name} +%{_fillupdir}/sysconfig.%{name} +%endif + +%files devel +%{_libdir}/lib*.so +%{_includedir}/* +%{_libdir}/pkgconfig/*.pc + +%files -n libfluidsynth3 +%{_libdir}/lib*.so.* + +%changelog diff --git a/doc/fluidsettings.xml b/doc/fluidsettings.xml index 20ee510..264e7b5 100644 --- a/doc/fluidsettings.xml +++ b/doc/fluidsettings.xml @@ -590,6 +590,15 @@ and commit the results. Refresh with the following command: Sets the performance mode as pointed out by Oboe's documentation. + + oboe.error-recovery-mode + str + Reconnect + Reconnect, Stop + + Sets the error recovery mode when audio device error such as earphone disconnection occurred. It reconnects by default (same as OpenSLES behavior), but can be stopped if Stop is specified. + + oss.device str diff --git a/doc/fluidsynth-v20-devdoc.txt b/doc/fluidsynth-v20-devdoc.txt index a491760..e37a1d5 100644 --- a/doc/fluidsynth-v20-devdoc.txt +++ b/doc/fluidsynth-v20-devdoc.txt @@ -8,8 +8,8 @@ \author David Henningsson \author Tom Moebert \author Copyright © 2003-2021 Peter Hanappe, Conrad Berhörster, Antoine Schmitt, Pedro López-Cabanillas, Josh Green, David Henningsson, Tom Moebert -\version Revision 2.2.2 -\date 2021-07-09 +\version Revision 2.2.3 +\date 2021-09-11 All the source code examples in this document are in the public domain; you can use them as you please. This document is licensed under the Creative Commons Attribution-Share Alike 3.0 Unported License. To view a copy of this license, visit https://creativecommons.org/licenses/by-sa/3.0/ . The FluidSynth library is distributed under the GNU Lesser General Public License. A copy of the GNU Lesser General Public License is contained in the FluidSynth package; if not, visit https://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt or write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. diff --git a/fluidsynth.spec.in b/fluidsynth.spec.in deleted file mode 100644 index 0841401..0000000 --- a/fluidsynth.spec.in +++ /dev/null @@ -1,76 +0,0 @@ - -%define name @PACKAGE@ -%define version @VERSION@ -%define release 1 -%define prefix /usr - -Summary: A real-time software synthesizer based on SoundFont 2 specifications. -Name: %{name} -Version: %{version} -Release: %{release} -Prefix: %{prefix} -Copyright: LGPL -Group: Sound -Source: https://savannah.nongnu.org/download/fluid/stable.pkg/%{version}/fluidsynth-%{version}.tar.gz -URL: https://www.fluidsynth.org/ -BuildRoot: /var/tmp/%{name}-%{version} - -%description -FluidSynth is a real-time software synthesizer based on the SoundFont -2 specifications. FluidSynth can read MIDI events from MIDI input -devices and render them to audio devices using SoundFont files to -define the instrument sounds. It can also play MIDI files and supports -real time effect control via SoundFont modulators and MIDI -controls. FluidSynth can be interfaced to other programs in different -ways, including linking as a shared library. - -%package devel -Summary: Libraries and includes to build FluidSynth into other applications -Group: Development/Libraries - -%description devel -FluidSynth is a real-time software synthesizer based on the SoundFont -2 specifications. FluidSynth can read MIDI events from MIDI input -devices and render them to audio devices using SoundFont files to -define the instrument sounds. It can also play MIDI files and supports -real time effect control via SoundFont modulators and MIDI -controls. FluidSynth can be interfaced to other programs in different -ways, including linking as a shared library. - -This package contains libraries and includes for building applications -with FluidSynth support. - -%prep -%setup - -%build -./configure --prefix=%{prefix} -make - -%install -if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi -mkdir -p $RPM_BUILD_ROOT -make prefix=$RPM_BUILD_ROOT%{prefix} install - -%clean -if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi - -%files -%defattr(-,root,root) -%doc AUTHORS COPYING ChangeLog NEWS README TODO -%{prefix}/bin/fluidsynth -%{prefix}/lib/libfluidsynth.so* -%{prefix}/man/man1/* - -%files devel -%defattr(-,root,root) -%doc doc/example.c doc/example.sf2 doc/api doc/html/* -%{prefix}/lib/libfluidsynth.a -%{prefix}/lib/libfluidsynth.la -%{prefix}/lib/pkgconfig/fluidsynth.pc -%{prefix}/include/fluidsynth.h -%{prefix}/include/fluidsynth - -%changelog -* Mon Aug 25 2003 Josh Green -- Created initial fluidsynth.spec.in diff --git a/include/fluidsynth/sfont.h b/include/fluidsynth/sfont.h index b29d8b4..8a5e405 100644 --- a/include/fluidsynth/sfont.h +++ b/include/fluidsynth/sfont.h @@ -26,7 +26,7 @@ extern "C" { #endif /** - * @defgroup soundfonts SountFonts + * @defgroup soundfonts SoundFonts * * SoundFont related functions * diff --git a/src/bindings/fluid_ladspa.c b/src/bindings/fluid_ladspa.c index bb63e5b..4acb75f 100644 --- a/src/bindings/fluid_ladspa.c +++ b/src/bindings/fluid_ladspa.c @@ -1325,13 +1325,16 @@ static void delete_fluid_ladspa_effect(fluid_ladspa_effect_t *effect) * are private to this effect, so we can safely remove them here. Nodes connected * to audio ports might be connected to other effects as well, so we simply remove * any pointers to them from the effect. */ - for(i = 0; i < effect->desc->PortCount; i++) + if(effect->desc != NULL) { - node = (fluid_ladspa_node_t *) effect->port_nodes[i]; - - if(node && node->type & FLUID_LADSPA_NODE_CONTROL) + for(i = 0; i < effect->desc->PortCount; i++) { - delete_fluid_ladspa_node(node); + node = (fluid_ladspa_node_t *) effect->port_nodes[i]; + + if(node && node->type & FLUID_LADSPA_NODE_CONTROL) + { + delete_fluid_ladspa_node(node); + } } } diff --git a/src/config.cmake b/src/config.cmake index 946421b..d3aaf70 100644 --- a/src/config.cmake +++ b/src/config.cmake @@ -262,4 +262,7 @@ /* Define to 1 if you have the logf() function. */ #cmakedefine HAVE_LOGF @HAVE_LOGF@ +/* Define to 1 if you have the socklen_t type. */ +#cmakedefine HAVE_SOCKLEN_T @HAVE_SOCKLEN_T@ + #endif /* CONFIG_H */ diff --git a/src/drivers/fluid_coreaudio.c b/src/drivers/fluid_coreaudio.c index ab41770..bfa482e 100644 --- a/src/drivers/fluid_coreaudio.c +++ b/src/drivers/fluid_coreaudio.c @@ -187,14 +187,22 @@ new_fluid_core_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func dev->data = data; // Open the default output unit +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + ComponentDescription desc; +#else AudioComponentDescription desc; +#endif desc.componentType = kAudioUnitType_Output; desc.componentSubType = kAudioUnitSubType_HALOutput; //kAudioUnitSubType_DefaultOutput; desc.componentManufacturer = kAudioUnitManufacturer_Apple; desc.componentFlags = 0; desc.componentFlagsMask = 0; +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + Component comp = FindNextComponent(NULL, &desc); +#else AudioComponent comp = AudioComponentFindNext(NULL, &desc); +#endif if(comp == NULL) { @@ -202,7 +210,11 @@ new_fluid_core_audio_driver2(fluid_settings_t *settings, fluid_audio_func_t func goto error_recovery; } +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + status = OpenAComponent(comp, &dev->outputUnit); +#else status = AudioComponentInstanceNew(comp, &dev->outputUnit); +#endif if(status != noErr) { @@ -372,7 +384,11 @@ delete_fluid_core_audio_driver(fluid_audio_driver_t *p) fluid_core_audio_driver_t *dev = (fluid_core_audio_driver_t *) p; fluid_return_if_fail(dev != NULL); +#if MAC_OS_X_VERSION_MIN_REQUIRED < 1060 + CloseComponent(dev->outputUnit); +#else AudioComponentInstanceDispose(dev->outputUnit); +#endif if(dev->buffers[0]) { diff --git a/src/drivers/fluid_oboe.cpp b/src/drivers/fluid_oboe.cpp index eb7de5d..f95af01 100644 --- a/src/drivers/fluid_oboe.cpp +++ b/src/drivers/fluid_oboe.cpp @@ -43,6 +43,7 @@ using namespace oboe; constexpr int NUM_CHANNELS = 2; class OboeAudioStreamCallback; +class OboeAudioStreamErrorCallback; /** fluid_oboe_audio_driver_t * @@ -55,7 +56,16 @@ typedef struct fluid_synth_t *synth = nullptr; bool cont = false; std::unique_ptr oboe_callback; + std::unique_ptr oboe_error_callback; std::shared_ptr stream; + + double sample_rate; + int is_sample_format_float; + int device_id; + int sharing_mode; // 0: Shared, 1: Exclusive + int performance_mode; // 0: None, 1: PowerSaving, 2: LowLatency + oboe::SampleRateConversionQuality srate_conversion_quality; + int error_recovery_mode; // 0: Reconnect, 1: Stop } fluid_oboe_audio_driver_t; @@ -93,20 +103,34 @@ class OboeAudioStreamCallback : public AudioStreamCallback void *user_data; }; +class OboeAudioStreamErrorCallback : public AudioStreamErrorCallback +{ + fluid_oboe_audio_driver_t *dev; + +public: + OboeAudioStreamErrorCallback(fluid_oboe_audio_driver_t *dev) : dev(dev) {} + + void onErrorAfterClose(AudioStream *stream, Result result); +}; + +constexpr char OBOE_ID[] = "audio.oboe.id"; +constexpr char SHARING_MODE[] = "audio.oboe.sharing-mode"; +constexpr char PERF_MODE[] = "audio.oboe.performance-mode"; constexpr char SRCQ_SET[] = "audio.oboe.sample-rate-conversion-quality"; +constexpr char RECOVERY_MODE[] = "audio.oboe.error-recovery-mode"; void fluid_oboe_audio_driver_settings(fluid_settings_t *settings) { - fluid_settings_register_int(settings, "audio.oboe.id", 0, 0, 0x7FFFFFFF, 0); + fluid_settings_register_int(settings, OBOE_ID, 0, 0, 0x7FFFFFFF, 0); - fluid_settings_register_str(settings, "audio.oboe.sharing-mode", "Shared", 0); - fluid_settings_add_option(settings, "audio.oboe.sharing-mode", "Shared"); - fluid_settings_add_option(settings, "audio.oboe.sharing-mode", "Exclusive"); + fluid_settings_register_str(settings, SHARING_MODE, "Shared", 0); + fluid_settings_add_option(settings, SHARING_MODE, "Shared"); + fluid_settings_add_option(settings, SHARING_MODE, "Exclusive"); - fluid_settings_register_str(settings, "audio.oboe.performance-mode", "None", 0); - fluid_settings_add_option(settings, "audio.oboe.performance-mode", "None"); - fluid_settings_add_option(settings, "audio.oboe.performance-mode", "PowerSaving"); - fluid_settings_add_option(settings, "audio.oboe.performance-mode", "LowLatency"); + fluid_settings_register_str(settings, PERF_MODE, "None", 0); + fluid_settings_add_option(settings, PERF_MODE, "None"); + fluid_settings_add_option(settings, PERF_MODE, "PowerSaving"); + fluid_settings_add_option(settings, PERF_MODE, "LowLatency"); fluid_settings_register_str(settings, SRCQ_SET, "Medium", 0); fluid_settings_add_option(settings, SRCQ_SET, "None"); @@ -115,6 +139,10 @@ void fluid_oboe_audio_driver_settings(fluid_settings_t *settings) fluid_settings_add_option(settings, SRCQ_SET, "Medium"); fluid_settings_add_option(settings, SRCQ_SET, "High"); fluid_settings_add_option(settings, SRCQ_SET, "Best"); + + fluid_settings_register_str(settings, RECOVERY_MODE, "Reconnect", 0); + fluid_settings_add_option(settings, RECOVERY_MODE, "Reconnect"); + fluid_settings_add_option(settings, RECOVERY_MODE, "Stop"); } static oboe::SampleRateConversionQuality get_srate_conversion_quality(fluid_settings_t *settings) @@ -157,6 +185,28 @@ static oboe::SampleRateConversionQuality get_srate_conversion_quality(fluid_sett return q; } +Result +fluid_oboe_connect_or_reconnect(fluid_oboe_audio_driver_t *dev) +{ + AudioStreamBuilder builder; + builder.setDeviceId(dev->device_id) + ->setDirection(Direction::Output) + ->setChannelCount(NUM_CHANNELS) + ->setSampleRate(dev->sample_rate) + ->setFormat(dev->is_sample_format_float ? AudioFormat::Float : AudioFormat::I16) + ->setSharingMode(dev->sharing_mode == 1 ? SharingMode::Exclusive : SharingMode::Shared) + ->setPerformanceMode( + dev->performance_mode == 1 ? PerformanceMode::PowerSaving : + dev->performance_mode == 2 ? PerformanceMode::LowLatency : PerformanceMode::None) + ->setUsage(Usage::Media) + ->setContentType(ContentType::Music) + ->setCallback(dev->oboe_callback.get()) + ->setErrorCallback(dev->oboe_error_callback.get()) + ->setSampleRateConversionQuality(dev->srate_conversion_quality); + + return builder.openStream(dev->stream); +} + /* * new_fluid_oboe_audio_driver */ @@ -168,44 +218,24 @@ new_fluid_oboe_audio_driver(fluid_settings_t *settings, fluid_synth_t *synth) try { Result result; - AudioStreamBuilder builder_obj; - AudioStreamBuilder *builder = &builder_obj; - - double sample_rate; - int is_sample_format_float; - int device_id; - int sharing_mode; // 0: Shared, 1: Exclusive - int performance_mode; // 0: None, 1: PowerSaving, 2: LowLatency - dev = new fluid_oboe_audio_driver_t(); dev->synth = synth; dev->oboe_callback = std::make_unique(dev); + dev->oboe_error_callback = std::make_unique(dev); + + fluid_settings_getnum(settings, "synth.sample-rate", &dev->sample_rate); + dev->is_sample_format_float = fluid_settings_str_equal(settings, "audio.sample-format", "float"); + fluid_settings_getint(settings, OBOE_ID, &dev->device_id); + dev->sharing_mode = + fluid_settings_str_equal(settings, SHARING_MODE, "Exclusive") ? 1 : 0; + dev->performance_mode = + fluid_settings_str_equal(settings, PERF_MODE, "PowerSaving") ? 1 : + fluid_settings_str_equal(settings, PERF_MODE, "LowLatency") ? 2 : 0; + dev->srate_conversion_quality = get_srate_conversion_quality(settings); + dev->error_recovery_mode = fluid_settings_str_equal(settings, RECOVERY_MODE, "Stop") ? 1 : 0; - fluid_settings_getnum(settings, "synth.sample-rate", &sample_rate); - is_sample_format_float = fluid_settings_str_equal(settings, "audio.sample-format", "float"); - fluid_settings_getint(settings, "audio.oboe.id", &device_id); - sharing_mode = - fluid_settings_str_equal(settings, "audio.oboe.sharing-mode", "Exclusive") ? 1 : 0; - performance_mode = - fluid_settings_str_equal(settings, "audio.oboe.performance-mode", "PowerSaving") ? 1 : - fluid_settings_str_equal(settings, "audio.oboe.performance-mode", "LowLatency") ? 2 : 0; - - builder->setDeviceId(device_id) - ->setDirection(Direction::Output) - ->setChannelCount(NUM_CHANNELS) - ->setSampleRate(sample_rate) - ->setFormat(is_sample_format_float ? AudioFormat::Float : AudioFormat::I16) - ->setSharingMode(sharing_mode == 1 ? SharingMode::Exclusive : SharingMode::Shared) - ->setPerformanceMode( - performance_mode == 1 ? PerformanceMode::PowerSaving : - performance_mode == 2 ? PerformanceMode::LowLatency : PerformanceMode::None) - ->setUsage(Usage::Media) - ->setContentType(ContentType::Music) - ->setCallback(dev->oboe_callback.get()) - ->setSampleRateConversionQuality(get_srate_conversion_quality(settings)); - - result = builder->openStream(dev->stream); + result = fluid_oboe_connect_or_reconnect(dev); if(result != Result::OK) { @@ -269,5 +299,38 @@ void delete_fluid_oboe_audio_driver(fluid_audio_driver_t *p) delete dev; } + +void +OboeAudioStreamErrorCallback::onErrorAfterClose(AudioStream *stream, Result result) +{ + if(dev->error_recovery_mode == 1) // Stop + { + FLUID_LOG(FLUID_ERR, "Oboe driver encountered an error (such as earphone unplugged). Stopped."); + dev->stream.reset(); + return; + } + else + { + FLUID_LOG(FLUID_WARN, "Oboe driver encountered an error (such as earphone unplugged). Recovering..."); + } + + result = fluid_oboe_connect_or_reconnect(dev); + + if(result != Result::OK) + { + FLUID_LOG(FLUID_ERR, "Unable to reconnect Oboe audio stream"); + return; // cannot do anything further + } + + // start the new stream. + result = dev->stream->start(); + + if(result != Result::OK) + { + FLUID_LOG(FLUID_ERR, "Unable to restart Oboe audio stream"); + return; // cannot do anything further + } +} + #endif // OBOE_SUPPORT diff --git a/src/utils/fluid_sys.h b/src/utils/fluid_sys.h index 86a47f3..635bcf6 100644 --- a/src/utils/fluid_sys.h +++ b/src/utils/fluid_sys.h @@ -205,8 +205,11 @@ char *fluid_strtok(char **str, char *delim); #define INCL_DOS #include +/* Define socklen_t if not provided */ +#if !HAVE_SOCKLEN_T typedef int socklen_t; #endif +#endif /** Time functions