Compare commits
140 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
5ccfcffcc1 | ||
![]() |
afe2aaa5f6 | ||
![]() |
9b11caa0e6 | ||
![]() |
a689b881d3 | ||
![]() |
e94c436264 | ||
![]() |
bad829509e | ||
![]() |
9c66b0414a | ||
![]() |
4d453a8313 | ||
![]() |
61d7b436a2 | ||
![]() |
cdddaf21b0 | ||
![]() |
b267ba5f0a | ||
![]() |
8270043053 | ||
![]() |
c00ce42bca | ||
![]() |
3852ddbbce | ||
![]() |
672bc3ab67 | ||
![]() |
62229f14da | ||
![]() |
a4c925c8d7 | ||
![]() |
60610e90b1 | ||
![]() |
90184e0ce7 | ||
![]() |
9c3e1d450a | ||
![]() |
60f2116202 | ||
![]() |
4ff2532330 | ||
![]() |
9c15760c4d | ||
![]() |
e1c43ec65f | ||
![]() |
4dd10894ba | ||
![]() |
608d7ec1e7 | ||
![]() |
8474599ed6 | ||
![]() |
ab39f64fc0 | ||
![]() |
185fbca282 | ||
![]() |
6e3b2fd844 | ||
![]() |
dab39dc778 | ||
![]() |
8cd5e79fbd | ||
![]() |
1de3ac6c78 | ||
![]() |
abe06a5fa6 | ||
![]() |
85c27840a3 | ||
![]() |
81c16273c5 | ||
![]() |
801ae86b5d | ||
![]() |
5619fd0bba | ||
![]() |
200258c7c3 | ||
![]() |
5418bb49fb | ||
![]() |
3449c14ff5 | ||
![]() |
36a89e8fe7 | ||
![]() |
8e6a21a9c2 | ||
![]() |
c560ec8ea6 | ||
![]() |
56c234b410 | ||
![]() |
82743dfd02 | ||
![]() |
33694642bd | ||
![]() |
c71242d743 | ||
![]() |
c45f113856 | ||
![]() |
e0a8fd398c | ||
![]() |
3e97058151 | ||
![]() |
51b1dd8672 | ||
![]() |
98a7d8da6c | ||
![]() |
acb29f792f | ||
![]() |
cd364023ae | ||
![]() |
8d34a1cfc6 | ||
![]() |
73a1f078a6 | ||
![]() |
b7ce452308 | ||
![]() |
5faf76051d | ||
![]() |
5fe70a3417 | ||
![]() |
7a68b1e71f | ||
![]() |
d5468dfe89 | ||
![]() |
976372ff63 | ||
![]() |
9abb686eeb | ||
![]() |
f24bcc7f42 | ||
![]() |
89800324cb | ||
![]() |
050e30418c | ||
![]() |
5397d18ed9 | ||
![]() |
42eb69f46f | ||
![]() |
f1ad21d2bf | ||
![]() |
535a099a27 | ||
![]() |
50003f6ad2 | ||
![]() |
0914644d2b | ||
![]() |
5ad6e7fec5 | ||
![]() |
0bb943ba3e | ||
![]() |
80a0cf694f | ||
![]() |
0c9e25b3c4 | ||
![]() |
943a67c805 | ||
![]() |
881d91f86b | ||
![]() |
54d57fdcc2 | ||
![]() |
f6f30d6d64 | ||
![]() |
4013fa15b9 | ||
![]() |
ac1b844c15 | ||
![]() |
b8614048d4 | ||
![]() |
aed0d13591 | ||
![]() |
9d02103ebe | ||
![]() |
61784c2144 | ||
![]() |
7059215795 | ||
![]() |
2190cc7927 | ||
![]() |
75dc9506c2 | ||
![]() |
4f11fa0d41 | ||
![]() |
ce7ec2b3f5 | ||
![]() |
fada4aa529 | ||
![]() |
aa0e121ade | ||
![]() |
b4700039fd | ||
![]() |
ab41c16eb5 | ||
![]() |
04101f37b8 | ||
![]() |
8c31370534 | ||
![]() |
2306b0d78c | ||
![]() |
cb1a9045e6 | ||
![]() |
e92af06664 | ||
![]() |
af20a1c994 | ||
![]() |
756560eac3 | ||
![]() |
dca0519336 | ||
![]() |
b9a7f30443 | ||
![]() |
32a17a997a | ||
![]() |
bf41d1ad2b | ||
![]() |
d27e534a85 | ||
![]() |
6d54928d7c | ||
![]() |
0dffe05bf7 | ||
![]() |
9ef1f10319 | ||
![]() |
23fcfdbd2a | ||
![]() |
3401d26d4c | ||
![]() |
256753ea46 | ||
![]() |
76cd5f8595 | ||
![]() |
5684025847 | ||
![]() |
744bd1eadc | ||
![]() |
2bc127bb43 | ||
![]() |
7770298a65 | ||
![]() |
fa50cdb39e | ||
![]() |
816ef12088 | ||
![]() |
5ff786e59c | ||
![]() |
80fe88e8f6 | ||
![]() |
a1afe9afc6 | ||
![]() |
fe598e7d30 | ||
![]() |
4475b8ca04 | ||
![]() |
a714bdb0ce | ||
![]() |
087874620f | ||
![]() |
f1116c9258 | ||
![]() |
d01fb6730a | ||
![]() |
7bfe6a3304 | ||
![]() |
9a577f8060 | ||
![]() |
d75a0d714e | ||
![]() |
9be3a1554e | ||
![]() |
7764719513 | ||
![]() |
dcbb9fe07c | ||
![]() |
e3b347820a | ||
![]() |
a84bf5a92e | ||
![]() |
732bdc800d | ||
![]() |
a8661b5931 |
.travis.ymlNEWS
android
doc
meson.buildpython/build
src
CommandLine.cxxMain.cxxStats.cxx
android
archive
plugins
command
config
db
decoder
plugins
encoder
event
DeferEvent.hxxLoop.cxxMaskMonitor.hxxMultiSocketMonitor.cxxMultiSocketMonitor.hxxSocketMonitor.cxxSocketMonitor.hxxTimerEvent.hxxmeson.build
fs
input
java
lib
curl
dbus
icu
nfs
upnp
xiph
mixer
neighbor
plugins
output
plugins
pcm
player
playlist
protocol
storage
tag
time
util
test
126
.travis.yml
126
.travis.yml
@@ -1,7 +1,73 @@
|
||||
language: cpp
|
||||
|
||||
matrix:
|
||||
jobs:
|
||||
include:
|
||||
# Ubuntu Bionic (18.04) with GCC 7
|
||||
- os: linux
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:deadsnakes/ppa' # for Python 3.7 (required by Meson)
|
||||
packages:
|
||||
- libgtest-dev
|
||||
- libboost-dev
|
||||
- python3.6
|
||||
- python3-urllib3
|
||||
- ninja-build
|
||||
before_install:
|
||||
- wget https://bootstrap.pypa.io/get-pip.py
|
||||
- /usr/bin/python3.6 get-pip.py --user --no-cache-dir
|
||||
install:
|
||||
- /usr/bin/python3.6 $HOME/.local/bin/pip install --user meson --no-cache-dir
|
||||
env:
|
||||
- MATRIX_EVAL="export PATH=\$HOME/.local/bin:\$PATH"
|
||||
|
||||
# Ubuntu Bionic (18.04) with GCC 7 on big-endian
|
||||
- os: linux
|
||||
arch: s390x
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:deadsnakes/ppa' # for Python 3.7 (required by Meson)
|
||||
packages:
|
||||
- libgtest-dev
|
||||
- libboost-dev
|
||||
- python3.6
|
||||
- python3-urllib3
|
||||
- ninja-build
|
||||
before_install:
|
||||
- wget https://bootstrap.pypa.io/get-pip.py
|
||||
- /usr/bin/python3.6 get-pip.py --user --no-cache-dir
|
||||
install:
|
||||
- /usr/bin/python3.6 $HOME/.local/bin/pip install --user meson --no-cache-dir
|
||||
env:
|
||||
- MATRIX_EVAL="export PATH=\$HOME/.local/bin:\$PATH"
|
||||
|
||||
# Ubuntu Bionic (18.04) with GCC 7 on ARM64
|
||||
- os: linux
|
||||
arch: arm64
|
||||
dist: bionic
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- sourceline: 'ppa:deadsnakes/ppa' # for Python 3.7 (required by Meson)
|
||||
packages:
|
||||
- libgtest-dev
|
||||
- libboost-dev
|
||||
- python3.6
|
||||
- python3-urllib3
|
||||
- ninja-build
|
||||
before_install:
|
||||
- wget https://bootstrap.pypa.io/get-pip.py
|
||||
- /usr/bin/python3.6 get-pip.py --user --no-cache-dir
|
||||
install:
|
||||
- /usr/bin/python3.6 $HOME/.local/bin/pip install --user meson --no-cache-dir
|
||||
env:
|
||||
- MATRIX_EVAL="export PATH=\$HOME/.local/bin:\$PATH"
|
||||
|
||||
# Ubuntu Trusty (16.04) with GCC 6
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons:
|
||||
@@ -20,13 +86,14 @@ matrix:
|
||||
- ninja-build
|
||||
before_install:
|
||||
- wget https://bootstrap.pypa.io/get-pip.py
|
||||
- /usr/bin/python3.6 get-pip.py --user
|
||||
- /usr/bin/python3.6 get-pip.py --user --no-cache-dir
|
||||
install:
|
||||
- /usr/bin/python3.6 $HOME/.local/bin/pip install --user meson
|
||||
- /usr/bin/python3.6 $HOME/.local/bin/pip install --user meson --no-cache-dir
|
||||
env:
|
||||
# use gold as workaround for https://sourceware.org/bugzilla/show_bug.cgi?id=17068
|
||||
- MATRIX_EVAL="export CC=gcc-6 CXX=g++-6 LDFLAGS=-fuse-ld=gold PATH=$HOME/.local/bin:$PATH"
|
||||
- MATRIX_EVAL="export CC='ccache gcc-6' CXX='ccache g++-6' LDFLAGS=-fuse-ld=gold PATH=\$HOME/.local/bin:\$PATH"
|
||||
|
||||
# Ubuntu Trusty (16.04) with GCC 8
|
||||
- os: linux
|
||||
dist: trusty
|
||||
addons:
|
||||
@@ -45,31 +112,60 @@ matrix:
|
||||
- ninja-build
|
||||
before_install:
|
||||
- wget https://bootstrap.pypa.io/get-pip.py
|
||||
- /usr/bin/python3.6 get-pip.py --user
|
||||
- /usr/bin/python3.6 get-pip.py --user --no-cache-dir
|
||||
install:
|
||||
- /usr/bin/python3.6 $HOME/.local/bin/pip install --user meson
|
||||
- /usr/bin/python3.6 $HOME/.local/bin/pip install --user meson --no-cache-dir
|
||||
env:
|
||||
# use gold as workaround for https://sourceware.org/bugzilla/show_bug.cgi?id=17068
|
||||
- MATRIX_EVAL="export CC=gcc-8 CXX=g++-8 LDFLAGS=-fuse-ld=gold PATH=$HOME/.local/bin:$PATH"
|
||||
- MATRIX_EVAL="export CC='ccache gcc-8' CXX='ccache g++-8' LDFLAGS=-fuse-ld=gold PATH=\$HOME/.local/bin:\$PATH"
|
||||
|
||||
- os: osx
|
||||
osx_image: xcode9.3beta
|
||||
osx_image: xcode9.4
|
||||
addons:
|
||||
homebrew:
|
||||
packages:
|
||||
- ccache
|
||||
- meson
|
||||
- icu4c
|
||||
- ffmpeg
|
||||
- libnfs
|
||||
- yajl
|
||||
- libupnp
|
||||
- libid3tag
|
||||
- chromaprint
|
||||
- libsamplerate
|
||||
- libsoxr
|
||||
- libzzip
|
||||
- flac
|
||||
- opus
|
||||
- libvorbis
|
||||
- faad2
|
||||
- wavpack
|
||||
- libmpdclient
|
||||
update: true
|
||||
env:
|
||||
- MATRIX_EVAL=""
|
||||
- MATRIX_EVAL="export PATH=/usr/local/opt/ccache/libexec:$PATH HOMEBREW_NO_ANALYTICS=1"
|
||||
|
||||
cache:
|
||||
- apt
|
||||
- ccache
|
||||
apt: true
|
||||
ccache: true
|
||||
directories:
|
||||
- $HOME/Library/Caches/Homebrew
|
||||
|
||||
before_cache:
|
||||
- test "$TRAVIS_OS_NAME" != "osx" || brew cleanup
|
||||
|
||||
before_install:
|
||||
- eval "${MATRIX_EVAL}"
|
||||
# C++14
|
||||
- test "$TRAVIS_OS_NAME" != "osx" || brew update
|
||||
|
||||
install:
|
||||
# C++14
|
||||
- test "$TRAVIS_OS_NAME" != "osx" || brew install ccache meson
|
||||
- test "$TRAVIS_OS_NAME" != "osx" || brew install --HEAD https://gist.githubusercontent.com/Kronuz/96ac10fbd8472eb1e7566d740c4034f8/raw/gtest.rb
|
||||
|
||||
# Work around "Target /usr/local/lib/libgtest.a is a symlink
|
||||
# belonging to nss. You can unlink it" during gtest install
|
||||
- test "$TRAVIS_OS_NAME" != "osx" || brew unlink nss
|
||||
|
||||
- test "$TRAVIS_OS_NAME" != "osx" || brew install https://gist.githubusercontent.com/Kronuz/96ac10fbd8472eb1e7566d740c4034f8/raw/gtest.rb
|
||||
|
||||
before_script:
|
||||
- ccache -s
|
||||
|
53
NEWS
53
NEWS
@@ -1,3 +1,56 @@
|
||||
ver 0.21.22 (2020/04/02)
|
||||
* database
|
||||
- simple: optimize startup
|
||||
* input
|
||||
- curl: fix streaming errors on Android
|
||||
* playlist
|
||||
- rss: support MIME type application/xml
|
||||
* mixer
|
||||
- android: new mixer plugin for "sles" output
|
||||
* Android
|
||||
- TV support
|
||||
* Windows
|
||||
- fix time zone offset check
|
||||
* fix build failures with uClibc-ng
|
||||
|
||||
ver 0.21.21 (2020/03/19)
|
||||
* configuration
|
||||
- fix bug in "metadata_to_use" setting
|
||||
* playlist
|
||||
- asx, xspf: fix corrupt tags in the presence of XML entities
|
||||
* archive
|
||||
- iso9660: skip empty file names to work around libcdio bug
|
||||
* decoder
|
||||
- gme: ignore empty tags
|
||||
* output
|
||||
- solaris: port to NetBSD
|
||||
* raise default "max_connections" value to 100
|
||||
|
||||
ver 0.21.20 (2020/02/16)
|
||||
* decoder
|
||||
- audiofile, ffmpeg, sndfile: handle MIME type "audio/wav"
|
||||
- ffmpeg: fix playback of AIFF and TTA
|
||||
- vorbis, opus: fix seeking in small files
|
||||
* fix backwards seeking on ARM (and other non-x86 CPUs)
|
||||
|
||||
ver 0.21.19 (2020/01/17)
|
||||
* configuration
|
||||
- allow overriding top-level settings in includes
|
||||
* 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
|
||||
- work around Mac OS X bug in the ISO 8601 parser
|
||||
* output
|
||||
- alsa: fix hang bug with ALSA "null" outputs
|
||||
* storage
|
||||
- curl: fix crash bug
|
||||
* drop support for CURL versions older than 7.32.0
|
||||
* reduce unnecessary CPU wakeups
|
||||
|
||||
ver 0.21.17 (2019/12/16)
|
||||
* protocol
|
||||
- relax the ISO 8601 parser: allow omitting field separators, the
|
||||
|
@@ -2,18 +2,25 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.musicpd"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="40"
|
||||
android:versionName="0.21.17">
|
||||
android:versionCode="45"
|
||||
android:versionName="0.21.22">
|
||||
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="26"/>
|
||||
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="28"/>
|
||||
|
||||
<uses-feature android:name="android.software.leanback"
|
||||
android:required="false" />
|
||||
<uses-feature android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||
<uses-permission android:name="android.permission.INTERNET"/>
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
|
||||
|
||||
<application android:allowBackup="true"
|
||||
android:icon="@drawable/icon"
|
||||
android:banner="@drawable/icon"
|
||||
android:label="@string/app_name">
|
||||
<activity android:name=".Settings"
|
||||
android:label="@string/app_name">
|
||||
@@ -22,6 +29,14 @@
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
<activity android:name=".Settings"
|
||||
android:label="@string/app_name" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LEANBACK_LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<receiver android:name=".Receiver">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||
|
@@ -25,16 +25,15 @@ 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',
|
||||
},
|
||||
|
||||
'arm64-v8a': {
|
||||
'android_api_level': '21',
|
||||
'arch': 'aarch64-linux-android',
|
||||
'ndk_arch': 'arm64',
|
||||
'toolchain_arch': 'aarch64-linux-android',
|
||||
'llvm_triple': 'aarch64-none-linux-android',
|
||||
'llvm_triple': 'aarch64-linux-android',
|
||||
'cflags': '',
|
||||
},
|
||||
|
||||
@@ -42,9 +41,17 @@ 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',
|
||||
},
|
||||
|
||||
'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
|
||||
@@ -76,24 +83,18 @@ 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)
|
||||
llvm_triple = abi_info['llvm_triple']
|
||||
llvm_triple = abi_info['llvm_triple'] + android_api_level
|
||||
|
||||
common_flags = '-Os -g'
|
||||
common_flags += ' -fPIC'
|
||||
@@ -107,6 +108,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')
|
||||
@@ -114,15 +118,11 @@ 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) + \
|
||||
' -D__ANDROID_API__=' + android_api_level
|
||||
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') + \
|
||||
' -Wl,--exclude-libs=ALL' + \
|
||||
' ' + common_flags
|
||||
self.ldflags = common_flags
|
||||
self.libs = ''
|
||||
|
||||
self.is_arm = ndk_arch == 'arm'
|
||||
@@ -130,13 +130,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;
|
||||
|
@@ -21,6 +21,7 @@ package org.musicpd;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
@@ -35,6 +36,9 @@ import android.os.RemoteException;
|
||||
import android.util.Log;
|
||||
import android.widget.RemoteViews;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class Main extends Service implements Runnable {
|
||||
private static final String TAG = "Main";
|
||||
private static final String REMOTE_ERROR = "MPD process was killed";
|
||||
@@ -156,11 +160,36 @@ public class Main extends Service implements Runnable {
|
||||
sendMessage(MSG_SEND_STATUS, mStatus, 0, mError);
|
||||
}
|
||||
|
||||
private Notification.Builder createNotificationBuilderWithChannel() {
|
||||
final NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (notificationManager == null)
|
||||
return null;
|
||||
|
||||
final String id = "org.musicpd";
|
||||
final String name = "MPD service";
|
||||
final int importance = 3; /* NotificationManager.IMPORTANCE_DEFAULT */
|
||||
|
||||
try {
|
||||
Class<?> ncClass = Class.forName("android.app.NotificationChannel");
|
||||
Constructor<?> ncCtor = ncClass.getConstructor(String.class, CharSequence.class, int.class);
|
||||
Object nc = ncCtor.newInstance(id, name, importance);
|
||||
|
||||
Method nmCreateNotificationChannelMethod =
|
||||
NotificationManager.class.getMethod("createNotificationChannel", ncClass);
|
||||
nmCreateNotificationChannelMethod.invoke(notificationManager, nc);
|
||||
|
||||
Constructor nbCtor = Notification.Builder.class.getConstructor(Context.class, String.class);
|
||||
return (Notification.Builder) nbCtor.newInstance(this, id);
|
||||
} catch (Exception e)
|
||||
{
|
||||
Log.e(TAG, "error creating the NotificationChannel", e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void start() {
|
||||
if (mThread != null)
|
||||
return;
|
||||
mThread = new Thread(this);
|
||||
mThread.start();
|
||||
|
||||
final Intent mainIntent = new Intent(this, Settings.class);
|
||||
mainIntent.setAction("android.intent.action.MAIN");
|
||||
@@ -168,13 +197,25 @@ public class Main extends Service implements Runnable {
|
||||
final PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
|
||||
mainIntent, PendingIntent.FLAG_CANCEL_CURRENT);
|
||||
|
||||
Notification notification = new Notification.Builder(this)
|
||||
.setContentTitle(getText(R.string.notification_title_mpd_running))
|
||||
Notification.Builder nBuilder;
|
||||
if (Build.VERSION.SDK_INT >= 26 /* Build.VERSION_CODES.O */)
|
||||
{
|
||||
nBuilder = createNotificationBuilderWithChannel();
|
||||
if (nBuilder == null)
|
||||
return;
|
||||
}
|
||||
else
|
||||
nBuilder = new Notification.Builder(this);
|
||||
|
||||
Notification notification = nBuilder.setContentTitle(getText(R.string.notification_title_mpd_running))
|
||||
.setContentText(getText(R.string.notification_text_mpd_running))
|
||||
.setSmallIcon(R.drawable.notification_icon)
|
||||
.setContentIntent(contentIntent)
|
||||
.build();
|
||||
|
||||
mThread = new Thread(this);
|
||||
mThread.start();
|
||||
|
||||
startForeground(R.string.notification_title_mpd_running, notification);
|
||||
startService(new Intent(this, Main.class));
|
||||
}
|
||||
|
@@ -105,12 +105,13 @@ public class Settings extends Activity {
|
||||
else
|
||||
mRunButton.setChecked(false);
|
||||
mFirstRun = true;
|
||||
mTextStatus.setText("");
|
||||
break;
|
||||
case MSG_STARTED:
|
||||
Log.d(TAG, "onStarted");
|
||||
mRunButton.setChecked(true);
|
||||
mFirstRun = true;
|
||||
mTextStatus.setText("CAUTION: this version is EXPERIMENTAL!"); // XXX
|
||||
mTextStatus.setText("MPD service started");
|
||||
break;
|
||||
case MSG_LOG:
|
||||
if (mLogListArray.size() > MAX_LOGS)
|
||||
|
@@ -38,7 +38,7 @@ author = 'Max Kellermann'
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '0.21.17'
|
||||
version = '0.21.22'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version
|
||||
|
||||
|
@@ -695,7 +695,7 @@ These settings are various limitations to prevent :program:`MPD` from using too
|
||||
* - **connection_timeout SECONDS**
|
||||
- If a client does not send any new data in this time period, the connection is closed. Clients waiting in "idle" mode are excluded from this. Default is 60.
|
||||
* - **max_connections NUMBER**
|
||||
- This specifies the maximum number of clients that can be connected to :program:`MPD` at the same time. Default is 5.
|
||||
- This specifies the maximum number of clients that can be connected to :program:`MPD` at the same time. Default is 100.
|
||||
* - **max_playlist_length NUMBER**
|
||||
- The maximum number of songs that can be in the playlist. Default is 16384.
|
||||
* - **max_command_list_size KBYTES**
|
||||
|
@@ -1,7 +1,7 @@
|
||||
project(
|
||||
'mpd',
|
||||
['c', 'cpp'],
|
||||
version: '0.21.17',
|
||||
version: '0.21.22',
|
||||
meson_version: '>= 0.49.0',
|
||||
default_options: [
|
||||
'c_std=c99',
|
||||
@@ -88,6 +88,10 @@ test_ldflags = [
|
||||
]
|
||||
|
||||
if get_option('buildtype') != 'debug'
|
||||
test_cxxflags += [
|
||||
'-ffunction-sections',
|
||||
'-fdata-sections',
|
||||
]
|
||||
test_cflags += [
|
||||
'-ffunction-sections',
|
||||
'-fdata-sections',
|
||||
@@ -286,6 +290,7 @@ if not is_android
|
||||
else
|
||||
sources += [
|
||||
'src/android/Context.cxx',
|
||||
'src/android/AudioManager.cxx',
|
||||
'src/android/Environment.cxx',
|
||||
'src/android/LogListener.cxx',
|
||||
]
|
||||
@@ -307,6 +312,7 @@ subdir('src/util')
|
||||
subdir('src/time')
|
||||
subdir('src/system')
|
||||
subdir('src/thread')
|
||||
subdir('src/net')
|
||||
subdir('src/event')
|
||||
|
||||
subdir('src/lib/dbus')
|
||||
@@ -331,7 +337,6 @@ subdir('src/lib/yajl')
|
||||
|
||||
subdir('src/fs')
|
||||
subdir('src/config')
|
||||
subdir('src/net')
|
||||
subdir('src/tag')
|
||||
subdir('src/pcm')
|
||||
subdir('src/neighbor')
|
||||
|
@@ -9,8 +9,8 @@ from build.ffmpeg import FfmpegProject
|
||||
from build.boost import BoostProject
|
||||
|
||||
libmpdclient = MesonProject(
|
||||
'https://www.musicpd.org/download/libmpdclient/2/libmpdclient-2.16.tar.xz',
|
||||
'fa6bdab67c0e0490302b38f00c27b4959735c3ec8aef7a88327adb1407654464',
|
||||
'https://www.musicpd.org/download/libmpdclient/2/libmpdclient-2.18.tar.xz',
|
||||
'4cb01e1f567e0169aca94875fb6e1200e7f5ce35b63a4df768ec1591fb1081fa',
|
||||
'lib/libmpdclient.a',
|
||||
)
|
||||
|
||||
@@ -52,8 +52,8 @@ opus = AutotoolsProject(
|
||||
)
|
||||
|
||||
flac = AutotoolsProject(
|
||||
'http://downloads.xiph.org/releases/flac/flac-1.3.2.tar.xz',
|
||||
'91cfc3ed61dc40f47f050a109b08610667d73477af6ef36dcad31c31a4a8d53f',
|
||||
'http://downloads.xiph.org/releases/flac/flac-1.3.3.tar.xz',
|
||||
'213e82bd716c9de6db2f98bcadbc4c24c7e2efe8c75939a1a84e28539c4e1748',
|
||||
'lib/libFLAC.a',
|
||||
[
|
||||
'--disable-shared', '--enable-static',
|
||||
@@ -112,8 +112,8 @@ liblame = AutotoolsProject(
|
||||
)
|
||||
|
||||
ffmpeg = FfmpegProject(
|
||||
'http://ffmpeg.org/releases/ffmpeg-4.2.1.tar.xz',
|
||||
'cec7c87e9b60d174509e263ac4011b522385fd0775292e1670ecc1180c9bb6d4',
|
||||
'http://ffmpeg.org/releases/ffmpeg-4.2.2.tar.xz',
|
||||
'cb754255ab0ee2ea5f66f8850e1bd6ad5cac1cd855d0a2f4990fb8c668b0d29c',
|
||||
'lib/libavcodec.a',
|
||||
[
|
||||
'--disable-shared', '--enable-static',
|
||||
@@ -341,8 +341,8 @@ ffmpeg = FfmpegProject(
|
||||
)
|
||||
|
||||
curl = AutotoolsProject(
|
||||
'http://curl.haxx.se/download/curl-7.66.0.tar.xz',
|
||||
'dbb48088193016d079b97c5c3efde8efa56ada2ebf336e8a97d04eb8e2ed98c1',
|
||||
'http://curl.haxx.se/download/curl-7.69.1.tar.xz',
|
||||
'03c7d5e6697f7b7e40ada1b2256e565a555657398e6c1fcfa4cb251ccd819d4f',
|
||||
'lib/libcurl.a',
|
||||
[
|
||||
'--disable-shared', '--enable-static',
|
||||
@@ -358,6 +358,11 @@ curl = AutotoolsProject(
|
||||
'--disable-manual',
|
||||
'--disable-threaded-resolver', '--disable-verbose', '--disable-sspi',
|
||||
'--disable-crypto-auth', '--disable-ntlm-wb', '--disable-tls-srp', '--disable-cookies',
|
||||
'--disable-doh',
|
||||
'--disable-mime',
|
||||
'--disable-netrc',
|
||||
'--disable-progress-meter',
|
||||
'--disable-alt-svc',
|
||||
'--without-ssl', '--without-gnutls', '--without-nss', '--without-libssh2',
|
||||
],
|
||||
|
||||
@@ -365,8 +370,8 @@ curl = AutotoolsProject(
|
||||
)
|
||||
|
||||
libexpat = AutotoolsProject(
|
||||
'https://github.com/libexpat/libexpat/releases/download/R_2_2_7/expat-2.2.7.tar.bz2',
|
||||
'cbc9102f4a31a8dafd42d642e9a3aa31e79a0aedaa1f6efd2795ebc83174ec18',
|
||||
'https://github.com/libexpat/libexpat/releases/download/R_2_2_9/expat-2.2.9.tar.bz2',
|
||||
'f1063084dc4302a427dabcca499c8312b3a32a29b7d2506653ecc8f950a9a237',
|
||||
'lib/libexpat.a',
|
||||
[
|
||||
'--disable-shared', '--enable-static',
|
||||
@@ -392,7 +397,7 @@ libnfs = AutotoolsProject(
|
||||
)
|
||||
|
||||
boost = BoostProject(
|
||||
'https://dl.bintray.com/boostorg/release/1.71.0/source/boost_1_71_0.tar.bz2',
|
||||
'd73a8da01e8bf8c7eda40b4c84915071a8c8a0df4a6734537ddde4a8580524ee',
|
||||
'https://dl.bintray.com/boostorg/release/1.72.0/source/boost_1_72_0.tar.bz2',
|
||||
'59c9b274bc451cf91a9ba1dd2c7fdcaf5d60b1b3aa83f2c9fa143417cc660722',
|
||||
'include/boost/version.hpp',
|
||||
)
|
||||
|
@@ -33,11 +33,11 @@
|
||||
#include "playlist/PlaylistRegistry.hxx"
|
||||
#include "playlist/PlaylistPlugin.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "fs/Traits.hxx"
|
||||
#include "fs/FileSystem.hxx"
|
||||
#include "fs/StandardDirectory.hxx"
|
||||
#include "system/Error.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/OptionDef.hxx"
|
||||
@@ -380,17 +380,7 @@ ParseCommandLine(int argc, char **argv, struct options &options,
|
||||
|
||||
if (config_file != nullptr) {
|
||||
/* use specified configuration file */
|
||||
#ifdef _UNICODE
|
||||
wchar_t buffer[MAX_PATH];
|
||||
auto result = MultiByteToWideChar(CP_ACP, 0, config_file, -1,
|
||||
buffer, ARRAY_SIZE(buffer));
|
||||
if (result <= 0)
|
||||
throw MakeLastError("MultiByteToWideChar() failed");
|
||||
|
||||
ReadConfigFile(config, Path::FromFS(buffer));
|
||||
#else
|
||||
ReadConfigFile(config, Path::FromFS(config_file));
|
||||
#endif
|
||||
ReadConfigFile(config, FromNarrowPath(config_file));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@@ -460,7 +460,7 @@ MainOrThrow(int argc, char *argv[])
|
||||
#endif
|
||||
|
||||
const unsigned max_clients =
|
||||
raw_config.GetPositive(ConfigOption::MAX_CONN, 10);
|
||||
raw_config.GetPositive(ConfigOption::MAX_CONN, 100);
|
||||
instance->client_list = new ClientList(max_clients);
|
||||
|
||||
initialize_decoder_and_player(raw_config, config.replay_gain);
|
||||
|
@@ -29,9 +29,9 @@
|
||||
#include "system/Clock.hxx"
|
||||
#include "Log.hxx"
|
||||
#include "time/ChronoUtil.hxx"
|
||||
#include "util/Math.hxx"
|
||||
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
|
||||
#ifndef _WIN32
|
||||
/**
|
||||
@@ -121,7 +121,7 @@ stats_print(Response &r, const Partition &partition)
|
||||
#else
|
||||
(unsigned)std::chrono::duration_cast<std::chrono::seconds>(std::chrono::steady_clock::now() - start_time).count(),
|
||||
#endif
|
||||
std::lround(partition.pc.GetTotalPlayTime().count()));
|
||||
lround(partition.pc.GetTotalPlayTime().count()));
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
const Database *db = partition.instance.GetDatabase();
|
||||
|
56
src/android/AudioManager.cxx
Normal file
56
src/android/AudioManager.cxx
Normal file
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2003-2020 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "AudioManager.hxx"
|
||||
#include "java/Class.hxx"
|
||||
#include "java/Exception.hxx"
|
||||
#include "java/File.hxx"
|
||||
|
||||
#define STREAM_MUSIC 3
|
||||
|
||||
AudioManager::AudioManager(JNIEnv *env, jobject obj) noexcept
|
||||
: Java::GlobalObject(env, obj)
|
||||
{
|
||||
Java::Class cls(env, env->GetObjectClass(Get()));
|
||||
jmethodID method = env->GetMethodID(cls, "getStreamMaxVolume", "(I)I");
|
||||
assert(method);
|
||||
maxVolume = env->CallIntMethod(Get(), method, STREAM_MUSIC);
|
||||
|
||||
getStreamVolumeMethod = env->GetMethodID(cls, "getStreamVolume", "(I)I");
|
||||
assert(getStreamVolumeMethod);
|
||||
|
||||
setStreamVolumeMethod = env->GetMethodID(cls, "setStreamVolume", "(III)V");
|
||||
assert(setStreamVolumeMethod);
|
||||
}
|
||||
|
||||
int
|
||||
AudioManager::GetVolume(JNIEnv *env)
|
||||
{
|
||||
if (maxVolume == 0)
|
||||
return 0;
|
||||
return env->CallIntMethod(Get(), getStreamVolumeMethod, STREAM_MUSIC);
|
||||
}
|
||||
|
||||
void
|
||||
AudioManager::SetVolume(JNIEnv *env, int volume)
|
||||
{
|
||||
if (maxVolume == 0)
|
||||
return;
|
||||
env->CallVoidMethod(Get(), setStreamVolumeMethod, STREAM_MUSIC, volume, 0);
|
||||
}
|
42
src/android/AudioManager.hxx
Normal file
42
src/android/AudioManager.hxx
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2003-2020 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef MPD_ANDROID_AUDIO_MANAGER_HXX
|
||||
#define MPD_ANDROID_AUDIO_MANAGER_HXX
|
||||
|
||||
#include "java/Object.hxx"
|
||||
|
||||
class AudioManager : public Java::GlobalObject {
|
||||
int maxVolume;
|
||||
jmethodID getStreamVolumeMethod;
|
||||
jmethodID setStreamVolumeMethod;
|
||||
|
||||
public:
|
||||
AudioManager(JNIEnv *env, jobject obj) noexcept;
|
||||
|
||||
AudioManager(std::nullptr_t) noexcept { maxVolume = 0; }
|
||||
|
||||
~AudioManager() noexcept {}
|
||||
|
||||
int GetMaxVolume() { return maxVolume; }
|
||||
int GetVolume(JNIEnv *env);
|
||||
void SetVolume(JNIEnv *env, int);
|
||||
};
|
||||
|
||||
#endif
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2018 The Music Player Daemon Project
|
||||
* Copyright 2003-2019 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -20,10 +20,13 @@
|
||||
#include "Context.hxx"
|
||||
#include "java/Class.hxx"
|
||||
#include "java/File.hxx"
|
||||
#include "java/String.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
|
||||
#include "AudioManager.hxx"
|
||||
|
||||
AllocatedPath
|
||||
Context::GetCacheDir(JNIEnv *env) const
|
||||
Context::GetCacheDir(JNIEnv *env) const noexcept
|
||||
{
|
||||
assert(env != nullptr);
|
||||
|
||||
@@ -40,3 +43,21 @@ Context::GetCacheDir(JNIEnv *env) const
|
||||
|
||||
return Java::File::ToAbsolutePath(env, file);
|
||||
}
|
||||
|
||||
AudioManager *
|
||||
Context::GetAudioManager(JNIEnv *env) noexcept
|
||||
{
|
||||
assert(env != nullptr);
|
||||
|
||||
Java::Class cls(env, env->GetObjectClass(Get()));
|
||||
jmethodID method = env->GetMethodID(cls, "getSystemService",
|
||||
"(Ljava/lang/String;)Ljava/lang/Object;");
|
||||
assert(method);
|
||||
|
||||
Java::String name(env, "audio");
|
||||
jobject am = env->CallObjectMethod(Get(), method, name.Get());
|
||||
if (Java::DiscardException(env) || am == nullptr)
|
||||
return nullptr;
|
||||
|
||||
return new AudioManager(env, am);
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2003-2018 The Music Player Daemon Project
|
||||
* Copyright 2003-2019 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -23,13 +23,18 @@
|
||||
#include "java/Object.hxx"
|
||||
|
||||
class AllocatedPath;
|
||||
class AudioManager;
|
||||
|
||||
class Context : public Java::Object {
|
||||
class Context : public Java::GlobalObject {
|
||||
public:
|
||||
Context(JNIEnv *env, jobject obj):Java::Object(env, obj) {}
|
||||
Context(JNIEnv *env, jobject obj) noexcept
|
||||
:Java::GlobalObject(env, obj) {}
|
||||
|
||||
gcc_pure
|
||||
AllocatedPath GetCacheDir(JNIEnv *env) const;
|
||||
AllocatedPath GetCacheDir(JNIEnv *env) const noexcept;
|
||||
|
||||
gcc_pure
|
||||
AudioManager *GetAudioManager(JNIEnv *env) noexcept;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -22,9 +22,9 @@
|
||||
|
||||
#include "java/Object.hxx"
|
||||
|
||||
class LogListener : public Java::Object {
|
||||
class LogListener : public Java::GlobalObject {
|
||||
public:
|
||||
LogListener(JNIEnv *env, jobject obj):Java::Object(env, obj) {}
|
||||
LogListener(JNIEnv *env, jobject obj):Java::GlobalObject(env, obj) {}
|
||||
|
||||
void OnLog(JNIEnv *env, int priority, const char *fmt, ...) const;
|
||||
};
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "input/InputStream.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
|
||||
#include <cdio/iso9660.h>
|
||||
|
||||
@@ -93,7 +94,10 @@ Iso9660ArchiveFile::Visit(char *path, size_t length, size_t capacity,
|
||||
auto *statbuf = (iso9660_stat_t *)
|
||||
_cdio_list_node_data(entnode);
|
||||
const char *filename = statbuf->filename;
|
||||
if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0)
|
||||
if (StringIsEmpty(filename) ||
|
||||
PathTraitsUTF8::IsSpecialFilename(filename))
|
||||
/* skip empty names (libcdio bug?) */
|
||||
/* skip special names like "." and ".." */
|
||||
continue;
|
||||
|
||||
size_t filename_length = strlen(filename);
|
||||
|
@@ -34,13 +34,12 @@
|
||||
#include "util/StringBuffer.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/Exception.hxx"
|
||||
#include "util/Math.hxx"
|
||||
|
||||
#ifdef ENABLE_DATABASE
|
||||
#include "db/update/Service.hxx"
|
||||
#endif
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#define COMMAND_STATUS_STATE "state"
|
||||
#define COMMAND_STATUS_REPEAT "repeat"
|
||||
#define COMMAND_STATUS_SINGLE "single"
|
||||
@@ -154,7 +153,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
|
||||
|
||||
if (pc.GetCrossFade() > FloatDuration::zero())
|
||||
r.Format(COMMAND_STATUS_CROSSFADE ": %lu\n",
|
||||
std::lround(pc.GetCrossFade().count()));
|
||||
lround(pc.GetCrossFade().count()));
|
||||
|
||||
if (pc.GetMixRampDelay() > FloatDuration::zero())
|
||||
r.Format(COMMAND_STATUS_MIXRAMPDELAY ": %f\n",
|
||||
@@ -173,7 +172,7 @@ handle_status(Client &client, gcc_unused Request args, Response &r)
|
||||
COMMAND_STATUS_BITRATE ": %u\n",
|
||||
player_status.elapsed_time.RoundS(),
|
||||
player_status.total_time.IsNegative()
|
||||
? 0u
|
||||
? 0U
|
||||
: unsigned(player_status.total_time.RoundS()),
|
||||
player_status.elapsed_time.ToDoubleS(),
|
||||
player_status.bit_rate);
|
||||
|
@@ -153,11 +153,9 @@ ReadConfigParam(ConfigData &config_data, BufferedReader &reader,
|
||||
name, reader.GetLineNumber());
|
||||
|
||||
if (!option.repeatable)
|
||||
if (const auto *param = config_data.GetParam(o))
|
||||
throw FormatRuntimeError("config parameter \"%s\" is first defined "
|
||||
"on line %d and redefined on line %u\n",
|
||||
name, param->line,
|
||||
reader.GetLineNumber());
|
||||
/* if the option is not repeatable, override the old
|
||||
value by removing it first */
|
||||
config_data.GetParamList(o).clear();
|
||||
|
||||
/* now parse the block or the value */
|
||||
|
||||
|
@@ -448,7 +448,7 @@ ProxyDatabase::ProxyDatabase(EventLoop &_loop, DatabaseListener &_listener,
|
||||
listener(_listener),
|
||||
host(block.GetBlockValue("host", "")),
|
||||
password(block.GetBlockValue("password", "")),
|
||||
port(block.GetBlockValue("port", 0u)),
|
||||
port(block.GetBlockValue("port", 0U)),
|
||||
keepalive(block.GetBlockValue("keepalive", false))
|
||||
{
|
||||
}
|
||||
@@ -517,7 +517,7 @@ ProxyDatabase::Connect()
|
||||
(void)keepalive;
|
||||
#endif
|
||||
|
||||
idle_received = ~0u;
|
||||
idle_received = ~0U;
|
||||
is_idle = false;
|
||||
|
||||
SocketMonitor::Open(SocketDescriptor(mpd_async_get_fd(mpd_connection_get_async(connection))));
|
||||
|
@@ -32,6 +32,7 @@
|
||||
#include "fs/Traits.hxx"
|
||||
#include "util/Alloc.hxx"
|
||||
#include "util/DeleteDisposer.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
@@ -69,7 +70,15 @@ Directory::GetName() const noexcept
|
||||
{
|
||||
assert(!IsRoot());
|
||||
|
||||
return PathTraitsUTF8::GetBase(path.c_str());
|
||||
if (parent->IsRoot())
|
||||
return path.c_str();
|
||||
|
||||
assert(StringAfterPrefix(path.c_str(), parent->path.c_str()) != nullptr);
|
||||
assert(*StringAfterPrefix(path.c_str(), parent->path.c_str()) == PathTraitsUTF8::SEPARATOR);
|
||||
|
||||
/* strip the parent directory path and the slash separator
|
||||
from this directory's path, and the base name remains */
|
||||
return path.c_str() + parent->path.length() + 1;
|
||||
}
|
||||
|
||||
Directory *
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "storage/StorageInterface.hxx"
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "fs/FileInfo.hxx"
|
||||
#include "fs/Traits.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <string>
|
||||
@@ -146,8 +147,7 @@ WatchDirectory::GetUriFS() const noexcept
|
||||
/* we don't look at "." / ".." nor files with newlines in their name */
|
||||
static bool skip_path(const char *path)
|
||||
{
|
||||
return (path[0] == '.' && path[1] == 0) ||
|
||||
(path[0] == '.' && path[1] == '.' && path[2] == 0) ||
|
||||
return PathTraitsFS::IsSpecialFilename(path) ||
|
||||
strchr(path, '\n') != nullptr;
|
||||
}
|
||||
|
||||
|
@@ -66,7 +66,7 @@ public:
|
||||
|
||||
~UpdateService();
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return defer.GetEventLoop();
|
||||
}
|
||||
|
||||
|
@@ -237,7 +237,7 @@ try {
|
||||
LogError(std::current_exception());
|
||||
}
|
||||
|
||||
/* we don't look at "." / ".." nor files with newlines in their name */
|
||||
/* we don't look at files with newlines in their name */
|
||||
gcc_pure
|
||||
static bool
|
||||
skip_path(const char *name_utf8) noexcept
|
||||
|
@@ -41,7 +41,7 @@ adplug_init(const ConfigBlock &block)
|
||||
FormatDebug(adplug_domain, "adplug %s",
|
||||
CAdPlug::get_version().c_str());
|
||||
|
||||
sample_rate = block.GetPositiveValue("sample_rate", 48000u);
|
||||
sample_rate = block.GetPositiveValue("sample_rate", 48000U);
|
||||
CheckSampleRate(sample_rate);
|
||||
|
||||
return true;
|
||||
|
@@ -269,6 +269,8 @@ static const char *const audiofile_suffixes[] = {
|
||||
};
|
||||
|
||||
static const char *const audiofile_mime_types[] = {
|
||||
"audio/wav",
|
||||
"audio/aiff",
|
||||
"audio/x-wav",
|
||||
"audio/x-aiff",
|
||||
nullptr
|
||||
|
@@ -26,11 +26,11 @@
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Math.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <neaacdec.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <exception>
|
||||
|
||||
#include <assert.h>
|
||||
|
@@ -297,7 +297,7 @@ FfmpegReceiveFrames(DecoderClient &client, InputStream &is,
|
||||
*/
|
||||
static DecoderCommand
|
||||
ffmpeg_send_packet(DecoderClient &client, InputStream &is,
|
||||
AVPacket &&packet,
|
||||
const AVPacket &packet,
|
||||
AVCodecContext &codec_context,
|
||||
const AVStream &stream,
|
||||
AVFrame &frame,
|
||||
@@ -350,24 +350,6 @@ ffmpeg_send_packet(DecoderClient &client, InputStream &is,
|
||||
return cmd;
|
||||
}
|
||||
|
||||
static DecoderCommand
|
||||
ffmpeg_send_packet(DecoderClient &client, InputStream &is,
|
||||
const AVPacket &packet,
|
||||
AVCodecContext &codec_context,
|
||||
const AVStream &stream,
|
||||
AVFrame &frame,
|
||||
uint64_t min_frame, size_t pcm_frame_size,
|
||||
FfmpegBuffer &buffer)
|
||||
{
|
||||
return ffmpeg_send_packet(client, is,
|
||||
/* copy the AVPacket, because FFmpeg
|
||||
< 3.0 requires this */
|
||||
AVPacket(packet),
|
||||
codec_context, stream,
|
||||
frame, min_frame, pcm_frame_size,
|
||||
buffer);
|
||||
}
|
||||
|
||||
gcc_const
|
||||
static SampleFormat
|
||||
ffmpeg_sample_format(enum AVSampleFormat sample_fmt) noexcept
|
||||
@@ -762,7 +744,7 @@ static const char *const ffmpeg_mime_types[] = {
|
||||
"audio/aac",
|
||||
"audio/aacp",
|
||||
"audio/ac3",
|
||||
"audio/aiff"
|
||||
"audio/aiff",
|
||||
"audio/amr",
|
||||
"audio/basic",
|
||||
"audio/flac",
|
||||
@@ -775,12 +757,13 @@ static const char *const ffmpeg_mime_types[] = {
|
||||
"audio/qcelp",
|
||||
"audio/vorbis",
|
||||
"audio/vorbis+ogg",
|
||||
"audio/wav",
|
||||
"audio/x-8svx",
|
||||
"audio/x-16sv",
|
||||
"audio/x-aac",
|
||||
"audio/x-ac3",
|
||||
"audio/x-adx",
|
||||
"audio/x-aiff"
|
||||
"audio/x-aiff",
|
||||
"audio/x-alaw",
|
||||
"audio/x-au",
|
||||
"audio/x-dca",
|
||||
@@ -800,7 +783,7 @@ static const char *const ffmpeg_mime_types[] = {
|
||||
"audio/x-pn-realaudio",
|
||||
"audio/x-pn-multirate-realaudio",
|
||||
"audio/x-speex",
|
||||
"audio/x-tta"
|
||||
"audio/x-tta",
|
||||
"audio/x-voc",
|
||||
"audio/x-wav",
|
||||
"audio/x-wma",
|
||||
|
@@ -78,7 +78,7 @@ fluidsynth_mpd_log_function(int level,
|
||||
static bool
|
||||
fluidsynth_init(const ConfigBlock &block)
|
||||
{
|
||||
sample_rate = block.GetPositiveValue("sample_rate", 48000u);
|
||||
sample_rate = block.GetPositiveValue("sample_rate", 48000U);
|
||||
CheckSampleRate(sample_rate);
|
||||
|
||||
soundfont_path = block.GetBlockValue("soundfont",
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "fs/AllocatedPath.hxx"
|
||||
#include "fs/FileSystem.hxx"
|
||||
#include "util/ScopeExit.hxx"
|
||||
#include "util/StringCompare.hxx"
|
||||
#include "util/StringFormat.hxx"
|
||||
#include "util/UriUtil.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
@@ -222,7 +223,7 @@ ScanGmeInfo(const gme_info_t &info, unsigned song_num, int track_count,
|
||||
if (track_count > 1)
|
||||
handler.OnTag(TAG_TRACK, StringFormat<16>("%u", song_num + 1));
|
||||
|
||||
if (info.song != nullptr) {
|
||||
if (!StringIsEmpty(info.song)) {
|
||||
if (track_count > 1) {
|
||||
/* start numbering subtunes from 1 */
|
||||
const auto tag_title =
|
||||
@@ -234,16 +235,16 @@ ScanGmeInfo(const gme_info_t &info, unsigned song_num, int track_count,
|
||||
handler.OnTag(TAG_TITLE, info.song);
|
||||
}
|
||||
|
||||
if (info.author != nullptr)
|
||||
if (!StringIsEmpty(info.author))
|
||||
handler.OnTag(TAG_ARTIST, info.author);
|
||||
|
||||
if (info.game != nullptr)
|
||||
if (!StringIsEmpty(info.game))
|
||||
handler.OnTag(TAG_ALBUM, info.game);
|
||||
|
||||
if (info.comment != nullptr)
|
||||
if (!StringIsEmpty(info.comment))
|
||||
handler.OnTag(TAG_COMMENT, info.comment);
|
||||
|
||||
if (info.copyright != nullptr)
|
||||
if (!StringIsEmpty(info.copyright))
|
||||
handler.OnTag(TAG_DATE, info.copyright);
|
||||
}
|
||||
|
||||
|
@@ -186,7 +186,7 @@ HybridDsdDecode(DecoderClient &client, InputStream &input)
|
||||
client.Ready(result.first, true, duration);
|
||||
frame_size = result.first.GetFrameSize();
|
||||
kbit_rate = frame_size * result.first.sample_rate /
|
||||
(1024u / 8u);
|
||||
(1024U / 8U);
|
||||
total_frames = result.second / frame_size;
|
||||
} catch (UnsupportedFile) {
|
||||
/* not a Hybrid-DSD file; let the next decoder plugin
|
||||
@@ -236,7 +236,7 @@ HybridDsdDecode(DecoderClient &client, InputStream &input)
|
||||
/* fill the buffer */
|
||||
auto w = buffer.Write();
|
||||
if (!w.empty()) {
|
||||
if (remaining_bytes < (1<<30ull) &&
|
||||
if (remaining_bytes < (1<<30ULL) &&
|
||||
w.size > size_t(remaining_bytes))
|
||||
w.size = remaining_bytes;
|
||||
|
||||
|
@@ -793,7 +793,7 @@ MadDecoder::DecodeFirstFrame(Tag *tag) noexcept
|
||||
|
||||
if (max_frames > 8 * 1024 * 1024) {
|
||||
FormatWarning(mad_domain,
|
||||
"mp3 file header indicates too many frames: %lu",
|
||||
"mp3 file header indicates too many frames: %zu",
|
||||
max_frames);
|
||||
return false;
|
||||
}
|
||||
|
@@ -107,7 +107,7 @@ mikmod_decoder_init(const ConfigBlock &block)
|
||||
static char params[] = "";
|
||||
|
||||
mikmod_loop = block.GetBlockValue("loop", false);
|
||||
mikmod_sample_rate = block.GetPositiveValue("sample_rate", 44100u);
|
||||
mikmod_sample_rate = block.GetPositiveValue("sample_rate", 44100U);
|
||||
if (!audio_valid_sample_rate(mikmod_sample_rate))
|
||||
throw FormatRuntimeError("Invalid sample rate in line %d: %u",
|
||||
block.line, mikmod_sample_rate);
|
||||
|
@@ -47,8 +47,12 @@ OggDecoder::LoadEndPacket(ogg_packet &packet) const
|
||||
DecoderReader reader(client, input_stream);
|
||||
OggSyncState sync2(reader);
|
||||
OggStreamState stream2(GetSerialNo());
|
||||
|
||||
/* passing synced=false because we're inside an
|
||||
OggVisitor callback, and our InputStream may be in
|
||||
the middle of an Ogg packet */
|
||||
result = OggSeekFindEOS(sync2, stream2, packet,
|
||||
input_stream);
|
||||
input_stream, false);
|
||||
}
|
||||
|
||||
/* restore the previous file position */
|
||||
|
@@ -115,7 +115,7 @@ sidplay_init(const ConfigBlock &block)
|
||||
if (!database_path.IsNull())
|
||||
songlength_database = sidplay_load_songlength_db(database_path);
|
||||
|
||||
default_songlength = block.GetPositiveValue("default_songlength", 0u);
|
||||
default_songlength = block.GetPositiveValue("default_songlength", 0U);
|
||||
|
||||
all_files_are_containers =
|
||||
block.GetBlockValue("all_files_are_containers", true);
|
||||
@@ -387,7 +387,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
|
||||
const unsigned timebase = player.timebase();
|
||||
#endif
|
||||
const unsigned end = duration.IsNegative()
|
||||
? 0u
|
||||
? 0U
|
||||
: duration.ToScale<uint64_t>(timebase);
|
||||
|
||||
DecoderCommand cmd;
|
||||
|
@@ -322,6 +322,8 @@ static const char *const sndfile_suffixes[] = {
|
||||
};
|
||||
|
||||
static const char *const sndfile_mime_types[] = {
|
||||
"audio/wav",
|
||||
"audio/aiff",
|
||||
"audio/x-wav",
|
||||
"audio/x-aiff",
|
||||
|
||||
|
@@ -94,7 +94,7 @@ public:
|
||||
};
|
||||
|
||||
PreparedFlacEncoder::PreparedFlacEncoder(const ConfigBlock &block)
|
||||
:compression(block.GetBlockValue("compression", 5u))
|
||||
:compression(block.GetBlockValue("compression", 5U))
|
||||
{
|
||||
}
|
||||
|
||||
|
@@ -107,7 +107,7 @@ PreparedOpusEncoder::PreparedOpusEncoder(const ConfigBlock &block)
|
||||
throw std::runtime_error("Invalid bit rate");
|
||||
}
|
||||
|
||||
complexity = block.GetBlockValue("complexity", 10u);
|
||||
complexity = block.GetBlockValue("complexity", 10U);
|
||||
if (complexity > 10)
|
||||
throw std::runtime_error("Invalid complexity");
|
||||
|
||||
|
@@ -50,7 +50,7 @@ public:
|
||||
Cancel();
|
||||
}
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
EventLoop &GetEventLoop() const noexcept {
|
||||
return loop;
|
||||
}
|
||||
|
||||
|
@@ -137,7 +137,8 @@ static constexpr int
|
||||
ExportTimeoutMS(std::chrono::steady_clock::duration timeout)
|
||||
{
|
||||
return timeout >= timeout.zero()
|
||||
? int(std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count())
|
||||
/* round up (+1) to avoid unnecessary wakeups */
|
||||
? int(std::chrono::duration_cast<std::chrono::milliseconds>(timeout).count()) + 1
|
||||
: -1;
|
||||
}
|
||||
|
||||
@@ -220,7 +221,6 @@ EventLoop::Run() noexcept
|
||||
} while (!quit);
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert(busy);
|
||||
assert(thread.IsInside());
|
||||
#endif
|
||||
}
|
||||
|
@@ -44,7 +44,7 @@ public:
|
||||
:defer(_loop, BIND_THIS_METHOD(RunDeferred)),
|
||||
callback(_callback), pending_mask(0) {}
|
||||
|
||||
EventLoop &GetEventLoop() {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return defer.GetEventLoop();
|
||||
}
|
||||
|
||||
|
@@ -22,6 +22,10 @@
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#ifdef USE_EPOLL
|
||||
#include <errno.h>
|
||||
#endif
|
||||
|
||||
#ifndef _WIN32
|
||||
#include <poll.h>
|
||||
#endif
|
||||
@@ -37,17 +41,42 @@ MultiSocketMonitor::Reset() noexcept
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
fds.clear();
|
||||
#ifdef USE_EPOLL
|
||||
always_ready_fds.clear();
|
||||
#endif
|
||||
IdleMonitor::Cancel();
|
||||
timeout_event.Cancel();
|
||||
ready = refresh = false;
|
||||
}
|
||||
|
||||
bool
|
||||
MultiSocketMonitor::AddSocket(SocketDescriptor fd, unsigned events) noexcept
|
||||
{
|
||||
fds.emplace_front(*this, fd);
|
||||
bool success = fds.front().Schedule(events);
|
||||
if (!success) {
|
||||
fds.pop_front();
|
||||
|
||||
#ifdef USE_EPOLL
|
||||
if (errno == EPERM)
|
||||
/* not supported by epoll (e.g. "/dev/null"):
|
||||
add it to the "always ready" list */
|
||||
always_ready_fds.push_front({fd, events});
|
||||
#endif
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
void
|
||||
MultiSocketMonitor::ClearSocketList() noexcept
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
fds.clear();
|
||||
#ifdef USE_EPOLL
|
||||
always_ready_fds.clear();
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifndef _WIN32
|
||||
@@ -55,6 +84,10 @@ MultiSocketMonitor::ClearSocketList() noexcept
|
||||
void
|
||||
MultiSocketMonitor::ReplaceSocketList(pollfd *pfds, unsigned n) noexcept
|
||||
{
|
||||
#ifdef USE_EPOLL
|
||||
always_ready_fds.clear();
|
||||
#endif
|
||||
|
||||
pollfd *const end = pfds + n;
|
||||
|
||||
UpdateSocketList([pfds, end](SocketDescriptor fd) -> unsigned {
|
||||
@@ -64,9 +97,7 @@ MultiSocketMonitor::ReplaceSocketList(pollfd *pfds, unsigned n) noexcept
|
||||
if (i == end)
|
||||
return 0;
|
||||
|
||||
auto events = i->events;
|
||||
i->events = 0;
|
||||
return events;
|
||||
return std::exchange(i->events, 0);
|
||||
});
|
||||
|
||||
for (auto i = pfds; i != end; ++i)
|
||||
@@ -79,7 +110,20 @@ MultiSocketMonitor::ReplaceSocketList(pollfd *pfds, unsigned n) noexcept
|
||||
void
|
||||
MultiSocketMonitor::Prepare() noexcept
|
||||
{
|
||||
const auto timeout = PrepareSockets();
|
||||
auto timeout = PrepareSockets();
|
||||
|
||||
#ifdef USE_EPOLL
|
||||
if (!always_ready_fds.empty()) {
|
||||
/* if there was at least one file descriptor not
|
||||
supported by epoll, install a very short timeout
|
||||
because we assume it's always ready */
|
||||
constexpr std::chrono::steady_clock::duration ready_timeout =
|
||||
std::chrono::milliseconds(1);
|
||||
if (timeout < timeout.zero() || timeout > ready_timeout)
|
||||
timeout = ready_timeout;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (timeout >= timeout.zero())
|
||||
timeout_event.Schedule(timeout);
|
||||
else
|
||||
|
@@ -50,12 +50,10 @@ class MultiSocketMonitor : IdleMonitor
|
||||
unsigned revents;
|
||||
|
||||
public:
|
||||
SingleFD(MultiSocketMonitor &_multi, SocketDescriptor _fd,
|
||||
unsigned events) noexcept
|
||||
SingleFD(MultiSocketMonitor &_multi,
|
||||
SocketDescriptor _fd) noexcept
|
||||
:SocketMonitor(_fd, _multi.GetEventLoop()),
|
||||
multi(_multi), revents(0) {
|
||||
Schedule(events);
|
||||
}
|
||||
multi(_multi), revents(0) {}
|
||||
|
||||
SocketDescriptor GetSocket() const noexcept {
|
||||
return SocketMonitor::GetSocket();
|
||||
@@ -86,8 +84,6 @@ class MultiSocketMonitor : IdleMonitor
|
||||
}
|
||||
};
|
||||
|
||||
friend class SingleFD;
|
||||
|
||||
TimerEvent timeout_event;
|
||||
|
||||
/**
|
||||
@@ -106,6 +102,21 @@ class MultiSocketMonitor : IdleMonitor
|
||||
|
||||
std::forward_list<SingleFD> fds;
|
||||
|
||||
#ifdef USE_EPOLL
|
||||
struct AlwaysReady {
|
||||
const SocketDescriptor fd;
|
||||
const unsigned revents;
|
||||
};
|
||||
|
||||
/**
|
||||
* A list of file descriptors which are always ready. This is
|
||||
* a kludge needed because the ALSA output plugin gives us a
|
||||
* file descriptor to /dev/null, which is incompatible with
|
||||
* epoll (epoll_ctl() returns -EPERM).
|
||||
*/
|
||||
std::forward_list<AlwaysReady> always_ready_fds;
|
||||
#endif
|
||||
|
||||
public:
|
||||
static constexpr unsigned READ = SocketMonitor::READ;
|
||||
static constexpr unsigned WRITE = SocketMonitor::WRITE;
|
||||
@@ -147,9 +158,7 @@ public:
|
||||
*
|
||||
* May only be called from PrepareSockets().
|
||||
*/
|
||||
void AddSocket(SocketDescriptor fd, unsigned events) noexcept {
|
||||
fds.emplace_front(*this, fd, events);
|
||||
}
|
||||
bool AddSocket(SocketDescriptor fd, unsigned events) noexcept;
|
||||
|
||||
/**
|
||||
* Remove all sockets.
|
||||
@@ -204,6 +213,11 @@ public:
|
||||
i.ClearReturnedEvents();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef USE_EPOLL
|
||||
for (const auto &i : always_ready_fds)
|
||||
f(i.fd, i.revents);
|
||||
#endif
|
||||
}
|
||||
|
||||
protected:
|
||||
@@ -232,7 +246,6 @@ private:
|
||||
|
||||
void OnTimeout() noexcept {
|
||||
SetReady();
|
||||
IdleMonitor::Schedule();
|
||||
}
|
||||
|
||||
virtual void OnIdle() noexcept final;
|
||||
|
@@ -68,20 +68,24 @@ SocketMonitor::Close() noexcept
|
||||
Steal().Close();
|
||||
}
|
||||
|
||||
void
|
||||
bool
|
||||
SocketMonitor::Schedule(unsigned flags) noexcept
|
||||
{
|
||||
assert(IsDefined());
|
||||
|
||||
if (flags == GetScheduledFlags())
|
||||
return;
|
||||
return true;
|
||||
|
||||
bool success;
|
||||
if (scheduled_flags == 0)
|
||||
loop.AddFD(fd.Get(), flags, *this);
|
||||
success = loop.AddFD(fd.Get(), flags, *this);
|
||||
else if (flags == 0)
|
||||
loop.RemoveFD(fd.Get(), *this);
|
||||
success = loop.RemoveFD(fd.Get(), *this);
|
||||
else
|
||||
loop.ModifyFD(fd.Get(), flags, *this);
|
||||
success = loop.ModifyFD(fd.Get(), flags, *this);
|
||||
|
||||
scheduled_flags = flags;
|
||||
if (success)
|
||||
scheduled_flags = flags;
|
||||
|
||||
return success;
|
||||
}
|
||||
|
@@ -68,7 +68,7 @@ public:
|
||||
|
||||
~SocketMonitor() noexcept;
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return loop;
|
||||
}
|
||||
|
||||
@@ -98,18 +98,22 @@ public:
|
||||
return scheduled_flags;
|
||||
}
|
||||
|
||||
void Schedule(unsigned flags) noexcept;
|
||||
/**
|
||||
* @return true on success, false on error (with errno set if
|
||||
* USE_EPOLL is defined)
|
||||
*/
|
||||
bool Schedule(unsigned flags) noexcept;
|
||||
|
||||
void Cancel() noexcept {
|
||||
Schedule(0);
|
||||
}
|
||||
|
||||
void ScheduleRead() noexcept {
|
||||
Schedule(GetScheduledFlags() | READ | HANGUP | ERROR);
|
||||
bool ScheduleRead() noexcept {
|
||||
return Schedule(GetScheduledFlags() | READ | HANGUP | ERROR);
|
||||
}
|
||||
|
||||
void ScheduleWrite() noexcept {
|
||||
Schedule(GetScheduledFlags() | WRITE);
|
||||
bool ScheduleWrite() noexcept {
|
||||
return Schedule(GetScheduledFlags() | WRITE);
|
||||
}
|
||||
|
||||
void CancelRead() noexcept {
|
||||
|
@@ -62,7 +62,7 @@ public:
|
||||
Cancel();
|
||||
}
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return loop;
|
||||
}
|
||||
|
||||
|
@@ -25,6 +25,7 @@ event_dep = declare_dependency(
|
||||
link_with: event,
|
||||
dependencies: [
|
||||
thread_dep,
|
||||
net_dep,
|
||||
system_dep,
|
||||
boost_dep,
|
||||
],
|
||||
|
55
src/fs/NarrowPath.cxx
Normal file
55
src/fs/NarrowPath.cxx
Normal file
@@ -0,0 +1,55 @@
|
||||
/*
|
||||
* Copyright 2003-2018 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "NarrowPath.hxx"
|
||||
|
||||
#ifdef _UNICODE
|
||||
|
||||
#include "lib/icu/Win32.hxx"
|
||||
#include "system/Error.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
NarrowPath::NarrowPath(Path _path) noexcept
|
||||
:value(WideCharToMultiByte(CP_ACP, _path.c_str()))
|
||||
{
|
||||
if (value.IsNull())
|
||||
/* fall back to empty string */
|
||||
value = Value::Empty();
|
||||
}
|
||||
|
||||
static AllocatedPath
|
||||
AcpToAllocatedPath(const char *s)
|
||||
{
|
||||
wchar_t buffer[MAX_PATH];
|
||||
auto result = MultiByteToWideChar(CP_ACP, 0, s, -1,
|
||||
buffer, ARRAY_SIZE(buffer));
|
||||
if (result <= 0)
|
||||
throw MakeLastError("MultiByteToWideChar() failed");
|
||||
|
||||
return AllocatedPath::FromFS(buffer);
|
||||
}
|
||||
|
||||
FromNarrowPath::FromNarrowPath(const char *s)
|
||||
:value(AcpToAllocatedPath(s))
|
||||
{
|
||||
}
|
||||
|
||||
#endif /* _UNICODE */
|
@@ -21,12 +21,10 @@
|
||||
#define MPD_FS_NARROW_PATH_HXX
|
||||
|
||||
#include "Path.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
|
||||
#ifdef _UNICODE
|
||||
#include "lib/icu/Win32.hxx"
|
||||
#include "AllocatedPath.hxx"
|
||||
#include "util/AllocatedString.hxx"
|
||||
#include <windows.h>
|
||||
#else
|
||||
#include "util/StringPointer.hxx"
|
||||
#endif
|
||||
@@ -48,12 +46,7 @@ class NarrowPath {
|
||||
|
||||
public:
|
||||
#ifdef _UNICODE
|
||||
explicit NarrowPath(Path _path)
|
||||
:value(WideCharToMultiByte(CP_ACP, _path.c_str())) {
|
||||
if (value.IsNull())
|
||||
/* fall back to empty string */
|
||||
value = Value::Empty();
|
||||
}
|
||||
explicit NarrowPath(Path _path) noexcept;
|
||||
#else
|
||||
explicit NarrowPath(Path _path):value(_path.c_str()) {}
|
||||
#endif
|
||||
@@ -67,4 +60,38 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* A path name converted from a "narrow" string. This is used to
|
||||
* import an existing narrow string to a #Path.
|
||||
*/
|
||||
class FromNarrowPath {
|
||||
#ifdef _UNICODE
|
||||
using Value = AllocatedPath;
|
||||
#else
|
||||
using Value = Path;
|
||||
#endif
|
||||
|
||||
Value value{nullptr};
|
||||
|
||||
public:
|
||||
FromNarrowPath() = default;
|
||||
|
||||
#ifdef _UNICODE
|
||||
/**
|
||||
* Throws on error.
|
||||
*/
|
||||
FromNarrowPath(const char *s);
|
||||
#else
|
||||
constexpr FromNarrowPath(const char *s) noexcept
|
||||
:value(Value::FromFS(s)) {}
|
||||
#endif
|
||||
|
||||
#ifndef _UNICODE
|
||||
constexpr
|
||||
#endif
|
||||
operator Path() const noexcept {
|
||||
return value;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -108,6 +108,12 @@ struct PathTraitsFS {
|
||||
return IsSeparator(*p);
|
||||
}
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static bool IsSpecialFilename(const_pointer_type name) noexcept {
|
||||
return (name[0] == '.' && name[1] == 0) ||
|
||||
(name[0] == '.' && name[1] == '.' && name[2] == 0);
|
||||
}
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static size_t GetLength(const_pointer_type p) noexcept {
|
||||
return StringLength(p);
|
||||
@@ -216,6 +222,12 @@ struct PathTraitsUTF8 {
|
||||
return IsSeparator(*p);
|
||||
}
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static bool IsSpecialFilename(const_pointer_type name) noexcept {
|
||||
return (name[0] == '.' && name[1] == 0) ||
|
||||
(name[0] == '.' && name[1] == '.' && name[2] == 0);
|
||||
}
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static size_t GetLength(const_pointer_type p) noexcept {
|
||||
return StringLength(p);
|
||||
|
@@ -40,7 +40,7 @@ class BufferedReader {
|
||||
|
||||
public:
|
||||
explicit BufferedReader(Reader &_reader) noexcept
|
||||
:reader(_reader), buffer(4096) {}
|
||||
:reader(_reader), buffer(16384) {}
|
||||
|
||||
/**
|
||||
* Reset the internal state. Should be called after rewinding
|
||||
|
@@ -36,7 +36,7 @@ class GunzipReader final : public Reader {
|
||||
|
||||
z_stream z;
|
||||
|
||||
StaticFifoBuffer<Bytef, 4096> buffer;
|
||||
StaticFifoBuffer<Bytef, 65536> buffer;
|
||||
|
||||
public:
|
||||
/**
|
||||
|
@@ -62,7 +62,7 @@ GzipOutputStream::Flush()
|
||||
z.avail_in = 0;
|
||||
|
||||
while (true) {
|
||||
Bytef output[4096];
|
||||
Bytef output[16384];
|
||||
z.next_out = output;
|
||||
z.avail_out = sizeof(output);
|
||||
|
||||
@@ -87,7 +87,7 @@ GzipOutputStream::Write(const void *_data, size_t size)
|
||||
z.avail_in = size;
|
||||
|
||||
while (z.avail_in > 0) {
|
||||
Bytef output[4096];
|
||||
Bytef output[16384];
|
||||
z.next_out = output;
|
||||
z.avail_out = sizeof(output);
|
||||
|
||||
|
@@ -6,6 +6,7 @@ fs_sources = [
|
||||
'Path.cxx',
|
||||
'Path2.cxx',
|
||||
'AllocatedPath.cxx',
|
||||
'NarrowPath.cxx',
|
||||
'FileSystem.cxx',
|
||||
'List.cxx',
|
||||
'StandardDirectory.cxx',
|
||||
|
@@ -76,7 +76,7 @@ public:
|
||||
|
||||
virtual ~AsyncInputStream();
|
||||
|
||||
EventLoop &GetEventLoop() {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return deferred_resume.GetEventLoop();
|
||||
}
|
||||
|
||||
|
@@ -113,7 +113,7 @@ input_cdio_init(EventLoop &, const ConfigBlock &block)
|
||||
throw FormatRuntimeError("Unrecognized 'default_byte_order' setting: %s",
|
||||
value);
|
||||
}
|
||||
speed = block.GetBlockValue("speed",0u);
|
||||
speed = block.GetBlockValue("speed",0U);
|
||||
}
|
||||
|
||||
struct CdioUri {
|
||||
|
@@ -180,7 +180,6 @@ CurlInputStream::FreeEasyIndirect() noexcept
|
||||
{
|
||||
BlockingCall(GetEventLoop(), [this](){
|
||||
FreeEasy();
|
||||
(*curl_init)->InvalidateSockets();
|
||||
});
|
||||
}
|
||||
|
||||
@@ -321,7 +320,7 @@ input_curl_init(EventLoop &event_loop, const ConfigBlock &block)
|
||||
http_200_aliases = curl_slist_append(http_200_aliases, "ICY 200 OK");
|
||||
|
||||
proxy = block.GetBlockValue("proxy");
|
||||
proxy_port = block.GetBlockValue("proxy_port", 0u);
|
||||
proxy_port = block.GetBlockValue("proxy_port", 0U);
|
||||
proxy_user = block.GetBlockValue("proxy_user");
|
||||
proxy_password = block.GetBlockValue("proxy_password");
|
||||
|
||||
@@ -366,9 +365,9 @@ CurlInputStream::InitEasy()
|
||||
request = new CurlRequest(**curl_init, GetURI(), *this);
|
||||
|
||||
request->SetOption(CURLOPT_HTTP200ALIASES, http_200_aliases);
|
||||
request->SetOption(CURLOPT_FOLLOWLOCATION, 1l);
|
||||
request->SetOption(CURLOPT_MAXREDIRS, 5l);
|
||||
request->SetOption(CURLOPT_FAILONERROR, 1l);
|
||||
request->SetOption(CURLOPT_FOLLOWLOCATION, 1L);
|
||||
request->SetOption(CURLOPT_MAXREDIRS, 5L);
|
||||
request->SetOption(CURLOPT_FAILONERROR, 1L);
|
||||
|
||||
if (proxy != nullptr)
|
||||
request->SetOption(CURLOPT_PROXY, proxy);
|
||||
@@ -381,8 +380,8 @@ CurlInputStream::InitEasy()
|
||||
StringFormat<1024>("%s:%s", proxy_user,
|
||||
proxy_password).c_str());
|
||||
|
||||
request->SetOption(CURLOPT_SSL_VERIFYPEER, verify_peer ? 1l : 0l);
|
||||
request->SetOption(CURLOPT_SSL_VERIFYHOST, verify_host ? 2l : 0l);
|
||||
request->SetOption(CURLOPT_SSL_VERIFYPEER, verify_peer ? 1L : 0L);
|
||||
request->SetOption(CURLOPT_SSL_VERIFYHOST, verify_host ? 2L : 0L);
|
||||
request->SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
||||
}
|
||||
|
||||
|
@@ -102,7 +102,7 @@ public:
|
||||
|
||||
~TidalSessionManager() noexcept;
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return defer_invoke_handlers.GetEventLoop();
|
||||
}
|
||||
|
||||
|
@@ -40,15 +40,15 @@ namespace Java {
|
||||
*/
|
||||
typedef LocalRef<jobject> LocalObject;
|
||||
|
||||
class Object : public GlobalRef<jobject> {
|
||||
class GlobalObject : public GlobalRef<jobject> {
|
||||
public:
|
||||
/**
|
||||
* Constructs an uninitialized object. The method
|
||||
* set() must be called before it is destructed.
|
||||
*/
|
||||
Object() = default;
|
||||
GlobalObject() = default;
|
||||
|
||||
Object(JNIEnv *env, jobject obj) noexcept
|
||||
GlobalObject(JNIEnv *env, jobject obj) noexcept
|
||||
:GlobalRef<jobject>(env, obj) {}
|
||||
};
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2016-2018 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2016-2018 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
@@ -90,6 +90,82 @@ public:
|
||||
throw std::runtime_error(curl_easy_strerror(code));
|
||||
}
|
||||
|
||||
void SetPrivate(void *pointer) {
|
||||
SetOption(CURLOPT_PRIVATE, pointer);
|
||||
}
|
||||
|
||||
void SetErrorBuffer(char *buf) {
|
||||
SetOption(CURLOPT_ERRORBUFFER, buf);
|
||||
}
|
||||
|
||||
void SetURL(const char *value) {
|
||||
SetOption(CURLOPT_URL, value);
|
||||
}
|
||||
|
||||
void SetUserAgent(const char *value) {
|
||||
SetOption(CURLOPT_USERAGENT, value);
|
||||
}
|
||||
|
||||
void SetRequestHeaders(struct curl_slist *headers) {
|
||||
SetOption(CURLOPT_HTTPHEADER, headers);
|
||||
}
|
||||
|
||||
void SetBasicAuth(const char *userpwd) {
|
||||
SetOption(CURLOPT_USERPWD, userpwd);
|
||||
}
|
||||
|
||||
void SetNoProgress(bool value=true) {
|
||||
SetOption(CURLOPT_NOPROGRESS, (long)value);
|
||||
}
|
||||
|
||||
void SetNoSignal(bool value=true) {
|
||||
SetOption(CURLOPT_NOSIGNAL, (long)value);
|
||||
}
|
||||
|
||||
void SetFailOnError(bool value=true) {
|
||||
SetOption(CURLOPT_FAILONERROR, (long)value);
|
||||
}
|
||||
|
||||
void SetConnectTimeout(long timeout) {
|
||||
SetOption(CURLOPT_CONNECTTIMEOUT, timeout);
|
||||
}
|
||||
|
||||
void SetHeaderFunction(size_t (*function)(char *buffer, size_t size,
|
||||
size_t nitems,
|
||||
void *userdata),
|
||||
void *userdata) {
|
||||
SetOption(CURLOPT_HEADERFUNCTION, function);
|
||||
SetOption(CURLOPT_HEADERDATA, userdata);
|
||||
}
|
||||
|
||||
void SetWriteFunction(size_t (*function)(char *ptr, size_t size,
|
||||
size_t nmemb, void *userdata),
|
||||
void *userdata) {
|
||||
SetOption(CURLOPT_WRITEFUNCTION, function);
|
||||
SetOption(CURLOPT_WRITEDATA, userdata);
|
||||
}
|
||||
|
||||
void SetNoBody(bool value=true) {
|
||||
SetOption(CURLOPT_NOBODY, (long)value);
|
||||
}
|
||||
|
||||
void SetPost(bool value=true) {
|
||||
SetOption(CURLOPT_POST, (long)value);
|
||||
}
|
||||
|
||||
void SetRequestBody(const void *data, size_t size) {
|
||||
SetOption(CURLOPT_POSTFIELDS, data);
|
||||
SetOption(CURLOPT_POSTFIELDSIZE, (long)size);
|
||||
}
|
||||
|
||||
void SetHttpPost(const struct curl_httppost *post) {
|
||||
SetOption(CURLOPT_HTTPPOST, post);
|
||||
}
|
||||
|
||||
bool Unpause() noexcept {
|
||||
return ::curl_easy_pause(handle, CURLPAUSE_CONT) == CURLE_OK;
|
||||
}
|
||||
|
||||
CurlString Escape(const char *string, int length=0) const noexcept {
|
||||
return CurlString(curl_easy_escape(handle, string, length));
|
||||
}
|
||||
|
@@ -48,7 +48,7 @@ public:
|
||||
CurlSocket(CurlGlobal &_global, EventLoop &_loop, SocketDescriptor _fd)
|
||||
:SocketMonitor(_fd, _loop), global(_global) {}
|
||||
|
||||
~CurlSocket() {
|
||||
~CurlSocket() noexcept {
|
||||
/* TODO: sometimes, CURL uses CURL_POLL_REMOVE after
|
||||
closing the socket, and sometimes, it uses
|
||||
CURL_POLL_REMOVE just to move the (still open)
|
||||
@@ -109,7 +109,8 @@ CurlGlobal::CurlGlobal(EventLoop &_loop)
|
||||
int
|
||||
CurlSocket::SocketFunction(gcc_unused CURL *easy,
|
||||
curl_socket_t s, int action,
|
||||
void *userp, void *socketp) noexcept {
|
||||
void *userp, void *socketp) noexcept
|
||||
{
|
||||
auto &global = *(CurlGlobal *)userp;
|
||||
CurlSocket *cs = (CurlSocket *)socketp;
|
||||
|
||||
@@ -153,11 +154,6 @@ CurlSocket::OnSocketReady(unsigned flags) noexcept
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs in the I/O thread. No lock needed.
|
||||
*
|
||||
* Throws std::runtime_error on error.
|
||||
*/
|
||||
void
|
||||
CurlGlobal::Add(CURL *easy, CurlRequest &request)
|
||||
{
|
||||
@@ -181,8 +177,6 @@ CurlGlobal::Remove(CURL *easy) noexcept
|
||||
assert(easy != nullptr);
|
||||
|
||||
curl_multi_remove_handle(multi.Get(), easy);
|
||||
|
||||
InvalidateSockets();
|
||||
}
|
||||
|
||||
static CurlRequest *
|
||||
@@ -196,11 +190,6 @@ ToRequest(CURL *easy) noexcept
|
||||
return (CurlRequest *)p;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for finished HTTP responses.
|
||||
*
|
||||
* Runs in the I/O thread. The caller must not hold locks.
|
||||
*/
|
||||
inline void
|
||||
CurlGlobal::ReadInfo() noexcept
|
||||
{
|
||||
@@ -219,41 +208,6 @@ CurlGlobal::ReadInfo() noexcept
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
CurlGlobal::UpdateTimeout(long timeout_ms) noexcept
|
||||
{
|
||||
if (timeout_ms < 0) {
|
||||
timeout_event.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeout_ms < 10)
|
||||
/* CURL 7.21.1 likes to report "timeout=0", which
|
||||
means we're running in a busy loop. Quite a bad
|
||||
idea to waste so much CPU. Let's use a lower limit
|
||||
of 10ms. */
|
||||
timeout_ms = 10;
|
||||
|
||||
timeout_event.Schedule(std::chrono::milliseconds(timeout_ms));
|
||||
}
|
||||
|
||||
int
|
||||
CurlGlobal::TimerFunction(gcc_unused CURLM *_global, long timeout_ms,
|
||||
void *userp) noexcept
|
||||
{
|
||||
auto &global = *(CurlGlobal *)userp;
|
||||
assert(_global == global.multi.Get());
|
||||
|
||||
global.UpdateTimeout(timeout_ms);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CurlGlobal::OnTimeout() noexcept
|
||||
{
|
||||
SocketAction(CURL_SOCKET_TIMEOUT, 0);
|
||||
}
|
||||
|
||||
void
|
||||
CurlGlobal::SocketAction(curl_socket_t fd, int ev_bitmask) noexcept
|
||||
{
|
||||
@@ -267,3 +221,38 @@ CurlGlobal::SocketAction(curl_socket_t fd, int ev_bitmask) noexcept
|
||||
|
||||
defer_read_info.Schedule();
|
||||
}
|
||||
|
||||
inline void
|
||||
CurlGlobal::UpdateTimeout(long timeout_ms) noexcept
|
||||
{
|
||||
if (timeout_ms < 0) {
|
||||
timeout_event.Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
if (timeout_ms < 1)
|
||||
/* CURL's threaded resolver sets a timeout of 0ms, which
|
||||
means we're running in a busy loop. Quite a bad
|
||||
idea to waste so much CPU. Let's use a lower limit
|
||||
of 1ms. */
|
||||
timeout_ms = 1;
|
||||
|
||||
timeout_event.Schedule(std::chrono::milliseconds(timeout_ms));
|
||||
}
|
||||
|
||||
int
|
||||
CurlGlobal::TimerFunction(gcc_unused CURLM *_multi, long timeout_ms,
|
||||
void *userp) noexcept
|
||||
{
|
||||
auto &global = *(CurlGlobal *)userp;
|
||||
assert(_multi == global.multi.Get());
|
||||
|
||||
global.UpdateTimeout(timeout_ms);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
CurlGlobal::OnTimeout() noexcept
|
||||
{
|
||||
SocketAction(CURL_SOCKET_TIMEOUT, 0);
|
||||
}
|
||||
|
@@ -50,43 +50,33 @@ class CurlGlobal final {
|
||||
public:
|
||||
explicit CurlGlobal(EventLoop &_loop);
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return timeout_event.GetEventLoop();
|
||||
}
|
||||
|
||||
void Add(CURL *easy, CurlRequest &request);
|
||||
void Remove(CURL *easy) noexcept;
|
||||
|
||||
/**
|
||||
* Check for finished HTTP responses.
|
||||
*
|
||||
* Runs in the I/O thread. The caller must not hold locks.
|
||||
*/
|
||||
void ReadInfo() noexcept;
|
||||
|
||||
void Assign(curl_socket_t fd, CurlSocket &cs) noexcept {
|
||||
curl_multi_assign(multi.Get(), fd, &cs);
|
||||
}
|
||||
|
||||
void SocketAction(curl_socket_t fd, int ev_bitmask) noexcept;
|
||||
|
||||
void InvalidateSockets() {
|
||||
void InvalidateSockets() noexcept {
|
||||
SocketAction(CURL_SOCKET_TIMEOUT, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a kludge to allow pausing/resuming a stream with
|
||||
* libcurl < 7.32.0. Read the curl_easy_pause manpage for
|
||||
* more information.
|
||||
*/
|
||||
void ResumeSockets() {
|
||||
int running_handles;
|
||||
curl_multi_socket_all(multi.Get(), &running_handles);
|
||||
}
|
||||
|
||||
private:
|
||||
/**
|
||||
* Check for finished HTTP responses.
|
||||
*
|
||||
* Runs in the I/O thread. The caller must not hold locks.
|
||||
*/
|
||||
void ReadInfo() noexcept;
|
||||
|
||||
void UpdateTimeout(long timeout_ms) noexcept;
|
||||
static int TimerFunction(CURLM *global, long timeout_ms,
|
||||
static int TimerFunction(CURLM *multi, long timeout_ms,
|
||||
void *userp) noexcept;
|
||||
|
||||
/* callback for #timeout_event */
|
||||
|
@@ -50,11 +50,19 @@ public:
|
||||
CurlInit(const CurlInit &) = delete;
|
||||
CurlInit &operator=(const CurlInit &) = delete;
|
||||
|
||||
CurlGlobal &operator*() {
|
||||
CurlGlobal &operator*() noexcept {
|
||||
return *instance;
|
||||
}
|
||||
|
||||
CurlGlobal *operator->() {
|
||||
const CurlGlobal &operator*() const noexcept {
|
||||
return *instance;
|
||||
}
|
||||
|
||||
CurlGlobal *operator->() noexcept {
|
||||
return instance;
|
||||
}
|
||||
|
||||
const CurlGlobal *operator->() const noexcept {
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
|
@@ -30,7 +30,6 @@
|
||||
#include "config.h"
|
||||
#include "Request.hxx"
|
||||
#include "Global.hxx"
|
||||
#include "Version.hxx"
|
||||
#include "Handler.hxx"
|
||||
#include "event/Call.hxx"
|
||||
#include "util/RuntimeError.hxx"
|
||||
@@ -53,17 +52,17 @@ CurlRequest::CurlRequest(CurlGlobal &_global,
|
||||
{
|
||||
error_buffer[0] = 0;
|
||||
|
||||
easy.SetOption(CURLOPT_PRIVATE, (void *)this);
|
||||
easy.SetOption(CURLOPT_USERAGENT, "Music Player Daemon " VERSION);
|
||||
easy.SetOption(CURLOPT_HEADERFUNCTION, _HeaderFunction);
|
||||
easy.SetOption(CURLOPT_WRITEHEADER, this);
|
||||
easy.SetOption(CURLOPT_WRITEFUNCTION, WriteFunction);
|
||||
easy.SetOption(CURLOPT_WRITEDATA, this);
|
||||
easy.SetOption(CURLOPT_NETRC, 1l);
|
||||
easy.SetOption(CURLOPT_ERRORBUFFER, error_buffer);
|
||||
easy.SetOption(CURLOPT_NOPROGRESS, 1l);
|
||||
easy.SetOption(CURLOPT_NOSIGNAL, 1l);
|
||||
easy.SetOption(CURLOPT_CONNECTTIMEOUT, 10l);
|
||||
easy.SetPrivate((void *)this);
|
||||
easy.SetUserAgent("Music Player Daemon " VERSION);
|
||||
easy.SetHeaderFunction(_HeaderFunction, this);
|
||||
easy.SetWriteFunction(WriteFunction, this);
|
||||
#ifndef ANDROID
|
||||
easy.SetOption(CURLOPT_NETRC, 1L);
|
||||
#endif
|
||||
easy.SetErrorBuffer(error_buffer);
|
||||
easy.SetNoProgress();
|
||||
easy.SetNoSignal();
|
||||
easy.SetConnectTimeout(10);
|
||||
easy.SetOption(CURLOPT_HTTPAUTH, (long) CURLAUTH_ANY);
|
||||
}
|
||||
|
||||
@@ -122,13 +121,7 @@ CurlRequest::Resume() noexcept
|
||||
{
|
||||
assert(registered);
|
||||
|
||||
curl_easy_pause(easy.Get(), CURLPAUSE_CONT);
|
||||
|
||||
if (IsCurlOlderThan(0x072000))
|
||||
/* libcurl older than 7.32.0 does not update
|
||||
its sockets after curl_easy_pause(); force
|
||||
libcurl to do it now */
|
||||
global.ResumeSockets();
|
||||
easy.Unpause();
|
||||
|
||||
global.InvalidateSockets();
|
||||
}
|
||||
@@ -227,14 +220,14 @@ CurlRequest::HeaderFunction(StringView s) noexcept
|
||||
}
|
||||
|
||||
size_t
|
||||
CurlRequest::_HeaderFunction(void *ptr, size_t size, size_t nmemb,
|
||||
CurlRequest::_HeaderFunction(char *ptr, size_t size, size_t nmemb,
|
||||
void *stream) noexcept
|
||||
{
|
||||
CurlRequest &c = *(CurlRequest *)stream;
|
||||
|
||||
size *= nmemb;
|
||||
|
||||
c.HeaderFunction({(const char *)ptr, size});
|
||||
c.HeaderFunction({ptr, size});
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -261,7 +254,7 @@ CurlRequest::DataReceived(const void *ptr, size_t received_size) noexcept
|
||||
}
|
||||
|
||||
size_t
|
||||
CurlRequest::WriteFunction(void *ptr, size_t size, size_t nmemb,
|
||||
CurlRequest::WriteFunction(char *ptr, size_t size, size_t nmemb,
|
||||
void *stream) noexcept
|
||||
{
|
||||
CurlRequest &c = *(CurlRequest *)stream;
|
||||
|
@@ -127,7 +127,7 @@ public:
|
||||
}
|
||||
|
||||
void SetUrl(const char *url) {
|
||||
easy.SetOption(CURLOPT_URL, url);
|
||||
easy.SetURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -160,11 +160,11 @@ private:
|
||||
void OnPostponeError() noexcept;
|
||||
|
||||
/** called by curl when new data is available */
|
||||
static size_t _HeaderFunction(void *ptr, size_t size, size_t nmemb,
|
||||
static size_t _HeaderFunction(char *ptr, size_t size, size_t nmemb,
|
||||
void *stream) noexcept;
|
||||
|
||||
/** called by curl when new data is available */
|
||||
static size_t WriteFunction(void *ptr, size_t size, size_t nmemb,
|
||||
static size_t WriteFunction(char *ptr, size_t size, size_t nmemb,
|
||||
void *stream) noexcept;
|
||||
};
|
||||
|
||||
|
@@ -42,7 +42,7 @@ class CurlSlist {
|
||||
struct curl_slist *head = nullptr;
|
||||
|
||||
public:
|
||||
CurlSlist() = default;
|
||||
CurlSlist() noexcept = default;
|
||||
|
||||
CurlSlist(CurlSlist &&src) noexcept
|
||||
:head(std::exchange(src.head, nullptr)) {}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
curl_dep = dependency('libcurl', version: '>= 7.18', required: get_option('curl'))
|
||||
curl_dep = dependency('libcurl', version: '>= 7.32', required: get_option('curl'))
|
||||
conf.set('ENABLE_CURL', curl_dep.found())
|
||||
if not curl_dep.found()
|
||||
subdir_done()
|
||||
|
@@ -42,7 +42,7 @@ public:
|
||||
DisconnectIndirect();
|
||||
}
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return watch.GetEventLoop();
|
||||
}
|
||||
|
||||
|
@@ -102,7 +102,7 @@ public:
|
||||
|
||||
void Shutdown() noexcept;
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return defer_dispatch.GetEventLoop();
|
||||
}
|
||||
|
||||
|
@@ -59,7 +59,7 @@ try {
|
||||
if (u.IsNull())
|
||||
return AllocatedString<>::Duplicate(src);
|
||||
|
||||
AllocatedArray<UChar> folded(u.size() * 2u);
|
||||
AllocatedArray<UChar> folded(u.size() * 2U);
|
||||
|
||||
UErrorCode error_code = U_ZERO_ERROR;
|
||||
size_t folded_length = u_strFoldCase(folded.begin(), folded.size(),
|
||||
|
@@ -161,9 +161,7 @@ public:
|
||||
return export_name.c_str();
|
||||
}
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
return SocketMonitor::GetEventLoop();
|
||||
}
|
||||
using SocketMonitor::GetEventLoop;
|
||||
|
||||
/**
|
||||
* Ensure that the connection is established. The connection
|
||||
|
@@ -69,7 +69,7 @@ public:
|
||||
NfsFileReader() noexcept;
|
||||
~NfsFileReader() noexcept;
|
||||
|
||||
EventLoop &GetEventLoop() noexcept {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return defer_open.GetEventLoop();
|
||||
}
|
||||
|
||||
|
@@ -272,7 +272,7 @@ UPnPDeviceDirectory::~UPnPDeviceDirectory() noexcept
|
||||
}
|
||||
|
||||
inline EventLoop &
|
||||
UPnPDeviceDirectory::GetEventLoop() noexcept
|
||||
UPnPDeviceDirectory::GetEventLoop() const noexcept
|
||||
{
|
||||
return curl->GetEventLoop();
|
||||
}
|
||||
|
@@ -168,7 +168,7 @@ public:
|
||||
UPnPDeviceDirectory(const UPnPDeviceDirectory &) = delete;
|
||||
UPnPDeviceDirectory& operator=(const UPnPDeviceDirectory &) = delete;
|
||||
|
||||
EventLoop &GetEventLoop() noexcept;
|
||||
EventLoop &GetEventLoop() const noexcept;
|
||||
|
||||
void Start();
|
||||
|
||||
|
@@ -57,13 +57,14 @@ OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
|
||||
|
||||
bool
|
||||
OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet,
|
||||
InputStream &is)
|
||||
InputStream &is, bool synced)
|
||||
{
|
||||
if (!is.KnownSize())
|
||||
return false;
|
||||
|
||||
if (is.GetRest() < 65536)
|
||||
return OggFindEOS(oy, os, packet);
|
||||
return (synced || oy.ExpectPageSeekIn(os)) &&
|
||||
OggFindEOS(oy, os, packet);
|
||||
|
||||
if (!is.CheapSeeking())
|
||||
return false;
|
||||
|
@@ -47,10 +47,13 @@ OggSeekPageAtOffset(OggSyncState &oy, ogg_stream_state &os, InputStream &is,
|
||||
* Try to find the end-of-stream (EOS) packet. Seek to the end of the
|
||||
* file if necessary.
|
||||
*
|
||||
* @param synced is the #OggSyncState currently synced? If not, then
|
||||
* we need to use ogg_sync_pageseek() instead of ogg_sync_pageout(),
|
||||
* which is more expensive
|
||||
* @return true if the EOS packet was found
|
||||
*/
|
||||
bool
|
||||
OggSeekFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet,
|
||||
InputStream &is);
|
||||
InputStream &is, bool synced=true);
|
||||
|
||||
#endif
|
||||
|
@@ -29,6 +29,7 @@ struct MixerPlugin;
|
||||
|
||||
extern const MixerPlugin null_mixer_plugin;
|
||||
extern const MixerPlugin software_mixer_plugin;
|
||||
extern const MixerPlugin android_mixer_plugin;
|
||||
extern const MixerPlugin alsa_mixer_plugin;
|
||||
extern const MixerPlugin haiku_mixer_plugin;
|
||||
extern const MixerPlugin oss_mixer_plugin;
|
||||
|
116
src/mixer/plugins/AndroidMixerPlugin.cxx
Normal file
116
src/mixer/plugins/AndroidMixerPlugin.cxx
Normal file
@@ -0,0 +1,116 @@
|
||||
/*
|
||||
* Copyright 2003-2020 The Music Player Daemon Project
|
||||
* http://www.musicpd.org
|
||||
*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "mixer/MixerInternal.hxx"
|
||||
#include "filter/plugins/VolumeFilterPlugin.hxx"
|
||||
#include "pcm/Volume.hxx"
|
||||
#include "android/Context.hxx"
|
||||
#include "android/AudioManager.hxx"
|
||||
|
||||
#include "Main.hxx"
|
||||
|
||||
#include <cassert>
|
||||
#include <cmath>
|
||||
|
||||
class AndroidMixer final : public Mixer {
|
||||
AudioManager *audioManager;
|
||||
int currentVolume;
|
||||
int maxAndroidVolume;
|
||||
int lastAndroidVolume;
|
||||
public:
|
||||
explicit AndroidMixer(MixerListener &_listener);
|
||||
|
||||
~AndroidMixer() override;
|
||||
|
||||
/* virtual methods from class Mixer */
|
||||
void Open() override {
|
||||
}
|
||||
|
||||
void Close() noexcept override {
|
||||
}
|
||||
|
||||
int GetVolume() override;
|
||||
|
||||
void SetVolume(unsigned volume) override;
|
||||
};
|
||||
|
||||
static Mixer *
|
||||
android_mixer_init([[maybe_unused]] EventLoop &event_loop,
|
||||
[[maybe_unused]] AudioOutput &ao,
|
||||
MixerListener &listener,
|
||||
[[maybe_unused]] const ConfigBlock &block)
|
||||
{
|
||||
return new AndroidMixer(listener);
|
||||
}
|
||||
|
||||
AndroidMixer::AndroidMixer(MixerListener &_listener)
|
||||
:Mixer(android_mixer_plugin, _listener)
|
||||
{
|
||||
JNIEnv *env = Java::GetEnv();
|
||||
audioManager = context->GetAudioManager(env);
|
||||
|
||||
maxAndroidVolume = audioManager->GetMaxVolume();
|
||||
if (maxAndroidVolume != 0)
|
||||
{
|
||||
lastAndroidVolume = audioManager->GetVolume(env);
|
||||
currentVolume = 100 * lastAndroidVolume / maxAndroidVolume;
|
||||
}
|
||||
}
|
||||
|
||||
AndroidMixer::~AndroidMixer()
|
||||
{
|
||||
delete audioManager;
|
||||
}
|
||||
|
||||
int
|
||||
AndroidMixer::GetVolume()
|
||||
{
|
||||
JNIEnv *env = Java::GetEnv();
|
||||
if (maxAndroidVolume == 0)
|
||||
return -1;
|
||||
|
||||
// The android volume index (or scale) is very likely inferior to the
|
||||
// MPD one (100). The last volume set by MPD is saved into
|
||||
// currentVolume, this volume is returned instead of the Android one
|
||||
// when the Android mixer was not touched by an other application. This
|
||||
// allows to fake a 0..100 scale from MPD.
|
||||
|
||||
int volume = audioManager->GetVolume(env);
|
||||
if (volume == lastAndroidVolume)
|
||||
return currentVolume;
|
||||
|
||||
return 100 * volume / maxAndroidVolume;
|
||||
}
|
||||
|
||||
void
|
||||
AndroidMixer::SetVolume(unsigned newVolume)
|
||||
{
|
||||
JNIEnv *env = Java::GetEnv();
|
||||
if (maxAndroidVolume == 0)
|
||||
return;
|
||||
currentVolume = newVolume;
|
||||
lastAndroidVolume = currentVolume * maxAndroidVolume / 100;
|
||||
audioManager->SetVolume(env, lastAndroidVolume);
|
||||
|
||||
}
|
||||
|
||||
const MixerPlugin android_mixer_plugin = {
|
||||
android_mixer_init,
|
||||
true,
|
||||
};
|
@@ -20,13 +20,13 @@
|
||||
#include "mixer/MixerInternal.hxx"
|
||||
#include "output/OutputAPI.hxx"
|
||||
#include "output/plugins/WinmmOutputPlugin.hxx"
|
||||
#include "util/Math.hxx"
|
||||
|
||||
#include <mmsystem.h>
|
||||
|
||||
#include <stdexcept>
|
||||
|
||||
#include <assert.h>
|
||||
#include <math.h>
|
||||
#include <windows.h>
|
||||
|
||||
class WinmmMixer final : public Mixer {
|
||||
|
@@ -34,6 +34,10 @@ if is_windows
|
||||
mixer_plugins_sources += 'WinmmMixerPlugin.cxx'
|
||||
endif
|
||||
|
||||
if is_android
|
||||
mixer_plugins_sources += 'AndroidMixerPlugin.cxx'
|
||||
endif
|
||||
|
||||
mixer_plugins = static_library(
|
||||
'mixer_plugins',
|
||||
mixer_plugins_sources,
|
||||
|
@@ -70,7 +70,7 @@ public:
|
||||
NeighborListener &_listener) noexcept
|
||||
:NeighborExplorer(_listener), event_loop(_event_loop) {}
|
||||
|
||||
auto &GetEventLoop() noexcept {
|
||||
auto &GetEventLoop() const noexcept {
|
||||
return event_loop;
|
||||
}
|
||||
|
||||
|
@@ -395,7 +395,7 @@ AlsaOutput::AlsaOutput(EventLoop &_loop, const ConfigBlock &block)
|
||||
#endif
|
||||
buffer_time(block.GetPositiveValue("buffer_time",
|
||||
MPD_ALSA_BUFFER_TIME_US)),
|
||||
period_time(block.GetPositiveValue("period_time", 0u))
|
||||
period_time(block.GetPositiveValue("period_time", 0U))
|
||||
{
|
||||
#ifdef SND_PCM_NO_AUTO_RESAMPLE
|
||||
if (!block.GetBlockValue("auto_resample", true))
|
||||
|
@@ -102,7 +102,7 @@ MakeAoError()
|
||||
|
||||
AoOutput::AoOutput(const ConfigBlock &block)
|
||||
:AudioOutput(0),
|
||||
write_size(block.GetPositiveValue("write_size", 1024u))
|
||||
write_size(block.GetPositiveValue("write_size", 1024U))
|
||||
{
|
||||
const char *value = block.GetBlockValue("driver", "default");
|
||||
if (0 == strcmp(value, "default"))
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include "../OutputAPI.hxx"
|
||||
#include "mixer/MixerList.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Math.hxx"
|
||||
#include "system/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
@@ -37,8 +38,6 @@
|
||||
#include <StringList.h>
|
||||
#include <SoundPlayer.h>
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#define UTF8_PLAY "\xE2\x96\xB6"
|
||||
|
@@ -212,7 +212,7 @@ JackOutput::JackOutput(const ConfigBlock &block)
|
||||
num_source_ports, num_destination_ports,
|
||||
block.line);
|
||||
|
||||
ringbuffer_size = block.GetPositiveValue("ringbuffer_size", 32768u);
|
||||
ringbuffer_size = block.GetPositiveValue("ringbuffer_size", 32768U);
|
||||
}
|
||||
|
||||
inline jack_nframes_t
|
||||
|
@@ -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 .. */
|
||||
|
@@ -101,7 +101,7 @@ ShoutOutput::ShoutOutput(const ConfigBlock &block)
|
||||
{
|
||||
const char *host = require_block_string(block, "host");
|
||||
const char *mount = require_block_string(block, "mount");
|
||||
unsigned port = block.GetBlockValue("port", 0u);
|
||||
unsigned port = block.GetBlockValue("port", 0U);
|
||||
if (port == 0)
|
||||
throw std::runtime_error("shout port must be configured");
|
||||
|
||||
|
@@ -22,22 +22,23 @@
|
||||
#include "system/FileDescriptor.hxx"
|
||||
#include "system/Error.hxx"
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef __sun
|
||||
#if defined(__sun)
|
||||
#include <sys/audio.h>
|
||||
#include <sys/stropts.h>
|
||||
#elif defined(__NetBSD__)
|
||||
#include <sys/audioio.h>
|
||||
#else
|
||||
|
||||
/* some fake declarations that allow build this plugin on systems
|
||||
other than Solaris, just to see if it compiles */
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
#ifndef I_FLUSH
|
||||
#define I_FLUSH 0
|
||||
#endif
|
||||
@@ -147,7 +148,11 @@ SolarisOutput::Play(const void *chunk, size_t size)
|
||||
void
|
||||
SolarisOutput::Cancel() noexcept
|
||||
{
|
||||
#if defined(AUDIO_FLUSH)
|
||||
ioctl(fd.Get(), AUDIO_FLUSH);
|
||||
#elif defined(I_FLUSH)
|
||||
ioctl(fd.Get(), I_FLUSH);
|
||||
#endif
|
||||
}
|
||||
|
||||
const struct AudioOutputPlugin solaris_output_plugin = {
|
||||
|
@@ -54,11 +54,11 @@ HttpdOutput::HttpdOutput(EventLoop &_loop, const ConfigBlock &block)
|
||||
genre = block.GetBlockValue("genre", "Set genre in config");
|
||||
website = block.GetBlockValue("website", "Set website in config");
|
||||
|
||||
clients_max = block.GetBlockValue("max_clients", 0u);
|
||||
clients_max = block.GetBlockValue("max_clients", 0U);
|
||||
|
||||
/* set up bind_to_address */
|
||||
|
||||
ServerSocketAddGeneric(*this, block.GetBlockValue("bind_to_address"), block.GetBlockValue("port", 8000u));
|
||||
ServerSocketAddGeneric(*this, block.GetBlockValue("bind_to_address"), block.GetBlockValue("port", 8000U));
|
||||
|
||||
/* determine content type */
|
||||
content_type = prepared_encoder->GetMimeType();
|
||||
|
@@ -28,6 +28,7 @@
|
||||
#include "util/Macros.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "system/ByteOrder.hxx"
|
||||
#include "mixer/MixerList.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <SLES/OpenSLES.h>
|
||||
@@ -412,5 +413,5 @@ const struct AudioOutputPlugin sles_output_plugin = {
|
||||
"sles",
|
||||
sles_test_default_device,
|
||||
SlesOutput::Create,
|
||||
nullptr,
|
||||
&android_mixer_plugin,
|
||||
};
|
||||
|
@@ -22,11 +22,10 @@
|
||||
#include "Clamp.hxx"
|
||||
#include "Traits.hxx"
|
||||
#include "util/Clamp.hxx"
|
||||
#include "util/Math.hxx"
|
||||
|
||||
#include "PcmDither.cxx" // including the .cxx file to get inlined templates
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
template<SampleFormat F, class Traits=SampleTraits<F>>
|
||||
@@ -225,7 +224,7 @@ pcm_mix(PcmDither &dither, void *buffer1, const void *buffer2, size_t size,
|
||||
s = sin(M_PI_2 * portion1);
|
||||
s *= s;
|
||||
|
||||
int vol1 = std::lround(s * PCM_VOLUME_1S);
|
||||
int vol1 = lround(s * PCM_VOLUME_1S);
|
||||
vol1 = Clamp<int>(vol1, 0, PCM_VOLUME_1S);
|
||||
|
||||
return pcm_add_vol(dither, buffer1, buffer2, size,
|
||||
|
@@ -23,10 +23,9 @@
|
||||
#include "AudioFormat.hxx"
|
||||
#include "util/NumberParser.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Math.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
static constexpr Domain cross_fade_domain("cross_fade");
|
||||
@@ -112,7 +111,7 @@ CrossFadeSettings::Calculate(SignedSongTime total_time,
|
||||
|
||||
if (mixramp_delay <= FloatDuration::zero() ||
|
||||
!mixramp_start || !mixramp_prev_end) {
|
||||
chunks = std::lround(duration / chunk_duration);
|
||||
chunks = lround(duration / chunk_duration);
|
||||
} else {
|
||||
/* Calculate mixramp overlap. */
|
||||
const auto mixramp_overlap_current =
|
||||
|
@@ -46,6 +46,7 @@
|
||||
#include "CrossFade.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "Idle.hxx"
|
||||
#include "util/Compiler.h"
|
||||
#include "util/Domain.hxx"
|
||||
#include "thread/Name.hxx"
|
||||
#include "Log.hxx"
|
||||
@@ -1171,6 +1172,7 @@ try {
|
||||
}
|
||||
|
||||
/* fall through */
|
||||
gcc_fallthrough;
|
||||
|
||||
case PlayerCommand::PAUSE:
|
||||
next_song.reset();
|
||||
|
@@ -21,6 +21,7 @@
|
||||
#include "../PlaylistPlugin.hxx"
|
||||
#include "../MemorySongEnumerator.hxx"
|
||||
#include "tag/Builder.hxx"
|
||||
#include "tag/Table.hxx"
|
||||
#include "util/ASCII.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
#include "lib/expat/ExpatParser.hxx"
|
||||
@@ -41,6 +42,7 @@ struct AsxParser {
|
||||
*/
|
||||
enum {
|
||||
ROOT, ENTRY,
|
||||
TAG,
|
||||
} state;
|
||||
|
||||
/**
|
||||
@@ -57,23 +59,33 @@ struct AsxParser {
|
||||
|
||||
TagBuilder tag_builder;
|
||||
|
||||
std::string value;
|
||||
|
||||
AsxParser()
|
||||
:state(ROOT) {}
|
||||
|
||||
};
|
||||
|
||||
static constexpr struct tag_table asx_tag_elements[] = {
|
||||
/* is that correct? or should it be COMPOSER or PERFORMER? */
|
||||
{ "author", TAG_ARTIST },
|
||||
|
||||
{ "title", TAG_TITLE },
|
||||
{ nullptr, TAG_NUM_OF_ITEM_TYPES }
|
||||
};
|
||||
|
||||
static void XMLCALL
|
||||
asx_start_element(void *user_data, const XML_Char *element_name,
|
||||
const XML_Char **atts)
|
||||
{
|
||||
AsxParser *parser = (AsxParser *)user_data;
|
||||
parser->value.clear();
|
||||
|
||||
switch (parser->state) {
|
||||
case AsxParser::ROOT:
|
||||
if (StringEqualsCaseASCII(element_name, "entry")) {
|
||||
parser->state = AsxParser::ENTRY;
|
||||
parser->location.clear();
|
||||
parser->tag_type = TAG_NUM_OF_ITEM_TYPES;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -84,14 +96,17 @@ asx_start_element(void *user_data, const XML_Char *element_name,
|
||||
ExpatParser::GetAttributeCase(atts, "href");
|
||||
if (href != nullptr)
|
||||
parser->location = href;
|
||||
} else if (StringEqualsCaseASCII(element_name, "author"))
|
||||
/* is that correct? or should it be COMPOSER
|
||||
or PERFORMER? */
|
||||
parser->tag_type = TAG_ARTIST;
|
||||
else if (StringEqualsCaseASCII(element_name, "title"))
|
||||
parser->tag_type = TAG_TITLE;
|
||||
} else {
|
||||
parser->tag_type = tag_table_lookup_i(asx_tag_elements,
|
||||
element_name);
|
||||
if (parser->tag_type != TAG_NUM_OF_ITEM_TYPES)
|
||||
parser->state = AsxParser::TAG;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AsxParser::TAG:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,11 +126,20 @@ asx_end_element(void *user_data, const XML_Char *element_name)
|
||||
parser->tag_builder.Commit());
|
||||
|
||||
parser->state = AsxParser::ROOT;
|
||||
} else
|
||||
parser->tag_type = TAG_NUM_OF_ITEM_TYPES;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AsxParser::TAG:
|
||||
if (!parser->value.empty())
|
||||
parser->tag_builder.AddItem(parser->tag_type,
|
||||
StringView(parser->value.data(),
|
||||
parser->value.length()));
|
||||
parser->state = AsxParser::ENTRY;
|
||||
break;
|
||||
}
|
||||
|
||||
parser->value.clear();
|
||||
}
|
||||
|
||||
static void XMLCALL
|
||||
@@ -125,13 +149,11 @@ asx_char_data(void *user_data, const XML_Char *s, int len)
|
||||
|
||||
switch (parser->state) {
|
||||
case AsxParser::ROOT:
|
||||
case AsxParser::ENTRY:
|
||||
break;
|
||||
|
||||
case AsxParser::ENTRY:
|
||||
if (parser->tag_type != TAG_NUM_OF_ITEM_TYPES)
|
||||
parser->tag_builder.AddItem(parser->tag_type,
|
||||
StringView(s, len));
|
||||
|
||||
case AsxParser::TAG:
|
||||
parser->value.append(s, len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -162,6 +162,7 @@ static const char *const rss_suffixes[] = {
|
||||
|
||||
static const char *const rss_mime_types[] = {
|
||||
"application/rss+xml",
|
||||
"application/xml",
|
||||
"text/xml",
|
||||
nullptr
|
||||
};
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "song/DetachedSong.hxx"
|
||||
#include "input/InputStream.hxx"
|
||||
#include "tag/Builder.hxx"
|
||||
#include "tag/Table.hxx"
|
||||
#include "util/StringView.hxx"
|
||||
#include "lib/expat/ExpatParser.hxx"
|
||||
#include "Log.hxx"
|
||||
@@ -44,8 +45,8 @@ struct XspfParser {
|
||||
*/
|
||||
enum {
|
||||
ROOT, PLAYLIST, TRACKLIST, TRACK,
|
||||
LOCATION,
|
||||
} state;
|
||||
TAG, LOCATION,
|
||||
} state = ROOT;
|
||||
|
||||
/**
|
||||
* The current tag within the "track" element. This is only
|
||||
@@ -61,8 +62,20 @@ struct XspfParser {
|
||||
|
||||
TagBuilder tag_builder;
|
||||
|
||||
XspfParser()
|
||||
:state(ROOT) {}
|
||||
std::string value;
|
||||
};
|
||||
|
||||
static constexpr struct tag_table xspf_tag_elements[] = {
|
||||
{ "title", TAG_TITLE },
|
||||
|
||||
/* TAG_COMPOSER would be more correct according to the XSPF
|
||||
spec */
|
||||
{ "creator", TAG_ARTIST },
|
||||
|
||||
{ "annotation", TAG_COMMENT },
|
||||
{ "album", TAG_ALBUM },
|
||||
{ "trackNum", TAG_TRACK },
|
||||
{ nullptr, TAG_NUM_OF_ITEM_TYPES }
|
||||
};
|
||||
|
||||
static void XMLCALL
|
||||
@@ -70,6 +83,7 @@ xspf_start_element(void *user_data, const XML_Char *element_name,
|
||||
gcc_unused const XML_Char **atts)
|
||||
{
|
||||
XspfParser *parser = (XspfParser *)user_data;
|
||||
parser->value.clear();
|
||||
|
||||
switch (parser->state) {
|
||||
case XspfParser::ROOT:
|
||||
@@ -88,7 +102,6 @@ xspf_start_element(void *user_data, const XML_Char *element_name,
|
||||
if (strcmp(element_name, "track") == 0) {
|
||||
parser->state = XspfParser::TRACK;
|
||||
parser->location.clear();
|
||||
parser->tag_type = TAG_NUM_OF_ITEM_TYPES;
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -96,21 +109,16 @@ xspf_start_element(void *user_data, const XML_Char *element_name,
|
||||
case XspfParser::TRACK:
|
||||
if (strcmp(element_name, "location") == 0)
|
||||
parser->state = XspfParser::LOCATION;
|
||||
else if (strcmp(element_name, "title") == 0)
|
||||
parser->tag_type = TAG_TITLE;
|
||||
else if (strcmp(element_name, "creator") == 0)
|
||||
/* TAG_COMPOSER would be more correct
|
||||
according to the XSPF spec */
|
||||
parser->tag_type = TAG_ARTIST;
|
||||
else if (strcmp(element_name, "annotation") == 0)
|
||||
parser->tag_type = TAG_COMMENT;
|
||||
else if (strcmp(element_name, "album") == 0)
|
||||
parser->tag_type = TAG_ALBUM;
|
||||
else if (strcmp(element_name, "trackNum") == 0)
|
||||
parser->tag_type = TAG_TRACK;
|
||||
else if (!parser->location.empty()) {
|
||||
parser->tag_type = tag_table_lookup(xspf_tag_elements,
|
||||
element_name);
|
||||
if (parser->tag_type != TAG_NUM_OF_ITEM_TYPES)
|
||||
parser->state = XspfParser::TAG;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case XspfParser::TAG:
|
||||
case XspfParser::LOCATION:
|
||||
break;
|
||||
}
|
||||
@@ -144,15 +152,26 @@ xspf_end_element(void *user_data, const XML_Char *element_name)
|
||||
parser->tag_builder.Commit());
|
||||
|
||||
parser->state = XspfParser::TRACKLIST;
|
||||
} else
|
||||
parser->tag_type = TAG_NUM_OF_ITEM_TYPES;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case XspfParser::TAG:
|
||||
if (!parser->value.empty())
|
||||
parser->tag_builder.AddItem(parser->tag_type,
|
||||
StringView(parser->value.data(),
|
||||
parser->value.length()));
|
||||
|
||||
parser->state = XspfParser::TRACK;
|
||||
break;
|
||||
|
||||
case XspfParser::LOCATION:
|
||||
parser->location = std::move(parser->value);
|
||||
parser->state = XspfParser::TRACK;
|
||||
break;
|
||||
}
|
||||
|
||||
parser->value.clear();
|
||||
}
|
||||
|
||||
static void XMLCALL
|
||||
@@ -164,19 +183,12 @@ xspf_char_data(void *user_data, const XML_Char *s, int len)
|
||||
case XspfParser::ROOT:
|
||||
case XspfParser::PLAYLIST:
|
||||
case XspfParser::TRACKLIST:
|
||||
break;
|
||||
|
||||
case XspfParser::TRACK:
|
||||
if (!parser->location.empty() &&
|
||||
parser->tag_type != TAG_NUM_OF_ITEM_TYPES)
|
||||
parser->tag_builder.AddItem(parser->tag_type,
|
||||
StringView(s, len));
|
||||
|
||||
break;
|
||||
|
||||
case XspfParser::TAG:
|
||||
case XspfParser::LOCATION:
|
||||
parser->location.assign(s, len);
|
||||
|
||||
parser->value.append(s, len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@@ -175,5 +175,5 @@ SignedSongTime
|
||||
ParseCommandArgSignedSongTime(const char *s)
|
||||
{
|
||||
auto value = ParseCommandArgFloat(s);
|
||||
return SongTime::FromS(value);
|
||||
return SignedSongTime::FromS(value);
|
||||
}
|
||||
|
@@ -109,7 +109,9 @@ public:
|
||||
BIND_THIS_METHOD(OnDeferredStart)),
|
||||
request(curl, uri, *this) {
|
||||
// TODO: use CurlInputStream's configuration
|
||||
}
|
||||
|
||||
void DeferStart() noexcept {
|
||||
/* start the transfer inside the IOThread */
|
||||
defer_start.Schedule();
|
||||
}
|
||||
@@ -264,8 +266,8 @@ public:
|
||||
CommonExpatParser(ExpatNamespaceSeparator{'|'})
|
||||
{
|
||||
request.SetOption(CURLOPT_CUSTOMREQUEST, "PROPFIND");
|
||||
request.SetOption(CURLOPT_FOLLOWLOCATION, 1l);
|
||||
request.SetOption(CURLOPT_MAXREDIRS, 1l);
|
||||
request.SetOption(CURLOPT_FOLLOWLOCATION, 1L);
|
||||
request.SetOption(CURLOPT_MAXREDIRS, 1L);
|
||||
|
||||
request_headers.Append(StringFormat<40>("depth: %u", depth));
|
||||
|
||||
@@ -283,6 +285,7 @@ public:
|
||||
}
|
||||
|
||||
using BlockingHttpRequest::GetEasy;
|
||||
using BlockingHttpRequest::DeferStart;
|
||||
using BlockingHttpRequest::Wait;
|
||||
|
||||
protected:
|
||||
@@ -430,6 +433,7 @@ public:
|
||||
}
|
||||
|
||||
const StorageFileInfo &Perform() {
|
||||
DeferStart();
|
||||
Wait();
|
||||
return info;
|
||||
}
|
||||
@@ -481,6 +485,7 @@ public:
|
||||
base_path(UriPathOrSlash(uri)) {}
|
||||
|
||||
std::unique_ptr<StorageDirectoryReader> Perform() {
|
||||
DeferStart();
|
||||
Wait();
|
||||
return ToReader();
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user