From af20a1c994fc829d1fe93da144fac8451e2295f6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 07:57:52 +0100 Subject: [PATCH 01/11] pulse: obey Pulse's maximum sample rate (fixes DSD128 playback) Closes https://github.com/MusicPlayerDaemon/MPD/issues/708 --- NEWS | 2 ++ src/output/plugins/PulseOutputPlugin.cxx | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 83388e38a..ba514ae9c 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.21.19 (not yet released) +* output + - pulse: obey Pulse's maximum sample rate (fixes DSD128 playback) * fix build failure with clang 10 ver 0.21.18 (2019/12/24) diff --git a/src/output/plugins/PulseOutputPlugin.cxx b/src/output/plugins/PulseOutputPlugin.cxx index fa1b06da9..ee7075625 100644 --- a/src/output/plugins/PulseOutputPlugin.cxx +++ b/src/output/plugins/PulseOutputPlugin.cxx @@ -650,7 +650,7 @@ PulseOutput::Open(AudioFormat &audio_format) break; } - ss.rate = audio_format.sample_rate; + ss.rate = std::min(audio_format.sample_rate, PA_RATE_MAX); ss.channels = audio_format.channels; /* create a stream .. */ From e92af066644cbc4aea2711003cebb1c20cac4aae Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 11:49:10 +0100 Subject: [PATCH 02/11] android/build.py: remove obsolete dict key android_api_level --- android/build.py | 1 - 1 file changed, 1 deletion(-) diff --git a/android/build.py b/android/build.py index 23ec9f256..1ef868dc8 100755 --- a/android/build.py +++ b/android/build.py @@ -30,7 +30,6 @@ android_abis = { }, 'arm64-v8a': { - 'android_api_level': '21', 'arch': 'aarch64-linux-android', 'ndk_arch': 'arm64', 'toolchain_arch': 'aarch64-linux-android', From cb1a9045e6f8b99689b6e27f2162f1f0964befe1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 11:51:20 +0100 Subject: [PATCH 03/11] android/build.py: drop "-none" from llvm_triple It's not mentioned on https://developer.android.com/ndk/guides/other_build_systems --- android/build.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/android/build.py b/android/build.py index 1ef868dc8..897666261 100755 --- a/android/build.py +++ b/android/build.py @@ -25,7 +25,7 @@ android_abis = { 'arch': 'arm-linux-androideabi', 'ndk_arch': 'arm', 'toolchain_arch': 'arm-linux-androideabi', - 'llvm_triple': 'armv7-none-linux-androideabi', + 'llvm_triple': 'armv7-linux-androideabi', 'cflags': '-march=armv7-a -mfpu=vfp -mfloat-abi=softfp', }, @@ -33,7 +33,7 @@ android_abis = { 'arch': 'aarch64-linux-android', 'ndk_arch': 'arm64', 'toolchain_arch': 'aarch64-linux-android', - 'llvm_triple': 'aarch64-none-linux-android', + 'llvm_triple': 'aarch64-linux-android', 'cflags': '', }, @@ -41,7 +41,7 @@ android_abis = { 'arch': 'i686-linux-android', 'ndk_arch': 'x86', 'toolchain_arch': 'x86', - 'llvm_triple': 'i686-none-linux-android', + 'llvm_triple': 'i686-linux-android', 'cflags': '-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32', }, } From 2306b0d78c2b025b0cf3d6771937bb71aef142e2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 12:02:12 +0100 Subject: [PATCH 04/11] android/build.py: append API level to LLVM triple This implicitly defines __ANDROID_API__, which means we can drop the "-D__ANDROID_API__=" parameter. This is recommended on https://android.googlesource.com/platform/ndk/+/ndk-release-r20/docs/BuildSystemMaintainers.md --- android/build.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/android/build.py b/android/build.py index 897666261..cfa3c461b 100755 --- a/android/build.py +++ b/android/build.py @@ -92,7 +92,7 @@ class AndroidNdkToolchain: toolchain_path = os.path.join(ndk_path, 'toolchains', abi_info['toolchain_arch'] + '-' + gcc_version, 'prebuilt', build_arch) llvm_path = os.path.join(ndk_path, 'toolchains', 'llvm', 'prebuilt', build_arch) - llvm_triple = abi_info['llvm_triple'] + llvm_triple = abi_info['llvm_triple'] + android_api_level common_flags = '-Os -g' common_flags += ' -fPIC' @@ -115,8 +115,7 @@ class AndroidNdkToolchain: self.cxxflags = common_flags self.cppflags = '--sysroot=' + sysroot + \ ' -isystem ' + os.path.join(install_prefix, 'include') + \ - ' -isystem ' + os.path.join(sysroot, 'usr', 'include', arch) + \ - ' -D__ANDROID_API__=' + android_api_level + ' -isystem ' + os.path.join(sysroot, 'usr', 'include', arch) self.ldflags = '--sysroot=' + sysroot + \ ' -L' + os.path.join(install_prefix, 'lib') + \ ' -L' + os.path.join(target_root, 'usr', 'lib') + \ From 8c31370534a7c76aea243fb2ef4935f418f079cf Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 12:07:55 +0100 Subject: [PATCH 05/11] android/build.py: drop --sysroot, -isystem, -L, ... These appear to be no longer necessary (tested with NDK r20b). Closes https://github.com/android/ndk/issues/951 --- android/build.py | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/android/build.py b/android/build.py index cfa3c461b..bea1dd051 100755 --- a/android/build.py +++ b/android/build.py @@ -75,20 +75,14 @@ class AndroidNdkToolchain: ndk_arch = abi_info['ndk_arch'] android_api_level = '21' - ndk_platform = 'android-' + android_api_level # select the NDK compiler gcc_version = '4.9' - ndk_platform_path = os.path.join(ndk_path, 'platforms', ndk_platform) - sysroot = os.path.join(ndk_path, 'sysroot') - target_root = os.path.join(ndk_platform_path, 'arch-' + ndk_arch) - install_prefix = os.path.join(arch_path, 'root') self.arch = arch self.install_prefix = install_prefix - self.sysroot = sysroot toolchain_path = os.path.join(ndk_path, 'toolchains', abi_info['toolchain_arch'] + '-' + gcc_version, 'prebuilt', build_arch) llvm_path = os.path.join(ndk_path, 'toolchains', 'llvm', 'prebuilt', build_arch) @@ -113,14 +107,10 @@ class AndroidNdkToolchain: self.cflags = common_flags self.cxxflags = common_flags - self.cppflags = '--sysroot=' + sysroot + \ - ' -isystem ' + os.path.join(install_prefix, 'include') + \ - ' -isystem ' + os.path.join(sysroot, 'usr', 'include', arch) - self.ldflags = '--sysroot=' + sysroot + \ - ' -L' + os.path.join(install_prefix, 'lib') + \ - ' -L' + os.path.join(target_root, 'usr', 'lib') + \ - ' -B' + os.path.join(target_root, 'usr', 'lib') + \ + self.cppflags = ' -isystem ' + os.path.join(install_prefix, 'include') + self.ldflags = ' -L' + os.path.join(install_prefix, 'lib') + \ ' ' + common_flags + self.ldflags = common_flags self.libs = '' self.is_arm = ndk_arch == 'arm' @@ -128,13 +118,10 @@ class AndroidNdkToolchain: self.is_aarch64 = ndk_arch == 'arm64' self.is_windows = False - libcxx_path = os.path.join(ndk_path, 'sources/cxx-stl/llvm-libc++') - libcxx_libs_path = os.path.join(libcxx_path, 'libs', android_abi) - libstdcxx_flags = '' - libstdcxx_cxxflags = libstdcxx_flags + ' -isystem ' + os.path.join(libcxx_path, 'include') + ' -isystem ' + os.path.join(ndk_path, 'sources/android/support/include') - libstdcxx_ldflags = libstdcxx_flags + ' -L' + libcxx_libs_path - libstdcxx_libs = '-lc++_static -lc++abi' + libstdcxx_cxxflags = '' + libstdcxx_ldflags = '' + libstdcxx_libs = '-static-libstdc++' if self.is_armv7: # On 32 bit ARM, clang generates no ".eh_frame" section; From 04101f37b820583387e3b93e3bdd50f791438e0e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 12:41:37 +0100 Subject: [PATCH 06/11] android/build.py: add -fno-faddrsig and -lmstackrealign --- android/build.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/android/build.py b/android/build.py index bea1dd051..d587982cd 100755 --- a/android/build.py +++ b/android/build.py @@ -100,6 +100,9 @@ class AndroidNdkToolchain: common_flags += ' -fvisibility=hidden -fdata-sections -ffunction-sections' + # required flags from https://android.googlesource.com/platform/ndk/+/ndk-release-r20/docs/BuildSystemMaintainers.md#additional-required-arguments + common_flags += ' -fno-addrsig' + self.ar = os.path.join(toolchain_bin, arch + '-ar') self.ranlib = os.path.join(toolchain_bin, arch + '-ranlib') self.nm = os.path.join(toolchain_bin, arch + '-nm') @@ -113,6 +116,10 @@ class AndroidNdkToolchain: self.ldflags = common_flags self.libs = '' + # required flags from https://android.googlesource.com/platform/ndk/+/ndk-release-r20/docs/BuildSystemMaintainers.md#additional-required-arguments + if ndk_arch == 'x86' and int(android_api_level) < 24: + self.ldflags += ' -lmstackrealign' + self.is_arm = ndk_arch == 'arm' self.is_armv7 = self.is_arm and 'armv7' in self.cflags self.is_aarch64 = ndk_arch == 'arm64' From ab41c16eb50535c672a1ce78f7f68181baa8f39a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 12:47:31 +0100 Subject: [PATCH 07/11] android/build.py: add -Wl,--exclude-libs=ALL Don't export the symbols of all those static libraries. Most importantly, don't export the whole libc++ ABI. --- android/build.py | 1 + 1 file changed, 1 insertion(+) diff --git a/android/build.py b/android/build.py index d587982cd..c48472546 100755 --- a/android/build.py +++ b/android/build.py @@ -112,6 +112,7 @@ class AndroidNdkToolchain: self.cxxflags = common_flags self.cppflags = ' -isystem ' + os.path.join(install_prefix, 'include') self.ldflags = ' -L' + os.path.join(install_prefix, 'lib') + \ + ' -Wl,--exclude-libs=ALL' + \ ' ' + common_flags self.ldflags = common_flags self.libs = '' From b4700039fd9ae574dec2f4ad308fb8f1eea248d2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 13:02:41 +0100 Subject: [PATCH 08/11] android/build.py: drop -lmstackrealign This flag doesn't appear to work, and since we never had a problem without the flag, implementing Google's recommendation is useless. --- android/build.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/android/build.py b/android/build.py index c48472546..6ccbb5f11 100755 --- a/android/build.py +++ b/android/build.py @@ -117,10 +117,6 @@ class AndroidNdkToolchain: self.ldflags = common_flags self.libs = '' - # required flags from https://android.googlesource.com/platform/ndk/+/ndk-release-r20/docs/BuildSystemMaintainers.md#additional-required-arguments - if ndk_arch == 'x86' and int(android_api_level) < 24: - self.ldflags += ' -lmstackrealign' - self.is_arm = ndk_arch == 'arm' self.is_armv7 = self.is_arm and 'armv7' in self.cflags self.is_aarch64 = ndk_arch == 'arm64' From aa0e121ade0d8db231279c5fb0ce36b6c4a1c389 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 13:02:07 +0100 Subject: [PATCH 09/11] android/build.py: support x86_64 builds --- android/build.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/android/build.py b/android/build.py index 6ccbb5f11..63e57f93e 100755 --- a/android/build.py +++ b/android/build.py @@ -44,6 +44,14 @@ android_abis = { 'llvm_triple': 'i686-linux-android', 'cflags': '-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32', }, + + 'x86_64': { + 'arch': 'x86_64-linux-android', + 'ndk_arch': 'x86_64', + 'toolchain_arch': 'x86_64', + 'llvm_triple': 'x86_64-linux-android', + 'cflags': '-m64', + }, } # select the NDK target From fada4aa5293b724a6fe16638169184cbe2edfdb1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 12 Jan 2020 13:08:37 +0100 Subject: [PATCH 10/11] NEWS: mention the Android build fix --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index ba514ae9c..e7c38ca97 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ver 0.21.19 (not yet released) * output - pulse: obey Pulse's maximum sample rate (fixes DSD128 playback) * fix build failure with clang 10 +* fix build failure with Android NDK r20 ver 0.21.18 (2019/12/24) * protocol From ce7ec2b3f59be54f67981d0f0e2f1155d58b110e Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 14 Jan 2020 17:44:44 +0100 Subject: [PATCH 11/11] meson.build: add -f{function,data}-sections to C++ as well By accident, this was only enabled for C. --- meson.build | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/meson.build b/meson.build index b6da75056..4acd0db64 100644 --- a/meson.build +++ b/meson.build @@ -88,6 +88,10 @@ test_ldflags = [ ] if get_option('buildtype') != 'debug' + test_cxxflags += [ + '-ffunction-sections', + '-fdata-sections', + ] test_cflags += [ '-ffunction-sections', '-fdata-sections',