Compare commits
240 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
9274bc15bc | ||
![]() |
751fff07fb | ||
![]() |
f7d1408a1a | ||
![]() |
e4e14ef6b0 | ||
![]() |
005e691339 | ||
![]() |
61eff1cddf | ||
![]() |
c26703b7e6 | ||
![]() |
db27bb76e2 | ||
![]() |
7cfe929c36 | ||
![]() |
6c06244e83 | ||
![]() |
53448e4633 | ||
![]() |
21adc78713 | ||
![]() |
0340b01392 | ||
![]() |
94aed92e9a | ||
![]() |
6b9966e969 | ||
![]() |
4bc5333995 | ||
![]() |
ff58b8d255 | ||
![]() |
3f3f0af543 | ||
![]() |
850d208b7b | ||
![]() |
da563940b4 | ||
![]() |
282859a62a | ||
![]() |
fbeb5eefdc | ||
![]() |
85bada0505 | ||
![]() |
cf96135125 | ||
![]() |
1ff97783ea | ||
![]() |
2bc42c6445 | ||
![]() |
49372a222f | ||
![]() |
9127afbf3f | ||
![]() |
f2caac595a | ||
![]() |
14d3a7ae83 | ||
![]() |
f37ab5482b | ||
![]() |
ef38dbe5bf | ||
![]() |
54a5491b86 | ||
![]() |
aff070bcbb | ||
![]() |
5af2632d4f | ||
![]() |
44a31357f4 | ||
![]() |
29f78b18b1 | ||
![]() |
147872fe97 | ||
![]() |
38edb58054 | ||
![]() |
98afae2520 | ||
![]() |
ddc85c620f | ||
![]() |
12bc625fe1 | ||
![]() |
6b407356b9 | ||
![]() |
a4e0b52468 | ||
![]() |
98efb4f6d5 | ||
![]() |
36edb4886c | ||
![]() |
76290f786d | ||
![]() |
c6299c26b5 | ||
![]() |
fb5f9baf9c | ||
![]() |
dee591d970 | ||
![]() |
a5cc13b0c5 | ||
![]() |
aaf588aeaa | ||
![]() |
533a3def9f | ||
![]() |
fcf487f4e0 | ||
![]() |
906972973e | ||
![]() |
116edf5fce | ||
![]() |
8581013911 | ||
![]() |
b1e073bacd | ||
![]() |
501e48daba | ||
![]() |
643ecd1edd | ||
![]() |
7393e1cba1 | ||
![]() |
ceee47fda8 | ||
![]() |
6f3c0d0a60 | ||
![]() |
466625f7ad | ||
![]() |
b8259e604a | ||
![]() |
86e2075c63 | ||
![]() |
30900b2fe2 | ||
![]() |
fd7ae7ea4c | ||
![]() |
60d5bf0240 | ||
![]() |
41cdc4e14b | ||
![]() |
87dfca0477 | ||
![]() |
e1ee8e7812 | ||
![]() |
63406efcd8 | ||
![]() |
d5c132fca0 | ||
![]() |
5f082a2739 | ||
![]() |
7d6a762845 | ||
![]() |
8dcb1f805d | ||
![]() |
a8b9e5b9b9 | ||
![]() |
04f928e2b0 | ||
![]() |
c7a803c922 | ||
![]() |
ab197b6d43 | ||
![]() |
16b0e53a36 | ||
![]() |
bc14a6038e | ||
![]() |
626329a1cc | ||
![]() |
8bf250c228 | ||
![]() |
62127bbb12 | ||
![]() |
786ac87b76 | ||
![]() |
c76f4ac89b | ||
![]() |
d495ec71a8 | ||
![]() |
b763852f57 | ||
![]() |
6522d2f722 | ||
![]() |
ac61fd1d78 | ||
![]() |
c44d1566fa | ||
![]() |
80dc7c2f74 | ||
![]() |
7b94f0e36b | ||
![]() |
504e8d564a | ||
![]() |
ac395429c3 | ||
![]() |
388768b3a6 | ||
![]() |
5c4169e64e | ||
![]() |
d40e9de2d2 | ||
![]() |
1e54297be8 | ||
![]() |
44b200240f | ||
![]() |
a2340c313f | ||
![]() |
37b07a5e7c | ||
![]() |
73013a3c04 | ||
![]() |
e8099f01b5 | ||
![]() |
672bdd3a56 | ||
![]() |
c2c2c29658 | ||
![]() |
c745e14f47 | ||
![]() |
e8f08cda53 | ||
![]() |
8266ab5588 | ||
![]() |
ea552208fc | ||
![]() |
e86015a72a | ||
![]() |
cf7ec2c9d3 | ||
![]() |
dadd3ca671 | ||
![]() |
79535212c8 | ||
![]() |
ef5f96a193 | ||
![]() |
418f71ec0f | ||
![]() |
0ebeaa9ac2 | ||
![]() |
25cd47b8dc | ||
![]() |
cd48d981b5 | ||
![]() |
774d26b982 | ||
![]() |
f3e683bd6f | ||
![]() |
50ce0c0d9d | ||
![]() |
5b80711d75 | ||
![]() |
666e456551 | ||
![]() |
31794ac376 | ||
![]() |
2141fdf06e | ||
![]() |
3f3e0739c4 | ||
![]() |
ebed7e2147 | ||
![]() |
53f5d4c710 | ||
![]() |
139a4054c5 | ||
![]() |
a4de96508d | ||
![]() |
a7582aaf15 | ||
![]() |
c5c1c64a81 | ||
![]() |
992c52ce7f | ||
![]() |
026aef7465 | ||
![]() |
b53a23b51b | ||
![]() |
2aad015392 | ||
![]() |
986ec877b0 | ||
![]() |
c43ea74b30 | ||
![]() |
79981f3cda | ||
![]() |
c2940a8385 | ||
![]() |
bede564618 | ||
![]() |
e0ca4b865a | ||
![]() |
31c206bf80 | ||
![]() |
9187a08106 | ||
![]() |
3859a50466 | ||
![]() |
927071e085 | ||
![]() |
6ba918b203 | ||
![]() |
e8b70dbca4 | ||
![]() |
0f8d223c7f | ||
![]() |
19a2885fd5 | ||
![]() |
b8a094470b | ||
![]() |
2988bb77e8 | ||
![]() |
738317bf34 | ||
![]() |
e46fbd0780 | ||
![]() |
56b74ad990 | ||
![]() |
6de92bb42b | ||
![]() |
c801936e53 | ||
![]() |
817656504d | ||
![]() |
6f00f97b66 | ||
![]() |
5acb978f8f | ||
![]() |
975a4ae871 | ||
![]() |
56aaf3c73e | ||
![]() |
12fd1cad0c | ||
![]() |
e573cbf032 | ||
![]() |
dead461542 | ||
![]() |
3d5da1ac73 | ||
![]() |
ec408ca6a6 | ||
![]() |
ea66cdd6a5 | ||
![]() |
f762e8034f | ||
![]() |
bb1e369f30 | ||
![]() |
8376578921 | ||
![]() |
ed2354cd9d | ||
![]() |
386688b87a | ||
![]() |
38d56dddf1 | ||
![]() |
e8975942ec | ||
![]() |
3ca80a7336 | ||
![]() |
d029dae7ad | ||
![]() |
9e058732ee | ||
![]() |
cad5d11261 | ||
![]() |
fcaedec2ab | ||
![]() |
ead9d59e88 | ||
![]() |
34b8a17ccd | ||
![]() |
a53d081c39 | ||
![]() |
823134e4ba | ||
![]() |
272167b4fc | ||
![]() |
92f09bba94 | ||
![]() |
1f50bdb230 | ||
![]() |
2eef4e6716 | ||
![]() |
d989dbfec4 | ||
![]() |
ca9fcec364 | ||
![]() |
354104f9a9 | ||
![]() |
8649ea3d6f | ||
![]() |
752ff12c37 | ||
![]() |
4bb89b1755 | ||
![]() |
0ef553d30e | ||
![]() |
43a62aef07 | ||
![]() |
ed4d0aa909 | ||
![]() |
023ce4e720 | ||
![]() |
368d9359dd | ||
![]() |
d98c19d561 | ||
![]() |
cab77e35e0 | ||
![]() |
e3e90b4b93 | ||
![]() |
f8c69893e1 | ||
![]() |
49678a0893 | ||
![]() |
d667b5b48c | ||
![]() |
9cba55b39c | ||
![]() |
c2cbb7b8ce | ||
![]() |
8217d75ca1 | ||
![]() |
1ca70d9759 | ||
![]() |
4303aaa9b8 | ||
![]() |
7b56bae289 | ||
![]() |
4183416b3e | ||
![]() |
a60dee57ce | ||
![]() |
5724656acb | ||
![]() |
329f9cd9fe | ||
![]() |
fbdb8b406e | ||
![]() |
85d0bbd957 | ||
![]() |
414f00d6ae | ||
![]() |
17b0add058 | ||
![]() |
c68ed40661 | ||
![]() |
ff624075a8 | ||
![]() |
08db28469d | ||
![]() |
a20b326807 | ||
![]() |
4db1b1b250 | ||
![]() |
ff6b263b48 | ||
![]() |
c0bf052fa9 | ||
![]() |
5419cff925 | ||
![]() |
eee10ad2ed | ||
![]() |
98472a8104 | ||
![]() |
d094c168aa | ||
![]() |
4b18460bc6 | ||
![]() |
412c0a965c | ||
![]() |
2becf79223 | ||
![]() |
43ec96d4a0 | ||
![]() |
3d1d779da7 | ||
![]() |
c88056ba83 | ||
![]() |
e769751221 |
5
AUTHORS
5
AUTHORS
@@ -31,3 +31,8 @@ The following people have contributed code to MPD:
|
|||||||
Jean-Francois Dockes <jf@dockes.org>
|
Jean-Francois Dockes <jf@dockes.org>
|
||||||
Yue Wang <yuleopen@gmail.com>
|
Yue Wang <yuleopen@gmail.com>
|
||||||
Matthew Leon Grinshpun <ml@matthewleon.com>
|
Matthew Leon Grinshpun <ml@matthewleon.com>
|
||||||
|
Dimitris Papastamos <sin@2f30.org>
|
||||||
|
Florian Schlichting <fsfs@debian.org>
|
||||||
|
François Revol <revol@free.fr>
|
||||||
|
Jacob Vosmaer <contact@jacobvosmaer.nl>
|
||||||
|
Thomas Guillem <thomas@gllm.fr>
|
||||||
|
142
Makefile.am
142
Makefile.am
@@ -61,8 +61,8 @@ src_mpd_LDADD = \
|
|||||||
libnet.a \
|
libnet.a \
|
||||||
$(FS_LIBS) \
|
$(FS_LIBS) \
|
||||||
libsystem.a \
|
libsystem.a \
|
||||||
libutil.a \
|
|
||||||
$(ICU_LDADD) \
|
$(ICU_LDADD) \
|
||||||
|
libutil.a \
|
||||||
$(SYSTEMD_DAEMON_LIBS)
|
$(SYSTEMD_DAEMON_LIBS)
|
||||||
|
|
||||||
src_mpd_SOURCES = \
|
src_mpd_SOURCES = \
|
||||||
@@ -234,6 +234,7 @@ libmpd_a_SOURCES += \
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
CURL_SOURCES = \
|
CURL_SOURCES = \
|
||||||
|
src/lib/curl/Error.hxx \
|
||||||
src/lib/curl/Version.cxx src/lib/curl/Version.hxx \
|
src/lib/curl/Version.cxx src/lib/curl/Version.hxx \
|
||||||
src/lib/curl/Global.cxx src/lib/curl/Global.hxx \
|
src/lib/curl/Global.cxx src/lib/curl/Global.hxx \
|
||||||
src/lib/curl/Request.cxx src/lib/curl/Request.hxx \
|
src/lib/curl/Request.cxx src/lib/curl/Request.hxx \
|
||||||
@@ -275,7 +276,8 @@ libjava_a_SOURCES = \
|
|||||||
noinst_LIBRARIES += libandroid.a
|
noinst_LIBRARIES += libandroid.a
|
||||||
libandroid_a_SOURCES = \
|
libandroid_a_SOURCES = \
|
||||||
src/android/Context.cxx src/android/Context.hxx \
|
src/android/Context.cxx src/android/Context.hxx \
|
||||||
src/android/Environment.cxx src/android/Environment.hxx
|
src/android/Environment.cxx src/android/Environment.hxx \
|
||||||
|
src/android/LogListener.cxx src/android/LogListener.hxx
|
||||||
libandroid_a_CPPFLAGS = $(AM_CPPFLAGS) -Iandroid/build/include
|
libandroid_a_CPPFLAGS = $(AM_CPPFLAGS) -Iandroid/build/include
|
||||||
|
|
||||||
noinst_LIBRARIES += libmain.a
|
noinst_LIBRARIES += libmain.a
|
||||||
@@ -285,56 +287,108 @@ libmain_a_CPPFLAGS = $(AM_CPPFLAGS) -Iandroid/build/include
|
|||||||
|
|
||||||
src_mpd_LDADD += libandroid.a libjava.a
|
src_mpd_LDADD += libandroid.a libjava.a
|
||||||
|
|
||||||
all-local: android/build/bin/$(APK_NAME)-debug.apk
|
all-local: android/build/$(APK_NAME)-debug.apk
|
||||||
clean-local:
|
clean-local:
|
||||||
rm -rf android/build
|
rm -rf android/build
|
||||||
|
|
||||||
libmpd.so: $(filter %.a,$(src_mpd_LDADD)) libmain.a
|
libmpd.so: $(filter %.a,$(src_mpd_LDADD)) libmain.a
|
||||||
|
$(AM_V_GEN)
|
||||||
$(AM_V_CXXLD)$(CXXLD) -shared -Wl,--no-undefined,-shared,-Bsymbolic -llog -lz -o $@ $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) src/libmain_a-Main.o $(src_mpd_LDADD) $(LIBS)
|
$(AM_V_CXXLD)$(CXXLD) -shared -Wl,--no-undefined,-shared,-Bsymbolic -llog -lz -o $@ $(AM_CXXFLAGS) $(CXXFLAGS) $(LDFLAGS) src/libmain_a-Main.o $(src_mpd_LDADD) $(LIBS)
|
||||||
|
|
||||||
android/build/build.xml: android/AndroidManifest.xml
|
ANDROID_SDK_BUILD_TOOLS_VERSION = 27.0.0
|
||||||
rm -rf android/build
|
ANDROID_SDK_PLATFORM = android-21
|
||||||
mkdir -p android/build/include android/build/res android/build/src/org
|
|
||||||
ln -s $(abs_srcdir)/android/AndroidManifest.xml $(abs_srcdir)/android/custom_rules.xml android/build
|
|
||||||
ln -s $(abs_srcdir)/android/src android/build/src/org/musicpd
|
|
||||||
ln -s $(abs_srcdir)/android/res/values $(abs_srcdir)/android/res/layout android/build/res
|
|
||||||
$(ANDROID_SDK)/tools/android update project --path android/build --target android-17 --name $(APK_NAME)
|
|
||||||
|
|
||||||
android/build/bin/classes/org/musicpd/Bridge.class: android/src/Bridge.java android/build/build.xml android/build/res/drawable/icon.png
|
ANDROID_BUILD_TOOLS_DIR = $(ANDROID_SDK)/build-tools/$(ANDROID_SDK_BUILD_TOOLS_VERSION)
|
||||||
cd android/build && ant compile-jni-classes
|
ANDROID_SDK_PLATFORM_DIR = $(ANDROID_SDK)/platforms/$(ANDROID_SDK_PLATFORM)
|
||||||
|
|
||||||
android/build/include/org_musicpd_Bridge.h: android/build/bin/classes/org/musicpd/Bridge.class
|
JAVAC = javac
|
||||||
javah -classpath $(ANDROID_SDK)/platforms/android-17/android.jar:android/build/bin/classes -d $(@D) org.musicpd.Bridge
|
AIDL = $(ANDROID_BUILD_TOOLS_DIR)/aidl
|
||||||
|
AAPT = $(ANDROID_BUILD_TOOLS_DIR)/aapt
|
||||||
|
DX = $(ANDROID_BUILD_TOOLS_DIR)/dx
|
||||||
|
ZIPALIGN = $(ANDROID_BUILD_TOOLS_DIR)/zipalign
|
||||||
|
|
||||||
|
ANDROID_XML_RES := $(wildcard $(srcdir)/android/res/*/*.xml)
|
||||||
|
ANDROID_XML_RES_COPIES := $(patsubst $(srcdir)/android/%,android/build/%,$(ANDROID_XML_RES))
|
||||||
|
|
||||||
|
JAVA_SOURCE_NAMES = Bridge.java Loader.java Main.java Settings.java
|
||||||
|
JAVA_SOURCE_PATHS = $(addprefix $(srcdir)/android/src/,$(JAVA_SOURCE_NAMES))
|
||||||
|
|
||||||
|
JAVA_CLASSFILES_DIR = android/build/classes
|
||||||
|
|
||||||
|
AIDL_FILES = $(wildcard $(srcdir)/android/src/*.aidl)
|
||||||
|
AIDL_JAVA_FILES = $(patsubst $(srcdir)/android/src/%.aidl,android/build/src/org/musicpd/%.java,$(AIDL_FILES))
|
||||||
|
|
||||||
|
android/build/src/org/musicpd/IMain.java: android/build/src/org/musicpd/IMainCallback.java
|
||||||
|
|
||||||
|
$(AIDL_JAVA_FILES): android/build/src/org/musicpd/%.java: $(srcdir)/android/src/%.aidl
|
||||||
|
$(AM_V_GEN)
|
||||||
|
$(AM_V_at)$(MKDIR_P) $(@D)
|
||||||
|
$(AM_V_at)cp $< $(@D)/
|
||||||
|
$(AM_V_at)$(AIDL) -Iandroid/build/src -oandroid/build/src $(patsubst %.java,%.aidl,$@)
|
||||||
|
|
||||||
|
$(ANDROID_XML_RES_COPIES): $(ANDROID_XML_RES)
|
||||||
|
$(AM_V_at)$(MKDIR_P) $(@D)
|
||||||
|
$(AM_V_at)cp $(patsubst android/build/%,$(srcdir)/android/%,$@) $@
|
||||||
|
|
||||||
|
android/build/resources.apk: $(ANDROID_XML_RES_COPIES) android/build/res/drawable/icon.png android/build/res/drawable/notification_icon.png
|
||||||
|
$(AM_V_GEN)
|
||||||
|
$(AM_V_at)$(MKDIR_P) android/build/gen
|
||||||
|
$(AM_V_at)$(AAPT) package -f -m --auto-add-overlay \
|
||||||
|
--custom-package org.musicpd \
|
||||||
|
-M $(srcdir)/android/AndroidManifest.xml \
|
||||||
|
-S android/build/res \
|
||||||
|
-J android/build/gen \
|
||||||
|
-I $(ANDROID_SDK_PLATFORM_DIR)/android.jar \
|
||||||
|
-F android/build/resources.apk
|
||||||
|
|
||||||
|
# R.java is generated by aapt, when resources.apk is generated
|
||||||
|
android/build/gen/org/musicpd/R.java: android/build/resources.apk
|
||||||
|
|
||||||
|
android/build/classes.dex: $(JAVA_SOURCE_PATHS) $(AIDL_JAVA_FILES) android/build/gen/org/musicpd/R.java
|
||||||
|
$(AM_V_GEN)
|
||||||
|
$(AM_V_at)$(MKDIR_P) $(JAVA_CLASSFILES_DIR)
|
||||||
|
$(AM_V_at)$(JAVAC) -source 1.6 -target 1.6 -Xlint:-options \
|
||||||
|
-cp $(ANDROID_SDK_PLATFORM_DIR)/android.jar:$(JAVA_CLASSFILES_DIR) \
|
||||||
|
-h android/build/include \
|
||||||
|
-d $(JAVA_CLASSFILES_DIR) $^
|
||||||
|
$(AM_V_at)$(DX) --dex --output $@ $(JAVA_CLASSFILES_DIR)
|
||||||
|
|
||||||
|
android/build/include/org_musicpd_Bridge.h: android/build/classes.dex
|
||||||
|
|
||||||
BUILT_SOURCES = android/build/include/org_musicpd_Bridge.h
|
BUILT_SOURCES = android/build/include/org_musicpd_Bridge.h
|
||||||
|
|
||||||
android/build/libs/armeabi-v7a/libmpd.so: libmpd.so android/build/build.xml
|
android/build/lib/$(ANDROID_ABI)/libmpd.so: libmpd.so
|
||||||
mkdir -p $(@D)
|
$(AM_V_GEN)
|
||||||
rm -f $@
|
$(AM_V_at)$(MKDIR_P) $(@D)
|
||||||
$(STRIP) -o $@ $<
|
$(AM_V_at)rm -f $@
|
||||||
|
$(AM_V_at)$(STRIP) -o $@ $<
|
||||||
|
|
||||||
android/build/res/drawable/icon.png: mpd.svg
|
android/build/res/drawable/icon.png: mpd.svg
|
||||||
mkdir -p $(@D)
|
$(AM_V_GEN)
|
||||||
rsvg-convert --width=48 --height=48 $< -o $@
|
$(AM_V_at)$(MKDIR_P) $(@D)
|
||||||
|
$(AM_V_at)rsvg-convert --width=48 --height=48 $< -o $@
|
||||||
|
|
||||||
APK_DEPS = android/build/res/drawable/icon.png \
|
android/build/res/drawable/notification_icon.png: android/build/res/drawable/icon.png
|
||||||
android/build/libs/armeabi-v7a/libmpd.so \
|
$(AM_V_GEN)
|
||||||
$(wildcard $(srcdir)/android/src/*.java) \
|
$(AM_V_at)convert $< -colorspace Gray -gamma 2.2 $@
|
||||||
android/build/build.xml
|
|
||||||
|
|
||||||
android/build/bin/$(APK_NAME)-debug.apk: $(APK_DEPS)
|
.DELETE_ON_ERROR: android/build/unsigned.apk
|
||||||
cd android/build && ant nodeps debug
|
android/build/unsigned.apk: android/build/classes.dex android/build/resources.apk android/build/lib/$(ANDROID_ABI)/libmpd.so
|
||||||
|
$(AM_V_GEN)
|
||||||
|
$(AM_V_at)cp android/build/resources.apk $@
|
||||||
|
$(AM_V_at)cd $(@D) && zip -q -r $(@F) classes.dex lib
|
||||||
|
|
||||||
android/build/bin/$(APK_NAME)-release-unsigned.apk: $(APK_DEPS)
|
android/build/$(APK_NAME)-debug.apk: android/build/unsigned.apk
|
||||||
cd android/build && ant nodeps release
|
$(AM_V_GEN)
|
||||||
|
$(AM_V_at)jarsigner -keystore $(HOME)/.android/debug.keystore -storepass android -signedjar $@ $< androiddebugkey
|
||||||
|
|
||||||
android/build/bin/$(APK_NAME)-release-unaligned.apk: android/build/bin/$(APK_NAME)-release-unsigned.apk
|
android/build/$(APK_NAME)-release-unaligned.apk: android/build/unsigned.apk
|
||||||
jarsigner -digestalg SHA1 -sigalg MD5withRSA -storepass:env ANDROID_KEYSTORE_PASS -keystore $(ANDROID_KEYSTORE) -signedjar $@ $< $(ANDROID_KEY_ALIAS)
|
$(AM_V_GEN)
|
||||||
|
$(AM_V_at)jarsigner -digestalg SHA1 -sigalg MD5withRSA -storepass:env ANDROID_KEYSTORE_PASS -keystore $(ANDROID_KEYSTORE) -signedjar $@ $< $(ANDROID_KEY_ALIAS)
|
||||||
|
|
||||||
ANDROID_SDK_BUILD_TOOLS_VERSION = 20.0.0
|
android/build/$(APK_NAME).apk: android/build/$(APK_NAME)-release-unaligned.apk
|
||||||
|
$(AM_V_GEN)
|
||||||
android/build/bin/$(APK_NAME).apk: android/build/bin/$(APK_NAME)-release-unaligned.apk
|
$(AM_V_at)$(ZIPALIGN) -f 4 $< $@
|
||||||
$(ANDROID_SDK)/build-tools/$(ANDROID_SDK_BUILD_TOOLS_VERSION)/zipalign -f 4 $< $@
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@@ -417,6 +471,7 @@ libutil_a_SOURCES = \
|
|||||||
src/util/NumberParser.hxx \
|
src/util/NumberParser.hxx \
|
||||||
src/util/MimeType.cxx src/util/MimeType.hxx \
|
src/util/MimeType.cxx src/util/MimeType.hxx \
|
||||||
src/util/StringBuffer.hxx \
|
src/util/StringBuffer.hxx \
|
||||||
|
src/util/StringFormat.hxx \
|
||||||
src/util/StringPointer.hxx \
|
src/util/StringPointer.hxx \
|
||||||
src/util/StringView.cxx src/util/StringView.hxx \
|
src/util/StringView.cxx src/util/StringView.hxx \
|
||||||
src/util/AllocatedString.cxx src/util/AllocatedString.hxx \
|
src/util/AllocatedString.cxx src/util/AllocatedString.hxx \
|
||||||
@@ -470,6 +525,7 @@ libthread_a_SOURCES = \
|
|||||||
|
|
||||||
libnet_a_SOURCES = \
|
libnet_a_SOURCES = \
|
||||||
src/net/Features.hxx \
|
src/net/Features.hxx \
|
||||||
|
src/net/Init.hxx \
|
||||||
src/net/ToString.cxx src/net/ToString.hxx \
|
src/net/ToString.cxx src/net/ToString.hxx \
|
||||||
src/net/Resolver.cxx src/net/Resolver.hxx \
|
src/net/Resolver.cxx src/net/Resolver.hxx \
|
||||||
src/net/StaticSocketAddress.cxx src/net/StaticSocketAddress.hxx \
|
src/net/StaticSocketAddress.cxx src/net/StaticSocketAddress.hxx \
|
||||||
@@ -684,6 +740,7 @@ NFS_SOURCES = \
|
|||||||
src/lib/nfs/Cancellable.hxx \
|
src/lib/nfs/Cancellable.hxx \
|
||||||
src/lib/nfs/Lease.hxx \
|
src/lib/nfs/Lease.hxx \
|
||||||
src/lib/nfs/Connection.cxx src/lib/nfs/Connection.hxx \
|
src/lib/nfs/Connection.cxx src/lib/nfs/Connection.hxx \
|
||||||
|
src/lib/nfs/Error.cxx src/lib/nfs/Error.hxx \
|
||||||
src/lib/nfs/Manager.cxx src/lib/nfs/Manager.hxx \
|
src/lib/nfs/Manager.cxx src/lib/nfs/Manager.hxx \
|
||||||
src/lib/nfs/Glue.cxx src/lib/nfs/Glue.hxx \
|
src/lib/nfs/Glue.cxx src/lib/nfs/Glue.hxx \
|
||||||
src/lib/nfs/Base.cxx src/lib/nfs/Base.hxx \
|
src/lib/nfs/Base.cxx src/lib/nfs/Base.hxx \
|
||||||
@@ -706,6 +763,8 @@ libstorage_a_SOURCES = \
|
|||||||
src/storage/FileInfo.hxx
|
src/storage/FileInfo.hxx
|
||||||
|
|
||||||
libstorage_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
libstorage_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||||
|
$(CURL_CFLAGS) \
|
||||||
|
$(EXPAT_CFLAGS) \
|
||||||
$(NFS_CFLAGS) \
|
$(NFS_CFLAGS) \
|
||||||
$(SMBCLIENT_CFLAGS)
|
$(SMBCLIENT_CFLAGS)
|
||||||
|
|
||||||
@@ -918,13 +977,14 @@ libtag_a_SOURCES =\
|
|||||||
src/tag/TagItem.hxx \
|
src/tag/TagItem.hxx \
|
||||||
src/tag/TagHandler.cxx src/tag/TagHandler.hxx \
|
src/tag/TagHandler.cxx src/tag/TagHandler.hxx \
|
||||||
src/tag/Mask.hxx \
|
src/tag/Mask.hxx \
|
||||||
|
src/tag/Fallback.hxx \
|
||||||
|
src/tag/VisitFallback.hxx \
|
||||||
src/tag/Settings.cxx src/tag/Settings.hxx \
|
src/tag/Settings.cxx src/tag/Settings.hxx \
|
||||||
src/tag/TagConfig.cxx src/tag/TagConfig.hxx \
|
src/tag/TagConfig.cxx src/tag/TagConfig.hxx \
|
||||||
src/tag/TagNames.c \
|
src/tag/TagNames.c \
|
||||||
src/tag/TagString.cxx src/tag/TagString.hxx \
|
src/tag/TagString.cxx src/tag/TagString.hxx \
|
||||||
src/tag/TagPool.cxx src/tag/TagPool.hxx \
|
src/tag/TagPool.cxx src/tag/TagPool.hxx \
|
||||||
src/tag/TagTable.cxx src/tag/TagTable.hxx \
|
src/tag/TagTable.cxx src/tag/TagTable.hxx \
|
||||||
src/tag/Set.cxx src/tag/Set.hxx \
|
|
||||||
src/tag/Format.cxx src/tag/Format.hxx \
|
src/tag/Format.cxx src/tag/Format.hxx \
|
||||||
src/tag/VorbisComment.cxx src/tag/VorbisComment.hxx \
|
src/tag/VorbisComment.cxx src/tag/VorbisComment.hxx \
|
||||||
src/tag/ReplayGain.cxx src/tag/ReplayGain.hxx \
|
src/tag/ReplayGain.cxx src/tag/ReplayGain.hxx \
|
||||||
@@ -1264,7 +1324,7 @@ endif
|
|||||||
#
|
#
|
||||||
|
|
||||||
libinput_a_SOURCES = \
|
libinput_a_SOURCES = \
|
||||||
src/input/Domain.cxx src/input/Domain.hxx \
|
src/input/Error.cxx src/input/Error.hxx \
|
||||||
src/input/Init.cxx src/input/Init.hxx \
|
src/input/Init.cxx src/input/Init.hxx \
|
||||||
src/input/Registry.cxx src/input/Registry.hxx \
|
src/input/Registry.cxx src/input/Registry.hxx \
|
||||||
src/input/Open.cxx \
|
src/input/Open.cxx \
|
||||||
@@ -1642,6 +1702,13 @@ FILTER_LIBS = \
|
|||||||
$(PCM_LIBS)
|
$(PCM_LIBS)
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# Icon
|
||||||
|
#
|
||||||
|
|
||||||
|
iconsdir = $(datadir)/icons/hicolor/scalable/apps
|
||||||
|
icons_DATA = mpd.svg
|
||||||
|
|
||||||
#
|
#
|
||||||
# systemd unit
|
# systemd unit
|
||||||
#
|
#
|
||||||
@@ -2132,6 +2199,7 @@ test_run_output_LDADD = $(MPD_LIBS) \
|
|||||||
libutil.a
|
libutil.a
|
||||||
test_run_output_SOURCES = test/run_output.cxx \
|
test_run_output_SOURCES = test/run_output.cxx \
|
||||||
test/ScopeIOThread.hxx \
|
test/ScopeIOThread.hxx \
|
||||||
|
test/NullMixerListener.hxx \
|
||||||
src/Log.cxx src/LogBackend.cxx \
|
src/Log.cxx src/LogBackend.cxx \
|
||||||
src/IOThread.cxx \
|
src/IOThread.cxx \
|
||||||
src/output/Domain.cxx \
|
src/output/Domain.cxx \
|
||||||
@@ -2155,6 +2223,7 @@ test_read_mixer_LDADD = \
|
|||||||
libsystem.a \
|
libsystem.a \
|
||||||
libutil.a
|
libutil.a
|
||||||
test_read_mixer_SOURCES = test/read_mixer.cxx \
|
test_read_mixer_SOURCES = test/read_mixer.cxx \
|
||||||
|
test/NullMixerListener.hxx \
|
||||||
src/Log.cxx src/LogBackend.cxx \
|
src/Log.cxx src/LogBackend.cxx \
|
||||||
src/mixer/MixerControl.cxx \
|
src/mixer/MixerControl.cxx \
|
||||||
src/filter/FilterPlugin.cxx \
|
src/filter/FilterPlugin.cxx \
|
||||||
@@ -2409,6 +2478,7 @@ endif
|
|||||||
#
|
#
|
||||||
|
|
||||||
EXTRA_DIST = $(doc_DATA) autogen.sh \
|
EXTRA_DIST = $(doc_DATA) autogen.sh \
|
||||||
|
mpd.svg \
|
||||||
test/test_archive_bzip2.sh \
|
test/test_archive_bzip2.sh \
|
||||||
test/test_archive_iso9660.sh \
|
test/test_archive_iso9660.sh \
|
||||||
test/test_archive_zzip.sh \
|
test/test_archive_zzip.sh \
|
||||||
|
103
NEWS
103
NEWS
@@ -1,3 +1,106 @@
|
|||||||
|
ver 0.20.22 (2018/10/23)
|
||||||
|
* protocol
|
||||||
|
- add tag fallbacks for AlbumArtistSort, ArtistSort
|
||||||
|
- fix empty string filter on fallback tags
|
||||||
|
- "count group ..." can print an empty group
|
||||||
|
- fix broken command "list ... group"
|
||||||
|
* storage
|
||||||
|
- curl: URL-encode paths
|
||||||
|
* decoder
|
||||||
|
- fluidsynth: adapt to API change in version 2.0
|
||||||
|
* Android
|
||||||
|
- now runs as a service
|
||||||
|
- add button to start/stop MPD
|
||||||
|
- add option to auto-start on boot
|
||||||
|
* work around clang bug leading to crash
|
||||||
|
* install the SVG icon
|
||||||
|
|
||||||
|
ver 0.20.21 (2018/08/17)
|
||||||
|
* database
|
||||||
|
- proxy: add "password" setting
|
||||||
|
- proxy: support tags "ArtistSort", "AlbumArtistSort", "AlbumSort"
|
||||||
|
- simple: allow .mpdignore comments only at start of line
|
||||||
|
* output
|
||||||
|
- httpd: remove broken DLNA support code
|
||||||
|
* playlist
|
||||||
|
- cue: support file type declaration "FLAC" (non-standard)
|
||||||
|
* URI schemes are case insensitive
|
||||||
|
* Android, Windows
|
||||||
|
- enable the "curl" storage plugin
|
||||||
|
|
||||||
|
ver 0.20.20 (2018/05/22)
|
||||||
|
* protocol
|
||||||
|
- fix "modified-since" filter regression
|
||||||
|
* output
|
||||||
|
- pulse: cork stream when paused due to "single" mode
|
||||||
|
* decoder
|
||||||
|
- dsdiff, dsf: support more MIME types
|
||||||
|
- dsdiff, dsf: allow 4 MB ID3 tags
|
||||||
|
- opus: support R128_ALBUM_GAIN tag
|
||||||
|
* Android, Windows
|
||||||
|
- enable the "proxy" database plugin
|
||||||
|
|
||||||
|
ver 0.20.19 (2018/04/26)
|
||||||
|
* protocol
|
||||||
|
- validate absolute seek time, reject negative values
|
||||||
|
* database
|
||||||
|
- proxy: fix "search already in progress" errors
|
||||||
|
- proxy: implement "list ... group"
|
||||||
|
* input
|
||||||
|
- mms: fix lockup bug and a crash bug
|
||||||
|
* decoder
|
||||||
|
- ffmpeg: fix av_register_all() deprecation warning (FFmpeg 4.0)
|
||||||
|
* player
|
||||||
|
- fix spurious "Not seekable" error when switching radio streams
|
||||||
|
* macOS: fix crash bug
|
||||||
|
|
||||||
|
ver 0.20.18 (2018/02/24)
|
||||||
|
* input
|
||||||
|
- curl: allow authentication methods other than "Basic"
|
||||||
|
* decoder
|
||||||
|
- flac: improve seeking precision
|
||||||
|
* fix gapless CUE song transitions
|
||||||
|
* Android, Windows
|
||||||
|
- enable the NFS storage plugin
|
||||||
|
|
||||||
|
ver 0.20.17 (2018/02/11)
|
||||||
|
* output
|
||||||
|
- alsa: fix crash bug with 8 channels
|
||||||
|
* mixer
|
||||||
|
- alsa: fix rounding error at volume 0
|
||||||
|
* fix real-time and idle scheduling with Musl
|
||||||
|
* Android
|
||||||
|
- fix compatibility with Android 4.0
|
||||||
|
|
||||||
|
ver 0.20.16 (2018/02/03)
|
||||||
|
* output
|
||||||
|
- pulse: fix crash during auto-detection
|
||||||
|
* database
|
||||||
|
- simple: fix search within mount points
|
||||||
|
- upnp: enable IPv6
|
||||||
|
* archive
|
||||||
|
- iso9660: libcdio 2.0 compatibility
|
||||||
|
* fix crash in debug build on Haiku and other operating systems
|
||||||
|
|
||||||
|
ver 0.20.15 (2018/01/05)
|
||||||
|
* queue: fix crash after seek failure
|
||||||
|
* resampler
|
||||||
|
- soxr: clear internal state after manual song change
|
||||||
|
* state file
|
||||||
|
- make mount point restore errors non-fatal
|
||||||
|
- fix crash when restoring mounts with incompatible database plugin
|
||||||
|
* Android
|
||||||
|
- build without Ant
|
||||||
|
- fix for SIGSYS crash
|
||||||
|
|
||||||
|
ver 0.20.14 (2018/01/01)
|
||||||
|
* database
|
||||||
|
- simple: fix file corruption in the presence of mount points
|
||||||
|
* archive
|
||||||
|
- bz2: fix deadlock
|
||||||
|
- reduce lock contention, fixing lots of xrun problems
|
||||||
|
* fix Solaris build failure
|
||||||
|
|
||||||
ver 0.20.13 (2017/12/18)
|
ver 0.20.13 (2017/12/18)
|
||||||
* output
|
* output
|
||||||
- osx: set up ring buffer to hold at least 100ms
|
- osx: set up ring buffer to hold at least 100ms
|
||||||
|
@@ -2,23 +2,32 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.musicpd"
|
package="org.musicpd"
|
||||||
android:installLocation="auto"
|
android:installLocation="auto"
|
||||||
android:versionCode="13"
|
android:versionCode="21"
|
||||||
android:versionName="0.19.9">
|
android:versionName="0.20.22">
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17"/>
|
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="26"/>
|
||||||
|
|
||||||
<application android:icon="@drawable/icon" android:label="@string/app_name">
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
||||||
<activity android:name=".Main"
|
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
||||||
android:label="@string/app_name"
|
<uses-permission android:name="android.permission.INTERNET"/>
|
||||||
android:launchMode="singleInstance">
|
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||||
|
|
||||||
|
<application android:allowBackup="true"
|
||||||
|
android:icon="@drawable/icon"
|
||||||
|
android:label="@string/app_name">
|
||||||
|
<activity android:name=".Settings"
|
||||||
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN" />
|
<action android:name="android.intent.action.MAIN" />
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
|
<receiver android:name=".Receiver">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.intent.action.BOOT_COMPLETED" />
|
||||||
|
</intent-filter>
|
||||||
|
</receiver>
|
||||||
|
<service android:name=".Main" android:process=":main"/>
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
|
|
||||||
<uses-permission android:name="android.permission.WAKE_LOCK"/>
|
|
||||||
<uses-permission android:name="android.permission.INTERNET"/>
|
|
||||||
</manifest>
|
</manifest>
|
||||||
|
@@ -3,13 +3,14 @@
|
|||||||
import os, os.path
|
import os, os.path
|
||||||
import sys, subprocess
|
import sys, subprocess
|
||||||
|
|
||||||
if len(sys.argv) < 3:
|
if len(sys.argv) < 4:
|
||||||
print("Usage: build.py SDK_PATH NDK_PATH [configure_args...]", file=sys.stderr)
|
print("Usage: build.py SDK_PATH NDK_PATH ABI [configure_args...]", file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
sdk_path = sys.argv[1]
|
sdk_path = sys.argv[1]
|
||||||
ndk_path = sys.argv[2]
|
ndk_path = sys.argv[2]
|
||||||
configure_args = sys.argv[3:]
|
android_abi = sys.argv[3]
|
||||||
|
configure_args = sys.argv[4:]
|
||||||
|
|
||||||
if not os.path.isfile(os.path.join(sdk_path, 'tools', 'android')):
|
if not os.path.isfile(os.path.join(sdk_path, 'tools', 'android')):
|
||||||
print("SDK not found in", ndk_path, file=sys.stderr)
|
print("SDK not found in", ndk_path, file=sys.stderr)
|
||||||
@@ -19,8 +20,36 @@ if not os.path.isdir(ndk_path):
|
|||||||
print("NDK not found in", ndk_path, file=sys.stderr)
|
print("NDK not found in", ndk_path, file=sys.stderr)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
android_abis = {
|
||||||
|
'armeabi-v7a': {
|
||||||
|
'arch': 'arm-linux-androideabi',
|
||||||
|
'ndk_arch': 'arm',
|
||||||
|
'toolchain_arch': 'arm-linux-androideabi',
|
||||||
|
'llvm_triple': 'armv7-none-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',
|
||||||
|
'cflags': '',
|
||||||
|
},
|
||||||
|
|
||||||
|
'x86': {
|
||||||
|
'arch': 'i686-linux-android',
|
||||||
|
'ndk_arch': 'x86',
|
||||||
|
'toolchain_arch': 'x86',
|
||||||
|
'llvm_triple': 'i686-none-linux-android',
|
||||||
|
'cflags': '-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32',
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
# select the NDK target
|
# select the NDK target
|
||||||
arch = 'arm-linux-androideabi'
|
abi_info = android_abis[android_abi]
|
||||||
|
arch = abi_info['arch']
|
||||||
|
|
||||||
# the path to the MPD sources
|
# the path to the MPD sources
|
||||||
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
|
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
|
||||||
@@ -44,16 +73,16 @@ class AndroidNdkToolchain:
|
|||||||
self.src_path = src_path
|
self.src_path = src_path
|
||||||
self.build_path = build_path
|
self.build_path = build_path
|
||||||
|
|
||||||
self.ndk_arch = 'arm'
|
ndk_arch = abi_info['ndk_arch']
|
||||||
android_abi = 'armeabi-v7a'
|
android_api_level = '21'
|
||||||
ndk_platform = 'android-21'
|
ndk_platform = 'android-' + android_api_level
|
||||||
|
|
||||||
# select the NDK compiler
|
# select the NDK compiler
|
||||||
gcc_version = '4.9'
|
gcc_version = '4.9'
|
||||||
|
|
||||||
ndk_platform_path = os.path.join(ndk_path, 'platforms', ndk_platform)
|
ndk_platform_path = os.path.join(ndk_path, 'platforms', ndk_platform)
|
||||||
sysroot = os.path.join(ndk_path, 'sysroot')
|
sysroot = os.path.join(ndk_path, 'sysroot')
|
||||||
target_root = os.path.join(ndk_platform_path, 'arch-' + self.ndk_arch)
|
target_root = os.path.join(ndk_platform_path, 'arch-' + ndk_arch)
|
||||||
|
|
||||||
install_prefix = os.path.join(arch_path, 'root')
|
install_prefix = os.path.join(arch_path, 'root')
|
||||||
|
|
||||||
@@ -61,11 +90,13 @@ class AndroidNdkToolchain:
|
|||||||
self.install_prefix = install_prefix
|
self.install_prefix = install_prefix
|
||||||
self.sysroot = sysroot
|
self.sysroot = sysroot
|
||||||
|
|
||||||
toolchain_path = os.path.join(ndk_path, 'toolchains', arch + '-' + gcc_version, 'prebuilt', build_arch)
|
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_path = os.path.join(ndk_path, 'toolchains', 'llvm', 'prebuilt', build_arch)
|
||||||
llvm_triple = 'armv7-none-linux-androideabi'
|
llvm_triple = abi_info['llvm_triple']
|
||||||
|
|
||||||
common_flags = '-march=armv7-a -mfloat-abi=softfp'
|
common_flags = '-Os -g'
|
||||||
|
common_flags += ' -fPIC'
|
||||||
|
common_flags += ' ' + abi_info['cflags']
|
||||||
|
|
||||||
toolchain_bin = os.path.join(toolchain_path, 'bin')
|
toolchain_bin = os.path.join(toolchain_path, 'bin')
|
||||||
llvm_bin = os.path.join(llvm_path, 'bin')
|
llvm_bin = os.path.join(llvm_path, 'bin')
|
||||||
@@ -73,17 +104,19 @@ class AndroidNdkToolchain:
|
|||||||
self.cxx = os.path.join(llvm_bin, 'clang++')
|
self.cxx = os.path.join(llvm_bin, 'clang++')
|
||||||
common_flags += ' -target ' + llvm_triple + ' -integrated-as -gcc-toolchain ' + toolchain_path
|
common_flags += ' -target ' + llvm_triple + ' -integrated-as -gcc-toolchain ' + toolchain_path
|
||||||
|
|
||||||
|
common_flags += ' -fvisibility=hidden -fdata-sections -ffunction-sections'
|
||||||
|
|
||||||
self.ar = os.path.join(toolchain_bin, arch + '-ar')
|
self.ar = os.path.join(toolchain_bin, arch + '-ar')
|
||||||
self.ranlib = os.path.join(toolchain_bin, arch + '-ranlib')
|
self.ranlib = os.path.join(toolchain_bin, arch + '-ranlib')
|
||||||
self.nm = os.path.join(toolchain_bin, arch + '-nm')
|
self.nm = os.path.join(toolchain_bin, arch + '-nm')
|
||||||
self.strip = os.path.join(toolchain_bin, arch + '-strip')
|
self.strip = os.path.join(toolchain_bin, arch + '-strip')
|
||||||
|
|
||||||
self.cflags = '-Os -g ' + common_flags
|
self.cflags = common_flags
|
||||||
self.cxxflags = '-Os -g ' + common_flags
|
self.cxxflags = common_flags
|
||||||
self.cppflags = '--sysroot=' + sysroot + \
|
self.cppflags = '--sysroot=' + sysroot + \
|
||||||
' -isystem ' + os.path.join(install_prefix, 'include') + \
|
' -isystem ' + os.path.join(install_prefix, 'include') + \
|
||||||
' -isystem ' + os.path.join(sysroot, 'usr', 'include', arch) + \
|
' -isystem ' + os.path.join(sysroot, 'usr', 'include', arch) + \
|
||||||
' -D__ANDROID_API__=21'
|
' -D__ANDROID_API__=' + android_api_level
|
||||||
self.ldflags = '--sysroot=' + sysroot + \
|
self.ldflags = '--sysroot=' + sysroot + \
|
||||||
' -L' + os.path.join(install_prefix, 'lib') + \
|
' -L' + os.path.join(install_prefix, 'lib') + \
|
||||||
' -L' + os.path.join(target_root, 'usr', 'lib') + \
|
' -L' + os.path.join(target_root, 'usr', 'lib') + \
|
||||||
@@ -91,22 +124,23 @@ class AndroidNdkToolchain:
|
|||||||
' ' + common_flags
|
' ' + common_flags
|
||||||
self.libs = ''
|
self.libs = ''
|
||||||
|
|
||||||
self.is_arm = self.ndk_arch == 'arm'
|
self.is_arm = ndk_arch == 'arm'
|
||||||
self.is_armv7 = self.is_arm and 'armv7' in self.cflags
|
self.is_armv7 = self.is_arm and 'armv7' in self.cflags
|
||||||
|
self.is_aarch64 = ndk_arch == 'arm64'
|
||||||
self.is_windows = False
|
self.is_windows = False
|
||||||
|
|
||||||
libcxx_path = os.path.join(ndk_path, 'sources/cxx-stl/llvm-libc++')
|
libcxx_path = os.path.join(ndk_path, 'sources/cxx-stl/llvm-libc++')
|
||||||
libcxx_libs_path = os.path.join(libcxx_path, 'libs', android_abi)
|
libcxx_libs_path = os.path.join(libcxx_path, 'libs', android_abi)
|
||||||
|
|
||||||
libstdcxx_cppflags = '-nostdinc++ -isystem ' + os.path.join(libcxx_path, 'include') + ' -isystem ' + os.path.join(ndk_path, 'sources/android/support/include')
|
libstdcxx_flags = ''
|
||||||
libstdcxx_ldadd = os.path.join(libcxx_libs_path, 'libc++_static.a') + ' ' + os.path.join(libcxx_libs_path, 'libc++abi.a')
|
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
|
||||||
if self.is_armv7:
|
libstdcxx_libs = '-lc++_static -lc++abi'
|
||||||
libstdcxx_ldadd += ' ' + os.path.join(libcxx_libs_path, 'libunwind.a')
|
|
||||||
|
|
||||||
if use_cxx:
|
if use_cxx:
|
||||||
self.libs += ' ' + libstdcxx_ldadd
|
self.cxxflags += ' ' + libstdcxx_cxxflags
|
||||||
self.cppflags += ' ' + libstdcxx_cppflags
|
self.ldflags += ' ' + libstdcxx_ldflags
|
||||||
|
self.libs += ' ' + libstdcxx_libs
|
||||||
|
|
||||||
self.env = dict(os.environ)
|
self.env = dict(os.environ)
|
||||||
|
|
||||||
@@ -117,14 +151,16 @@ class AndroidNdkToolchain:
|
|||||||
# a list of third-party libraries to be used by MPD on Android
|
# a list of third-party libraries to be used by MPD on Android
|
||||||
from build.libs import *
|
from build.libs import *
|
||||||
thirdparty_libs = [
|
thirdparty_libs = [
|
||||||
|
libmpdclient,
|
||||||
libogg,
|
libogg,
|
||||||
libvorbis,
|
libvorbis,
|
||||||
opus,
|
opus,
|
||||||
flac,
|
flac,
|
||||||
libid3tag,
|
libid3tag,
|
||||||
libmad,
|
|
||||||
ffmpeg,
|
ffmpeg,
|
||||||
curl,
|
curl,
|
||||||
|
libexpat,
|
||||||
|
libnfs,
|
||||||
boost,
|
boost,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
22
android/res/layout/custom_notification_gb.xml
Normal file
22
android/res/layout/custom_notification_gb.xml
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/layout"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:padding="10dp" >
|
||||||
|
<ImageView android:id="@+id/image"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="fill_parent"
|
||||||
|
android:layout_alignParentLeft="true"
|
||||||
|
android:layout_marginRight="10dp" />
|
||||||
|
<TextView android:id="@+id/title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toRightOf="@id/image"
|
||||||
|
style="Custom Notification Title" />
|
||||||
|
<TextView android:id="@+id/text"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_toRightOf="@id/image"
|
||||||
|
android:layout_below="@id/title"
|
||||||
|
style="Custom Notification Text" />
|
||||||
|
</RelativeLayout>
|
5
android/res/layout/log_item.xml
Normal file
5
android/res/layout/log_item.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:typeface="monospace" />
|
37
android/res/layout/settings.xml
Normal file
37
android/res/layout/settings.xml
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="vertical" >
|
||||||
|
|
||||||
|
<ToggleButton
|
||||||
|
android:id="@+id/run"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textOn="@string/toggle_button_run_on"
|
||||||
|
android:textOff="@string/toggle_button_run_off" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/run_on_boot"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/checkbox_run_on_boot" />
|
||||||
|
|
||||||
|
<CheckBox
|
||||||
|
android:id="@+id/wakelock"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/checkbox_wakelock" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/status"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content" />
|
||||||
|
|
||||||
|
<ListView
|
||||||
|
android:id="@+id/log_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingTop="10dip" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
@@ -2,4 +2,10 @@
|
|||||||
|
|
||||||
<resources>
|
<resources>
|
||||||
<string name="app_name">MPD</string>
|
<string name="app_name">MPD</string>
|
||||||
|
<string name="notification_title_mpd_running">Music Player Daemon is running</string>
|
||||||
|
<string name="notification_text_mpd_running">Touch for MPD options.</string>
|
||||||
|
<string name="toggle_button_run_on">MPD is running</string>
|
||||||
|
<string name="toggle_button_run_off">MPD is not running</string>
|
||||||
|
<string name="checkbox_run_on_boot">Run MPD automatically on boot</string>
|
||||||
|
<string name="checkbox_wakelock">Prevent suspend when MPD is running (Wakelock)</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
@@ -25,6 +25,12 @@ import android.content.Context;
|
|||||||
* Bridge to native code.
|
* Bridge to native code.
|
||||||
*/
|
*/
|
||||||
public class Bridge {
|
public class Bridge {
|
||||||
public static native void run(Context context);
|
|
||||||
|
/* used by jni */
|
||||||
|
public interface LogListener {
|
||||||
|
public void onLog(int priority, String msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static native void run(Context context, LogListener logListener);
|
||||||
public static native void shutdown();
|
public static native void shutdown();
|
||||||
}
|
}
|
||||||
|
12
android/src/IMain.aidl
Normal file
12
android/src/IMain.aidl
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package org.musicpd;
|
||||||
|
import org.musicpd.IMainCallback;
|
||||||
|
|
||||||
|
interface IMain
|
||||||
|
{
|
||||||
|
void start();
|
||||||
|
void stop();
|
||||||
|
void setWakelockEnabled(boolean enabled);
|
||||||
|
boolean isRunning();
|
||||||
|
void registerCallback(IMainCallback cb);
|
||||||
|
void unregisterCallback(IMainCallback cb);
|
||||||
|
}
|
9
android/src/IMainCallback.aidl
Normal file
9
android/src/IMainCallback.aidl
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
package org.musicpd;
|
||||||
|
|
||||||
|
interface IMainCallback
|
||||||
|
{
|
||||||
|
void onStarted();
|
||||||
|
void onStopped();
|
||||||
|
void onError(String error);
|
||||||
|
void onLog(int priority, String msg);
|
||||||
|
}
|
@@ -19,57 +19,360 @@
|
|||||||
|
|
||||||
package org.musicpd;
|
package org.musicpd;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.annotation.TargetApi;
|
||||||
import android.os.Bundle;
|
import android.app.Notification;
|
||||||
|
import android.app.PendingIntent;
|
||||||
|
import android.app.Service;
|
||||||
|
import android.content.ComponentName;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.content.ServiceConnection;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Handler;
|
import android.os.IBinder;
|
||||||
import android.os.Message;
|
import android.os.PowerManager;
|
||||||
import android.widget.TextView;
|
import android.os.RemoteCallbackList;
|
||||||
|
import android.os.RemoteException;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.widget.RemoteViews;
|
||||||
|
|
||||||
public class Main extends Activity implements Runnable {
|
public class Main extends Service implements Runnable {
|
||||||
private static final String TAG = "MPD";
|
private static final String TAG = "Main";
|
||||||
|
private static final String REMOTE_ERROR = "MPD process was killed";
|
||||||
|
private static final int MAIN_STATUS_ERROR = -1;
|
||||||
|
private static final int MAIN_STATUS_STOPPED = 0;
|
||||||
|
private static final int MAIN_STATUS_STARTED = 1;
|
||||||
|
|
||||||
Thread thread;
|
private static final int MSG_SEND_STATUS = 0;
|
||||||
|
private static final int MSG_SEND_LOG = 1;
|
||||||
|
|
||||||
TextView textView;
|
private Thread mThread = null;
|
||||||
|
private int mStatus = MAIN_STATUS_STOPPED;
|
||||||
|
private boolean mAbort = false;
|
||||||
|
private String mError = null;
|
||||||
|
private final RemoteCallbackList<IMainCallback> mCallbacks = new RemoteCallbackList<IMainCallback>();
|
||||||
|
private final IBinder mBinder = new MainStub(this);
|
||||||
|
private PowerManager.WakeLock mWakelock = null;
|
||||||
|
|
||||||
final Handler quitHandler = new Handler() {
|
static class MainStub extends IMain.Stub {
|
||||||
public void handleMessage(Message msg) {
|
private Main mService;
|
||||||
textView.setText("Music Player Daemon has quit");
|
MainStub(Main service) {
|
||||||
|
mService = service;
|
||||||
|
}
|
||||||
|
public void start() {
|
||||||
|
mService.start();
|
||||||
|
}
|
||||||
|
public void stop() {
|
||||||
|
mService.stop();
|
||||||
|
}
|
||||||
|
public void setWakelockEnabled(boolean enabled) {
|
||||||
|
mService.setWakelockEnabled(enabled);
|
||||||
|
}
|
||||||
|
public boolean isRunning() {
|
||||||
|
return mService.isRunning();
|
||||||
|
}
|
||||||
|
public void registerCallback(IMainCallback cb) {
|
||||||
|
mService.registerCallback(cb);
|
||||||
|
}
|
||||||
|
public void unregisterCallback(IMainCallback cb) {
|
||||||
|
mService.unregisterCallback(cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: what now? restart?
|
private synchronized void sendMessage(int what, int arg1, int arg2, Object obj) {
|
||||||
|
int i = mCallbacks.beginBroadcast();
|
||||||
|
while (i > 0) {
|
||||||
|
i--;
|
||||||
|
final IMainCallback cb = mCallbacks.getBroadcastItem(i);
|
||||||
|
try {
|
||||||
|
switch (what) {
|
||||||
|
case MSG_SEND_STATUS:
|
||||||
|
switch (arg1) {
|
||||||
|
case MAIN_STATUS_ERROR:
|
||||||
|
cb.onError((String)obj);
|
||||||
|
break;
|
||||||
|
case MAIN_STATUS_STOPPED:
|
||||||
|
cb.onStopped();
|
||||||
|
break;
|
||||||
|
case MAIN_STATUS_STARTED:
|
||||||
|
cb.onStarted();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case MSG_SEND_LOG:
|
||||||
|
cb.onLog(arg1, (String) obj);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mCallbacks.finishBroadcast();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Bridge.LogListener mLogListener = new Bridge.LogListener() {
|
||||||
|
@Override
|
||||||
|
public void onLog(int priority, String msg) {
|
||||||
|
sendMessage(MSG_SEND_LOG, priority, 0, msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public IBinder onBind(Intent intent) {
|
||||||
|
return mBinder;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
|
start();
|
||||||
|
if (intent != null && intent.getBooleanExtra("wakelock", false))
|
||||||
|
setWakelockEnabled(true);
|
||||||
|
return START_STICKY;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!Loader.loaded) {
|
||||||
|
final String error = "Failed to load the native MPD libary.\n" +
|
||||||
|
"Report this problem to us, and include the following information:\n" +
|
||||||
|
"SUPPORTED_ABIS=" + String.join(", ", Build.SUPPORTED_ABIS) + "\n" +
|
||||||
|
"PRODUCT=" + Build.PRODUCT + "\n" +
|
||||||
|
"FINGERPRINT=" + Build.FINGERPRINT + "\n" +
|
||||||
|
"error=" + Loader.error;
|
||||||
|
setStatus(MAIN_STATUS_ERROR, error);
|
||||||
|
stopSelf();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
synchronized (this) {
|
||||||
|
if (mAbort)
|
||||||
|
return;
|
||||||
|
setStatus(MAIN_STATUS_STARTED, null);
|
||||||
|
}
|
||||||
|
Bridge.run(this, mLogListener);
|
||||||
|
setStatus(MAIN_STATUS_STOPPED, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
private synchronized void setStatus(int status, String error) {
|
||||||
|
mStatus = status;
|
||||||
|
mError = error;
|
||||||
|
sendMessage(MSG_SEND_STATUS, mStatus, 0, mError);
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
mainIntent.addCategory("android.intent.category.LAUNCHER");
|
||||||
|
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))
|
||||||
|
.setContentText(getText(R.string.notification_text_mpd_running))
|
||||||
|
.setSmallIcon(R.drawable.notification_icon)
|
||||||
|
.setContentIntent(contentIntent)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
startForeground(R.string.notification_title_mpd_running, notification);
|
||||||
|
startService(new Intent(this, Main.class));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stop() {
|
||||||
|
if (mThread != null) {
|
||||||
|
if (mThread.isAlive()) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (mStatus == MAIN_STATUS_STARTED)
|
||||||
|
Bridge.shutdown();
|
||||||
|
else
|
||||||
|
mAbort = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
mThread.join();
|
||||||
|
mThread = null;
|
||||||
|
mAbort = false;
|
||||||
|
} catch (InterruptedException ie) {}
|
||||||
|
}
|
||||||
|
setWakelockEnabled(false);
|
||||||
|
stopForeground(true);
|
||||||
|
stopSelf();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setWakelockEnabled(boolean enabled) {
|
||||||
|
if (enabled && mWakelock == null) {
|
||||||
|
PowerManager pm = (PowerManager)getSystemService(Context.POWER_SERVICE);
|
||||||
|
mWakelock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
|
||||||
|
mWakelock.acquire();
|
||||||
|
Log.d(TAG, "Wakelock acquired");
|
||||||
|
} else if (!enabled && mWakelock != null) {
|
||||||
|
mWakelock.release();
|
||||||
|
mWakelock = null;
|
||||||
|
Log.d(TAG, "Wakelock released");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isRunning() {
|
||||||
|
return mThread != null && mThread.isAlive();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void registerCallback(IMainCallback cb) {
|
||||||
|
if (cb != null) {
|
||||||
|
mCallbacks.register(cb);
|
||||||
|
sendMessage(MSG_SEND_STATUS, mStatus, 0, mError);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void unregisterCallback(IMainCallback cb) {
|
||||||
|
if (cb != null) {
|
||||||
|
mCallbacks.unregister(cb);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Client that bind the Main Service in order to send commands and receive callback
|
||||||
|
*/
|
||||||
|
public static class Client {
|
||||||
|
|
||||||
|
public interface Callback {
|
||||||
|
public void onStarted();
|
||||||
|
public void onStopped();
|
||||||
|
public void onError(String error);
|
||||||
|
public void onLog(int priority, String msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean mBound = false;
|
||||||
|
private final Context mContext;
|
||||||
|
private Callback mCallback;
|
||||||
|
private IMain mIMain = null;
|
||||||
|
|
||||||
|
private final IMainCallback.Stub mICallback = new IMainCallback.Stub() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopped() throws RemoteException {
|
||||||
|
mCallback.onStopped();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStarted() throws RemoteException {
|
||||||
|
mCallback.onStarted();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) throws RemoteException {
|
||||||
|
mCallback.onError(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLog(int priority, String msg) throws RemoteException {
|
||||||
|
mCallback.onLog(priority, msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@Override protected void onCreate(Bundle savedInstanceState) {
|
private final ServiceConnection mServiceConnection = new ServiceConnection() {
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
|
|
||||||
if (!Loader.loaded) {
|
@Override
|
||||||
TextView tv = new TextView(this);
|
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||||
tv.setText("Failed to load the native MPD libary.\n" +
|
synchronized (this) {
|
||||||
"Report this problem to us, and include the following information:\n" +
|
mIMain = IMain.Stub.asInterface(service);
|
||||||
"ABI=" + Build.CPU_ABI + "\n" +
|
try {
|
||||||
"PRODUCT=" + Build.PRODUCT + "\n" +
|
if (mCallback != null)
|
||||||
"FINGERPRINT=" + Build.FINGERPRINT + "\n" +
|
mIMain.registerCallback(mICallback);
|
||||||
"error=" + Loader.error);
|
} catch (RemoteException e) {
|
||||||
setContentView(tv);
|
if (mCallback != null)
|
||||||
return;
|
mCallback.onError(REMOTE_ERROR);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onServiceDisconnected(ComponentName name) {
|
||||||
|
if (mCallback != null)
|
||||||
|
mCallback.onError(REMOTE_ERROR);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public Client(Context context, Callback cb) throws IllegalArgumentException {
|
||||||
|
if (context == null)
|
||||||
|
throw new IllegalArgumentException("Context can't be null");
|
||||||
|
mContext = context;
|
||||||
|
mCallback = cb;
|
||||||
|
mBound = mContext.bindService(new Intent(mContext, Main.class), mServiceConnection, Context.BIND_AUTO_CREATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (thread == null || !thread.isAlive()) {
|
public boolean start() {
|
||||||
thread = new Thread(this, "NativeMain");
|
synchronized (this) {
|
||||||
thread.start();
|
if (mIMain != null) {
|
||||||
|
try {
|
||||||
|
mIMain.start();
|
||||||
|
return true;
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
textView = new TextView(this);
|
public boolean stop() {
|
||||||
textView.setText("Music Player Daemon is running"
|
synchronized (this) {
|
||||||
+ "\nCAUTION: this version is EXPERIMENTAL!");
|
if (mIMain != null) {
|
||||||
setContentView(textView);
|
try {
|
||||||
|
mIMain.stop();
|
||||||
|
return true;
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setWakelockEnabled(boolean enabled) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (mIMain != null) {
|
||||||
|
try {
|
||||||
|
mIMain.setWakelockEnabled(enabled);
|
||||||
|
return true;
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRunning() {
|
||||||
|
synchronized (this) {
|
||||||
|
if (mIMain != null) {
|
||||||
|
try {
|
||||||
|
return mIMain.isRunning();
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void release() {
|
||||||
|
if (mBound) {
|
||||||
|
synchronized (this) {
|
||||||
|
if (mIMain != null && mICallback != null) {
|
||||||
|
try {
|
||||||
|
if (mCallback != null)
|
||||||
|
mIMain.unregisterCallback(mICallback);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mBound = false;
|
||||||
|
mContext.unbindService(mServiceConnection);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void run() {
|
/*
|
||||||
Bridge.run(this);
|
* start Main service without any callback
|
||||||
quitHandler.sendMessage(quitHandler.obtainMessage());
|
*/
|
||||||
|
public static void start(Context context, boolean wakelock) {
|
||||||
|
context.startService(new Intent(context, Main.class).putExtra("wakelock", wakelock));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
41
android/src/Receiver.java
Normal file
41
android/src/Receiver.java
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2003-2014 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.musicpd;
|
||||||
|
|
||||||
|
import android.content.BroadcastReceiver;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
|
public class Receiver extends BroadcastReceiver {
|
||||||
|
@Override
|
||||||
|
public void onReceive(Context context, Intent intent) {
|
||||||
|
Log.d("Receiver", "onReceive: " + intent);
|
||||||
|
if (intent.getAction() == "android.intent.action.BOOT_COMPLETED") {
|
||||||
|
if (Settings.Preferences.getBoolean(context,
|
||||||
|
Settings.Preferences.KEY_RUN_ON_BOOT, false)) {
|
||||||
|
final boolean wakelock = Settings.Preferences.getBoolean(context,
|
||||||
|
Settings.Preferences.KEY_WAKELOCK, false);
|
||||||
|
Main.start(context, wakelock);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
254
android/src/Settings.java
Normal file
254
android/src/Settings.java
Normal file
@@ -0,0 +1,254 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.musicpd;
|
||||||
|
|
||||||
|
import java.util.LinkedList;
|
||||||
|
|
||||||
|
import android.app.Activity;
|
||||||
|
import android.content.Context;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.SharedPreferences.Editor;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Message;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.CheckBox;
|
||||||
|
import android.widget.CompoundButton;
|
||||||
|
import android.widget.CompoundButton.OnCheckedChangeListener;
|
||||||
|
import android.widget.ListView;
|
||||||
|
import android.widget.TextView;
|
||||||
|
import android.widget.ToggleButton;
|
||||||
|
|
||||||
|
public class Settings extends Activity {
|
||||||
|
private static final String TAG = "Settings";
|
||||||
|
private Main.Client mClient;
|
||||||
|
private TextView mTextStatus;
|
||||||
|
private ToggleButton mRunButton;
|
||||||
|
private boolean mFirstRun;
|
||||||
|
private LinkedList<String> mLogListArray = new LinkedList<String>();
|
||||||
|
private ListView mLogListView;
|
||||||
|
private ArrayAdapter<String> mLogListAdapter;
|
||||||
|
|
||||||
|
private static final int MAX_LOGS = 500;
|
||||||
|
|
||||||
|
private static final int MSG_ERROR = 0;
|
||||||
|
private static final int MSG_STOPPED = 1;
|
||||||
|
private static final int MSG_STARTED = 2;
|
||||||
|
private static final int MSG_LOG = 3;
|
||||||
|
|
||||||
|
public static class Preferences {
|
||||||
|
public static final String KEY_RUN_ON_BOOT ="run_on_boot";
|
||||||
|
public static final String KEY_WAKELOCK ="wakelock";
|
||||||
|
|
||||||
|
public static SharedPreferences get(Context context) {
|
||||||
|
return context.getSharedPreferences(TAG, MODE_PRIVATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void putBoolean(Context context, String key, boolean value) {
|
||||||
|
final SharedPreferences prefs = get(context);
|
||||||
|
|
||||||
|
if (prefs == null)
|
||||||
|
return;
|
||||||
|
final Editor editor = prefs.edit();
|
||||||
|
editor.putBoolean(key, value);
|
||||||
|
editor.apply();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean getBoolean(Context context, String key, boolean defValue) {
|
||||||
|
final SharedPreferences prefs = get(context);
|
||||||
|
|
||||||
|
return prefs != null ? prefs.getBoolean(key, defValue) : defValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Handler mHandler = new Handler(new Handler.Callback() {
|
||||||
|
@Override
|
||||||
|
public boolean handleMessage(Message msg) {
|
||||||
|
switch (msg.what) {
|
||||||
|
case MSG_ERROR:
|
||||||
|
Log.d(TAG, "onError");
|
||||||
|
|
||||||
|
mClient.release();
|
||||||
|
connectClient();
|
||||||
|
|
||||||
|
mRunButton.setEnabled(false);
|
||||||
|
mRunButton.setChecked(false);
|
||||||
|
|
||||||
|
mTextStatus.setText((String)msg.obj);
|
||||||
|
mFirstRun = true;
|
||||||
|
break;
|
||||||
|
case MSG_STOPPED:
|
||||||
|
Log.d(TAG, "onStopped");
|
||||||
|
mRunButton.setEnabled(true);
|
||||||
|
if (!mFirstRun && Preferences.getBoolean(Settings.this, Preferences.KEY_RUN_ON_BOOT, false))
|
||||||
|
mRunButton.setChecked(true);
|
||||||
|
else
|
||||||
|
mRunButton.setChecked(false);
|
||||||
|
mFirstRun = true;
|
||||||
|
break;
|
||||||
|
case MSG_STARTED:
|
||||||
|
Log.d(TAG, "onStarted");
|
||||||
|
mRunButton.setChecked(true);
|
||||||
|
mFirstRun = true;
|
||||||
|
mTextStatus.setText("CAUTION: this version is EXPERIMENTAL!"); // XXX
|
||||||
|
break;
|
||||||
|
case MSG_LOG:
|
||||||
|
if (mLogListArray.size() > MAX_LOGS)
|
||||||
|
mLogListArray.remove(0);
|
||||||
|
String priority;
|
||||||
|
switch (msg.arg1) {
|
||||||
|
case Log.DEBUG:
|
||||||
|
priority = "D";
|
||||||
|
break;
|
||||||
|
case Log.ERROR:
|
||||||
|
priority = "E";
|
||||||
|
break;
|
||||||
|
case Log.INFO:
|
||||||
|
priority = "I";
|
||||||
|
break;
|
||||||
|
case Log.VERBOSE:
|
||||||
|
priority = "V";
|
||||||
|
break;
|
||||||
|
case Log.WARN:
|
||||||
|
priority = "W";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
priority = "";
|
||||||
|
}
|
||||||
|
mLogListArray.add(priority + "/ " + (String)msg.obj);
|
||||||
|
mLogListAdapter.notifyDataSetChanged();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
private final OnCheckedChangeListener mOnRunChangeListener = new OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
if (mClient != null) {
|
||||||
|
if (isChecked) {
|
||||||
|
mClient.start();
|
||||||
|
if (Preferences.getBoolean(Settings.this,
|
||||||
|
Preferences.KEY_WAKELOCK, false))
|
||||||
|
mClient.setWakelockEnabled(true);
|
||||||
|
} else {
|
||||||
|
mClient.stop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final OnCheckedChangeListener mOnRunOnBootChangeListener = new OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
Preferences.putBoolean(Settings.this, Preferences.KEY_RUN_ON_BOOT, isChecked);
|
||||||
|
if (isChecked && mClient != null && !mRunButton.isChecked())
|
||||||
|
mRunButton.setChecked(true);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
private final OnCheckedChangeListener mOnWakelockChangeListener = new OnCheckedChangeListener() {
|
||||||
|
@Override
|
||||||
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||||
|
Preferences.putBoolean(Settings.this, Preferences.KEY_WAKELOCK, isChecked);
|
||||||
|
if (mClient != null && mClient.isRunning())
|
||||||
|
mClient.setWakelockEnabled(isChecked);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
|
setContentView(R.layout.settings);
|
||||||
|
mRunButton = (ToggleButton) findViewById(R.id.run);
|
||||||
|
mRunButton.setOnCheckedChangeListener(mOnRunChangeListener);
|
||||||
|
|
||||||
|
mTextStatus = (TextView) findViewById(R.id.status);
|
||||||
|
|
||||||
|
mLogListAdapter = new ArrayAdapter<String>(this, R.layout.log_item, mLogListArray);
|
||||||
|
|
||||||
|
mLogListView = (ListView) findViewById(R.id.log_list);
|
||||||
|
mLogListView.setAdapter(mLogListAdapter);
|
||||||
|
mLogListView.setTranscriptMode(ListView.TRANSCRIPT_MODE_NORMAL);
|
||||||
|
|
||||||
|
CheckBox checkbox = (CheckBox) findViewById(R.id.run_on_boot);
|
||||||
|
checkbox.setOnCheckedChangeListener(mOnRunOnBootChangeListener);
|
||||||
|
if (Preferences.getBoolean(this, Preferences.KEY_RUN_ON_BOOT, false))
|
||||||
|
checkbox.setChecked(true);
|
||||||
|
|
||||||
|
checkbox = (CheckBox) findViewById(R.id.wakelock);
|
||||||
|
checkbox.setOnCheckedChangeListener(mOnWakelockChangeListener);
|
||||||
|
if (Preferences.getBoolean(this, Preferences.KEY_WAKELOCK, false))
|
||||||
|
checkbox.setChecked(true);
|
||||||
|
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void connectClient() {
|
||||||
|
mClient = new Main.Client(this, new Main.Client.Callback() {
|
||||||
|
|
||||||
|
private void removeMessages() {
|
||||||
|
/* don't remove log messages */
|
||||||
|
mHandler.removeMessages(MSG_STOPPED);
|
||||||
|
mHandler.removeMessages(MSG_STARTED);
|
||||||
|
mHandler.removeMessages(MSG_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStopped() {
|
||||||
|
removeMessages();
|
||||||
|
mHandler.sendEmptyMessage(MSG_STOPPED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStarted() {
|
||||||
|
removeMessages();
|
||||||
|
mHandler.sendEmptyMessage(MSG_STARTED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(String error) {
|
||||||
|
removeMessages();
|
||||||
|
mHandler.sendMessage(Message.obtain(mHandler, MSG_ERROR, error));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLog(int priority, String msg) {
|
||||||
|
mHandler.sendMessage(Message.obtain(mHandler, MSG_LOG, priority, 0, msg));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart() {
|
||||||
|
mFirstRun = false;
|
||||||
|
connectClient();
|
||||||
|
super.onStart();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop() {
|
||||||
|
mClient.release();
|
||||||
|
mClient = null;
|
||||||
|
super.onStop();
|
||||||
|
}
|
||||||
|
}
|
30
configure.ac
30
configure.ac
@@ -1,10 +1,10 @@
|
|||||||
AC_PREREQ(2.60)
|
AC_PREREQ(2.60)
|
||||||
|
|
||||||
AC_INIT(mpd, 0.20.13, musicpd-dev-team@lists.sourceforge.net)
|
AC_INIT(mpd, 0.20.22, musicpd-dev-team@lists.sourceforge.net)
|
||||||
|
|
||||||
VERSION_MAJOR=0
|
VERSION_MAJOR=0
|
||||||
VERSION_MINOR=20
|
VERSION_MINOR=20
|
||||||
VERSION_REVISION=13
|
VERSION_REVISION=22
|
||||||
VERSION_EXTRA=0
|
VERSION_EXTRA=0
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR([src/Main.cxx])
|
AC_CONFIG_SRCDIR([src/Main.cxx])
|
||||||
@@ -14,9 +14,9 @@ AM_SILENT_RULES
|
|||||||
AC_CONFIG_HEADERS(config.h)
|
AC_CONFIG_HEADERS(config.h)
|
||||||
AC_CONFIG_MACRO_DIR([m4])
|
AC_CONFIG_MACRO_DIR([m4])
|
||||||
|
|
||||||
AC_DEFINE(PROTOCOL_VERSION, "0.20.0", [The MPD protocol version])
|
AC_DEFINE(PROTOCOL_VERSION, "0.20.22", [The MPD protocol version])
|
||||||
|
|
||||||
GIT_COMMIT=`GIT_DIR="$srcdir/.git" git describe --dirty --always 2>/dev/null`
|
GIT_COMMIT=`cd "$srcdir" && git describe --dirty --always 2>/dev/null`
|
||||||
if test x$GIT_COMMIT != x; then
|
if test x$GIT_COMMIT != x; then
|
||||||
AC_DEFINE_UNQUOTED(GIT_COMMIT, ["$GIT_COMMIT"], [The current git commit])
|
AC_DEFINE_UNQUOTED(GIT_COMMIT, ["$GIT_COMMIT"], [The current git commit])
|
||||||
fi
|
fi
|
||||||
@@ -186,6 +186,7 @@ AC_ARG_WITH([android-sdk],
|
|||||||
[Directory for Android SDK]),
|
[Directory for Android SDK]),
|
||||||
[], [with_android_sdk=no])
|
[], [with_android_sdk=no])
|
||||||
|
|
||||||
|
android_abi=""
|
||||||
if test x$host_is_android = xyes; then
|
if test x$host_is_android = xyes; then
|
||||||
if test x$with_android_sdk = xno; then
|
if test x$with_android_sdk = xno; then
|
||||||
AC_MSG_ERROR([Android build requires option --with-android-sdk=DIR])
|
AC_MSG_ERROR([Android build requires option --with-android-sdk=DIR])
|
||||||
@@ -194,9 +195,15 @@ if test x$host_is_android = xyes; then
|
|||||||
if ! test -x $with_android_sdk/tools/android; then
|
if ! test -x $with_android_sdk/tools/android; then
|
||||||
AC_MSG_ERROR([Android SDK not found in $with_android_sdk])
|
AC_MSG_ERROR([Android SDK not found in $with_android_sdk])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
AS_CASE([$host_cpu],
|
||||||
|
[i686], [android_abi="x86"],
|
||||||
|
[aarch64], [android_abi="arm64-v8a"],
|
||||||
|
[android_abi="armeabi-v7a"])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_SUBST(ANDROID_SDK, [$with_android_sdk])
|
AC_SUBST(ANDROID_SDK, [$with_android_sdk])
|
||||||
|
AC_SUBST(ANDROID_ABI, [$android_abi])
|
||||||
|
|
||||||
dnl ---------------------------------------------------------------------------
|
dnl ---------------------------------------------------------------------------
|
||||||
dnl Language Checks
|
dnl Language Checks
|
||||||
@@ -315,7 +322,7 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
default_enable_daemon=yes
|
default_enable_daemon=yes
|
||||||
if test x$host_is_android = xyes || test x$host_is_android = xyes; then
|
if test x$host_is_android = xyes || test x$host_is_windows = xyes; then
|
||||||
default_enable_daemon=no
|
default_enable_daemon=no
|
||||||
fi
|
fi
|
||||||
AC_ARG_ENABLE(daemon,
|
AC_ARG_ENABLE(daemon,
|
||||||
@@ -402,7 +409,7 @@ AC_ARG_ENABLE(recorder-output,
|
|||||||
|
|
||||||
AC_ARG_ENABLE(sidplay,
|
AC_ARG_ENABLE(sidplay,
|
||||||
AS_HELP_STRING([--enable-sidplay],
|
AS_HELP_STRING([--enable-sidplay],
|
||||||
[enable C64 SID support via libsidplay2]),,
|
[enable C64 SID support via libsidplayfp or libsidplay2]),,
|
||||||
enable_sidplay=auto)
|
enable_sidplay=auto)
|
||||||
|
|
||||||
AC_ARG_ENABLE(shout,
|
AC_ARG_ENABLE(shout,
|
||||||
@@ -454,7 +461,7 @@ dnl ---------------------------------------------------------------------------
|
|||||||
dnl Mandatory Libraries
|
dnl Mandatory Libraries
|
||||||
dnl ---------------------------------------------------------------------------
|
dnl ---------------------------------------------------------------------------
|
||||||
|
|
||||||
AX_BOOST_BASE([1.46],, [AC_MSG_ERROR([Boost not found])])
|
AX_BOOST_BASE([1.54],, [AC_MSG_ERROR([Boost not found])])
|
||||||
|
|
||||||
AC_ARG_ENABLE(icu,
|
AC_ARG_ENABLE(icu,
|
||||||
AS_HELP_STRING([--enable-icu],
|
AS_HELP_STRING([--enable-icu],
|
||||||
@@ -700,7 +707,7 @@ MPD_ENABLE_AUTO_PKG_LIB(smbclient, SMBCLIENT, [smbclient >= 0.2],
|
|||||||
[smbclient input plugin], [libsmbclient not found])
|
[smbclient input plugin], [libsmbclient not found])
|
||||||
|
|
||||||
dnl ----------------------------------- NFS -----------------------------
|
dnl ----------------------------------- NFS -----------------------------
|
||||||
MPD_ENABLE_AUTO_PKG(nfs, NFS, [libnfs],
|
MPD_ENABLE_AUTO_PKG(nfs, NFS, [libnfs >= 1.9.5],
|
||||||
[NFS input plugin], [libnfs not found])
|
[NFS input plugin], [libnfs not found])
|
||||||
|
|
||||||
dnl --------------------------------- Soundcloud ------------------------------
|
dnl --------------------------------- Soundcloud ------------------------------
|
||||||
@@ -1005,7 +1012,7 @@ if test x$enable_sidplay != xno && test x$found_sidplayfp = xno; then
|
|||||||
[found_sidplay=no])
|
[found_sidplay=no])
|
||||||
|
|
||||||
MPD_AUTO_PRE(sidplay, [sidplay decoder plugin],
|
MPD_AUTO_PRE(sidplay, [sidplay decoder plugin],
|
||||||
[libsidplay2 not found])
|
[libsidplay2 or libsidutils not found])
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$enable_sidplay != xno && test x$found_sidplayfp = xno; then
|
if test x$enable_sidplay != xno && test x$found_sidplayfp = xno; then
|
||||||
@@ -1017,10 +1024,11 @@ if test x$enable_sidplay != xno && test x$found_sidplayfp = xno; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$enable_sidplay = xyes; then
|
if test x$enable_sidplay = xyes; then
|
||||||
SIDPLAY_LIBS="$SIDPLAY_LIBS -lresid-builder"
|
AC_DEFINE(ENABLE_SIDPLAY, 1, [Define for libsidplayfp or libsidplay2 support])
|
||||||
AC_DEFINE(ENABLE_SIDPLAY, 1, [Define for libsidplay2 support])
|
|
||||||
if test x$found_sidplayfp = xyes; then
|
if test x$found_sidplayfp = xyes; then
|
||||||
AC_DEFINE(HAVE_SIDPLAYFP, 1, [Define if libsidplayfp is used instead of libsidplay2])
|
AC_DEFINE(HAVE_SIDPLAYFP, 1, [Define if libsidplayfp is used instead of libsidplay2])
|
||||||
|
else
|
||||||
|
SIDPLAY_LIBS="$SIDPLAY_LIBS -lresid-builder"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@@ -113,7 +113,7 @@
|
|||||||
<para>
|
<para>
|
||||||
<varname>musicbrainz_artistid</varname>: the artist id in the
|
<varname>musicbrainz_artistid</varname>: the artist id in the
|
||||||
<ulink
|
<ulink
|
||||||
url="http://musicbrainz.org/doc/MusicBrainzTag">MusicBrainz</ulink>
|
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
|
||||||
database.
|
database.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@@ -122,7 +122,7 @@
|
|||||||
<para>
|
<para>
|
||||||
<varname>musicbrainz_albumid</varname>: the album id in the
|
<varname>musicbrainz_albumid</varname>: the album id in the
|
||||||
<ulink
|
<ulink
|
||||||
url="http://musicbrainz.org/doc/MusicBrainzTag">MusicBrainz</ulink>
|
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
|
||||||
database.
|
database.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
<para>
|
<para>
|
||||||
<varname>musicbrainz_albumartistid</varname>: the album artist
|
<varname>musicbrainz_albumartistid</varname>: the album artist
|
||||||
id in the <ulink
|
id in the <ulink
|
||||||
url="http://musicbrainz.org/doc/MusicBrainzTag">MusicBrainz</ulink>
|
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
|
||||||
database.
|
database.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@@ -140,7 +140,7 @@
|
|||||||
<para>
|
<para>
|
||||||
<varname>musicbrainz_trackid</varname>: the track id in the
|
<varname>musicbrainz_trackid</varname>: the track id in the
|
||||||
<ulink
|
<ulink
|
||||||
url="http://musicbrainz.org/doc/MusicBrainzTag">MusicBrainz</ulink>
|
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
|
||||||
database.
|
database.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
@@ -149,7 +149,7 @@
|
|||||||
<para>
|
<para>
|
||||||
<varname>musicbrainz_releasetrackid</varname>: the release track
|
<varname>musicbrainz_releasetrackid</varname>: the release track
|
||||||
id in the <ulink
|
id in the <ulink
|
||||||
url="http://musicbrainz.org/doc/MusicBrainzTag">MusicBrainz</ulink>
|
url="https://picard.musicbrainz.org/docs/mappings/">MusicBrainz</ulink>
|
||||||
database.
|
database.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
@@ -1599,6 +1599,11 @@ OK
|
|||||||
per-artist counts:
|
per-artist counts:
|
||||||
</para>
|
</para>
|
||||||
<programlisting>count group artist</programlisting>
|
<programlisting>count group artist</programlisting>
|
||||||
|
<para>
|
||||||
|
A group with an empty value contains counts of matching
|
||||||
|
song which don't this group tag. It exists only if at
|
||||||
|
least one such song is found.
|
||||||
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
95
doc/user.xml
95
doc/user.xml
@@ -66,6 +66,26 @@
|
|||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section id="install_android">
|
||||||
|
<title>Installing on Android</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
An experimental Android build is available on <ulink
|
||||||
|
url="https://play.google.com/store/apps/details?id=org.musicpd">Google
|
||||||
|
Play</ulink>. After installing and launching it, MPD will
|
||||||
|
scan the music in your <filename>Music</filename> directory
|
||||||
|
and you can control it as usual with a MPD client.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
If you need to tweak the configuration, you can create a file
|
||||||
|
called <filename>mpd.conf</filename> on the data partition
|
||||||
|
(the directory which is returned by Android's <ulink
|
||||||
|
url="https://developer.android.com/reference/android/os/Environment.html#getExternalStorageDirectory()">getExternalStorageDirectory()</ulink>
|
||||||
|
API function).
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
|
|
||||||
<section id="install_source">
|
<section id="install_source">
|
||||||
<title>Compiling from source</title>
|
<title>Compiling from source</title>
|
||||||
|
|
||||||
@@ -94,7 +114,7 @@ cd mpd-version</programlisting>
|
|||||||
|
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
<ulink url="http://www.boost.org/">Boost 1.46</ulink>
|
<ulink url="http://www.boost.org/">Boost 1.54</ulink>
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
|
||||||
@@ -248,6 +268,59 @@ apt-get install g++ \
|
|||||||
script.
|
script.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section id="android_build">
|
||||||
|
<title>Compiling for Android</title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
MPD can be compiled as an Android app. It can be installed
|
||||||
|
easily with <link linkend="install_android">Google
|
||||||
|
Play</link>, but if you want to build it from source, follow
|
||||||
|
this section.
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
You need:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
Android SDK
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<para>
|
||||||
|
<ulink
|
||||||
|
url="https://developer.android.com/ndk/downloads/index.html">Android
|
||||||
|
NDK</ulink>
|
||||||
|
</para>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Just like with the native build, unpack the
|
||||||
|
<application>MPD</application> source tarball and change
|
||||||
|
into the directory. Then, instead of
|
||||||
|
<command>./configure</command>, type:
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<programlisting>./android/build.py SDK_PATH NDK_PATH ABI
|
||||||
|
make android/build/mpd-debug.apk</programlisting>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
<varname>SDK_PATH</varname> is the absolute path where you
|
||||||
|
installed the Android SDK; <varname>NDK_PATH</varname> is
|
||||||
|
the Android NDK installation path; <varname>ABI</varname> is
|
||||||
|
the Android ABI to be built, e.g. "armeabi-v7a".
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
This downloads various library sources, and then configures
|
||||||
|
and builds <application>MPD</application>.
|
||||||
|
</para>
|
||||||
|
</section>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="systemd_socket">
|
<section id="systemd_socket">
|
||||||
@@ -323,7 +396,9 @@ systemctl start mpd.socket</programlisting>
|
|||||||
<application>MPD</application> as a user daemon (and not as a
|
<application>MPD</application> as a user daemon (and not as a
|
||||||
system daemon), the configuration is read from
|
system daemon), the configuration is read from
|
||||||
<filename>$XDG_CONFIG_HOME/mpd/mpd.conf</filename> (usually
|
<filename>$XDG_CONFIG_HOME/mpd/mpd.conf</filename> (usually
|
||||||
<filename>~/.config/mpd/mpd.conf</filename>).
|
<filename>~/.config/mpd/mpd.conf</filename>). On Android,
|
||||||
|
<filename>mpd.conf</filename> will be loaded from the
|
||||||
|
top-level directory of the data partition.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -2012,13 +2087,6 @@ run</programlisting>
|
|||||||
database.
|
database.
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
|
||||||
Note that unless overridden by the below settings (e.g. by
|
|
||||||
setting them to a blank value), general curl configuration
|
|
||||||
from environment variables such as http_proxy or specified
|
|
||||||
in ~/.curlrc will be in effect.
|
|
||||||
</para>
|
|
||||||
|
|
||||||
<informaltable>
|
<informaltable>
|
||||||
<tgroup cols="2">
|
<tgroup cols="2">
|
||||||
<thead>
|
<thead>
|
||||||
@@ -2046,6 +2114,15 @@ run</programlisting>
|
|||||||
<application>MPD</application> instance.
|
<application>MPD</application> instance.
|
||||||
</entry>
|
</entry>
|
||||||
</row>
|
</row>
|
||||||
|
<row>
|
||||||
|
<entry>
|
||||||
|
<varname>password</varname>
|
||||||
|
</entry>
|
||||||
|
<entry>
|
||||||
|
The password used to log in to the "master"
|
||||||
|
<application>MPD</application> instance.
|
||||||
|
</entry>
|
||||||
|
</row>
|
||||||
<row>
|
<row>
|
||||||
<entry>
|
<entry>
|
||||||
<varname>keepalive</varname>
|
<varname>keepalive</varname>
|
||||||
|
@@ -1,24 +1,37 @@
|
|||||||
import os.path, subprocess
|
import os.path, subprocess, sys
|
||||||
|
|
||||||
from build.project import Project
|
from build.makeproject import MakeProject
|
||||||
|
|
||||||
class AutotoolsProject(Project):
|
class AutotoolsProject(MakeProject):
|
||||||
def __init__(self, url, md5, installed, configure_args=[],
|
def __init__(self, url, md5, installed, configure_args=[],
|
||||||
autogen=False,
|
autogen=False,
|
||||||
|
autoreconf=False,
|
||||||
cppflags='',
|
cppflags='',
|
||||||
|
ldflags='',
|
||||||
|
libs='',
|
||||||
|
subdirs=None,
|
||||||
**kwargs):
|
**kwargs):
|
||||||
Project.__init__(self, url, md5, installed, **kwargs)
|
MakeProject.__init__(self, url, md5, installed, **kwargs)
|
||||||
self.configure_args = configure_args
|
self.configure_args = configure_args
|
||||||
self.autogen = autogen
|
self.autogen = autogen
|
||||||
|
self.autoreconf = autoreconf
|
||||||
self.cppflags = cppflags
|
self.cppflags = cppflags
|
||||||
|
self.ldflags = ldflags
|
||||||
|
self.libs = libs
|
||||||
|
self.subdirs = subdirs
|
||||||
|
|
||||||
def build(self, toolchain):
|
def configure(self, toolchain):
|
||||||
src = self.unpack(toolchain)
|
src = self.unpack(toolchain)
|
||||||
if self.autogen:
|
if self.autogen:
|
||||||
subprocess.check_call(['libtoolize', '--force'], cwd=src)
|
if sys.platform == 'darwin':
|
||||||
|
subprocess.check_call(['glibtoolize', '--force'], cwd=src)
|
||||||
|
else:
|
||||||
|
subprocess.check_call(['libtoolize', '--force'], cwd=src)
|
||||||
subprocess.check_call(['aclocal'], cwd=src)
|
subprocess.check_call(['aclocal'], cwd=src)
|
||||||
subprocess.check_call(['automake', '--add-missing', '--force-missing', '--foreign'], cwd=src)
|
subprocess.check_call(['automake', '--add-missing', '--force-missing', '--foreign'], cwd=src)
|
||||||
subprocess.check_call(['autoconf'], cwd=src)
|
subprocess.check_call(['autoconf'], cwd=src)
|
||||||
|
if self.autoreconf:
|
||||||
|
subprocess.check_call(['autoreconf', '-vif'], cwd=src)
|
||||||
|
|
||||||
build = self.make_build_path(toolchain)
|
build = self.make_build_path(toolchain)
|
||||||
|
|
||||||
@@ -29,8 +42,8 @@ class AutotoolsProject(Project):
|
|||||||
'CFLAGS=' + toolchain.cflags,
|
'CFLAGS=' + toolchain.cflags,
|
||||||
'CXXFLAGS=' + toolchain.cxxflags,
|
'CXXFLAGS=' + toolchain.cxxflags,
|
||||||
'CPPFLAGS=' + toolchain.cppflags + ' ' + self.cppflags,
|
'CPPFLAGS=' + toolchain.cppflags + ' ' + self.cppflags,
|
||||||
'LDFLAGS=' + toolchain.ldflags,
|
'LDFLAGS=' + toolchain.ldflags + ' ' + self.ldflags,
|
||||||
'LIBS=' + toolchain.libs,
|
'LIBS=' + toolchain.libs + ' ' + self.libs,
|
||||||
'AR=' + toolchain.ar,
|
'AR=' + toolchain.ar,
|
||||||
'RANLIB=' + toolchain.ranlib,
|
'RANLIB=' + toolchain.ranlib,
|
||||||
'STRIP=' + toolchain.strip,
|
'STRIP=' + toolchain.strip,
|
||||||
@@ -40,7 +53,12 @@ class AutotoolsProject(Project):
|
|||||||
] + self.configure_args
|
] + self.configure_args
|
||||||
|
|
||||||
subprocess.check_call(configure, cwd=build, env=toolchain.env)
|
subprocess.check_call(configure, cwd=build, env=toolchain.env)
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', '-j12'],
|
return build
|
||||||
cwd=build, env=toolchain.env)
|
|
||||||
subprocess.check_call(['/usr/bin/make', '--quiet', 'install'],
|
def build(self, toolchain):
|
||||||
cwd=build, env=toolchain.env)
|
build = self.configure(toolchain)
|
||||||
|
if self.subdirs is not None:
|
||||||
|
for subdir in self.subdirs:
|
||||||
|
MakeProject.build(self, toolchain, os.path.join(build, subdir))
|
||||||
|
else:
|
||||||
|
MakeProject.build(self, toolchain, build)
|
||||||
|
@@ -21,6 +21,8 @@ class FfmpegProject(Project):
|
|||||||
|
|
||||||
if toolchain.is_arm:
|
if toolchain.is_arm:
|
||||||
arch = 'arm'
|
arch = 'arm'
|
||||||
|
elif toolchain.is_aarch64:
|
||||||
|
arch = 'aarch64'
|
||||||
else:
|
else:
|
||||||
arch = 'x86'
|
arch = 'x86'
|
||||||
|
|
||||||
|
@@ -1,28 +1,54 @@
|
|||||||
|
import re
|
||||||
|
from os.path import abspath
|
||||||
|
|
||||||
from build.project import Project
|
from build.project import Project
|
||||||
from build.zlib import ZlibProject
|
from build.zlib import ZlibProject
|
||||||
|
from build.meson import MesonProject
|
||||||
from build.autotools import AutotoolsProject
|
from build.autotools import AutotoolsProject
|
||||||
from build.ffmpeg import FfmpegProject
|
from build.ffmpeg import FfmpegProject
|
||||||
from build.boost import BoostProject
|
from build.boost import BoostProject
|
||||||
|
|
||||||
|
libmpdclient = MesonProject(
|
||||||
|
'https://www.musicpd.org/download/libmpdclient/2/libmpdclient-2.16.tar.xz',
|
||||||
|
'fa6bdab67c0e0490302b38f00c27b4959735c3ec8aef7a88327adb1407654464',
|
||||||
|
'lib/libmpdclient.a',
|
||||||
|
)
|
||||||
|
|
||||||
libogg = AutotoolsProject(
|
libogg = AutotoolsProject(
|
||||||
'http://downloads.xiph.org/releases/ogg/libogg-1.3.2.tar.xz',
|
'http://downloads.xiph.org/releases/ogg/libogg-1.3.3.tar.xz',
|
||||||
'5c3a34309d8b98640827e5d0991a4015',
|
'4f3fc6178a533d392064f14776b23c397ed4b9f48f5de297aba73b643f955c08',
|
||||||
'lib/libogg.a',
|
'lib/libogg.a',
|
||||||
['--disable-shared', '--enable-static'],
|
[
|
||||||
|
'--disable-shared', '--enable-static',
|
||||||
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
libvorbis = AutotoolsProject(
|
libvorbis = AutotoolsProject(
|
||||||
'http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.5.tar.xz',
|
'http://downloads.xiph.org/releases/vorbis/libvorbis-1.3.6.tar.xz',
|
||||||
'28cb28097c07a735d6af56e598e1c90f',
|
'af00bb5a784e7c9e69f56823de4637c350643deedaf333d0fa86ecdba6fcb415',
|
||||||
'lib/libvorbis.a',
|
'lib/libvorbis.a',
|
||||||
['--disable-shared', '--enable-static'],
|
[
|
||||||
|
'--disable-shared', '--enable-static',
|
||||||
|
],
|
||||||
|
|
||||||
|
edits={
|
||||||
|
# this option is not understood by clang
|
||||||
|
'configure': lambda data: data.replace('-mno-ieee-fp', ' '),
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
opus = AutotoolsProject(
|
opus = AutotoolsProject(
|
||||||
'https://archive.mozilla.org/pub/opus/opus-1.2.1.tar.gz',
|
'https://archive.mozilla.org/pub/opus/opus-1.3.tar.gz',
|
||||||
'cfafd339ccd9c5ef8d6ab15d7e1a412c054bf4cb4ecbbbcc78c12ef2def70732',
|
'4f3d69aefdf2dbaf9825408e452a8a414ffc60494c70633560700398820dc550',
|
||||||
'lib/libopus.a',
|
'lib/libopus.a',
|
||||||
['--disable-shared', '--enable-static'],
|
[
|
||||||
|
'--disable-shared', '--enable-static',
|
||||||
|
'--disable-doc',
|
||||||
|
'--disable-extra-programs',
|
||||||
|
],
|
||||||
|
|
||||||
|
# suppress "visibility default" from opus_defines.h
|
||||||
|
cppflags='-DOPUS_EXPORT=',
|
||||||
)
|
)
|
||||||
|
|
||||||
flac = AutotoolsProject(
|
flac = AutotoolsProject(
|
||||||
@@ -32,7 +58,9 @@ flac = AutotoolsProject(
|
|||||||
[
|
[
|
||||||
'--disable-shared', '--enable-static',
|
'--disable-shared', '--enable-static',
|
||||||
'--disable-xmms-plugin', '--disable-cpplibs',
|
'--disable-xmms-plugin', '--disable-cpplibs',
|
||||||
|
'--disable-doxygen-docs',
|
||||||
],
|
],
|
||||||
|
subdirs=['include', 'src/libFLAC'],
|
||||||
)
|
)
|
||||||
|
|
||||||
zlib = ZlibProject(
|
zlib = ZlibProject(
|
||||||
@@ -45,21 +73,36 @@ libid3tag = AutotoolsProject(
|
|||||||
'ftp://ftp.mars.org/pub/mpeg/libid3tag-0.15.1b.tar.gz',
|
'ftp://ftp.mars.org/pub/mpeg/libid3tag-0.15.1b.tar.gz',
|
||||||
'e5808ad997ba32c498803822078748c3',
|
'e5808ad997ba32c498803822078748c3',
|
||||||
'lib/libid3tag.a',
|
'lib/libid3tag.a',
|
||||||
['--disable-shared', '--enable-static'],
|
[
|
||||||
|
'--disable-shared', '--enable-static',
|
||||||
|
|
||||||
|
# without this, libid3tag's configure.ac ignores -O* and -f*
|
||||||
|
'--disable-debugging',
|
||||||
|
],
|
||||||
autogen=True,
|
autogen=True,
|
||||||
|
|
||||||
|
edits={
|
||||||
|
# fix bug in libid3tag's configure.ac which discards all but the last optimization flag
|
||||||
|
'configure.ac': lambda data: re.sub(r'optimize="\$1"', r'optimize="$optimize $1"', data, count=1),
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
libmad = AutotoolsProject(
|
libmad = AutotoolsProject(
|
||||||
'ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz',
|
'ftp://ftp.mars.org/pub/mpeg/libmad-0.15.1b.tar.gz',
|
||||||
'1be543bc30c56fb6bea1d7bf6a64e66c',
|
'1be543bc30c56fb6bea1d7bf6a64e66c',
|
||||||
'lib/libmad.a',
|
'lib/libmad.a',
|
||||||
['--disable-shared', '--enable-static'],
|
[
|
||||||
|
'--disable-shared', '--enable-static',
|
||||||
|
|
||||||
|
# without this, libmad's configure.ac ignores -O* and -f*
|
||||||
|
'--disable-debugging',
|
||||||
|
],
|
||||||
autogen=True,
|
autogen=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
liblame = AutotoolsProject(
|
liblame = AutotoolsProject(
|
||||||
'http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz',
|
'http://downloads.sourceforge.net/project/lame/lame/3.100/lame-3.100.tar.gz',
|
||||||
'24346b4158e4af3bd9f2e194bb23eb473c75fb7377011523353196b19b9a23ff',
|
'ddfe36cab873794038ae2c1210557ad34857a4b6bdc515785d1da9e175b1da1e',
|
||||||
'lib/libmp3lame.a',
|
'lib/libmp3lame.a',
|
||||||
[
|
[
|
||||||
'--disable-shared', '--enable-static',
|
'--disable-shared', '--enable-static',
|
||||||
@@ -69,8 +112,8 @@ liblame = AutotoolsProject(
|
|||||||
)
|
)
|
||||||
|
|
||||||
ffmpeg = FfmpegProject(
|
ffmpeg = FfmpegProject(
|
||||||
'http://ffmpeg.org/releases/ffmpeg-3.4.1.tar.xz',
|
'http://ffmpeg.org/releases/ffmpeg-4.0.2.tar.xz',
|
||||||
'5a77278a63741efa74e26bf197b9bb09ac6381b9757391b922407210f0f991c0',
|
'a95c0cc9eb990e94031d2183f2e6e444cc61c99f6f182d1575c433d62afb2f97',
|
||||||
'lib/libavcodec.a',
|
'lib/libavcodec.a',
|
||||||
[
|
[
|
||||||
'--disable-shared', '--enable-static',
|
'--disable-shared', '--enable-static',
|
||||||
@@ -89,21 +132,217 @@ ffmpeg = FfmpegProject(
|
|||||||
'--disable-pixelutils',
|
'--disable-pixelutils',
|
||||||
'--disable-network',
|
'--disable-network',
|
||||||
'--disable-encoders',
|
'--disable-encoders',
|
||||||
|
'--disable-muxers',
|
||||||
'--disable-protocols',
|
'--disable-protocols',
|
||||||
'--disable-devices',
|
'--disable-devices',
|
||||||
'--disable-filters',
|
'--disable-filters',
|
||||||
'--disable-v4l2_m2m',
|
'--disable-v4l2_m2m',
|
||||||
|
|
||||||
# clang misinterprets the "B0" in hevc_mvs.c as binary
|
'--disable-parser=bmp',
|
||||||
# literal, which breaks the build; but we don't need that
|
'--disable-parser=cavsvideo',
|
||||||
# video codec anyway
|
'--disable-parser=dvbsub',
|
||||||
|
'--disable-parser=dvdsub',
|
||||||
|
'--disable-parser=dvd_nav',
|
||||||
|
'--disable-parser=flac',
|
||||||
|
'--disable-parser=g729',
|
||||||
|
'--disable-parser=gsm',
|
||||||
|
'--disable-parser=h261',
|
||||||
|
'--disable-parser=h263',
|
||||||
|
'--disable-parser=h264',
|
||||||
|
'--disable-parser=hevc',
|
||||||
|
'--disable-parser=mjpeg',
|
||||||
|
'--disable-parser=mlp',
|
||||||
|
'--disable-parser=mpeg4video',
|
||||||
|
'--disable-parser=mpegvideo',
|
||||||
|
'--disable-parser=opus',
|
||||||
|
'--disable-parser=vc1',
|
||||||
|
'--disable-parser=vp3',
|
||||||
|
'--disable-parser=vp8',
|
||||||
|
'--disable-parser=vp9',
|
||||||
|
'--disable-parser=png',
|
||||||
|
'--disable-parser=pnm',
|
||||||
|
'--disable-parser=xma',
|
||||||
|
|
||||||
|
'--disable-demuxer=aqtitle',
|
||||||
|
'--disable-demuxer=ass',
|
||||||
|
'--disable-demuxer=bethsoftvid',
|
||||||
|
'--disable-demuxer=bink',
|
||||||
|
'--disable-demuxer=cavsvideo',
|
||||||
|
'--disable-demuxer=cdxl',
|
||||||
|
'--disable-demuxer=dvbsub',
|
||||||
|
'--disable-demuxer=dvbtxt',
|
||||||
|
'--disable-demuxer=h261',
|
||||||
|
'--disable-demuxer=h263',
|
||||||
|
'--disable-demuxer=h264',
|
||||||
|
'--disable-demuxer=ico',
|
||||||
|
'--disable-demuxer=image2',
|
||||||
|
'--disable-demuxer=jacosub',
|
||||||
|
'--disable-demuxer=lrc',
|
||||||
|
'--disable-demuxer=microdvd',
|
||||||
|
'--disable-demuxer=mjpeg',
|
||||||
|
'--disable-demuxer=mjpeg_2000',
|
||||||
|
'--disable-demuxer=mpegps',
|
||||||
|
'--disable-demuxer=mpegvideo',
|
||||||
|
'--disable-demuxer=mpl2',
|
||||||
|
'--disable-demuxer=mpsub',
|
||||||
|
'--disable-demuxer=pjs',
|
||||||
|
'--disable-demuxer=rawvideo',
|
||||||
|
'--disable-demuxer=realtext',
|
||||||
|
'--disable-demuxer=sami',
|
||||||
|
'--disable-demuxer=scc',
|
||||||
|
'--disable-demuxer=srt',
|
||||||
|
'--disable-demuxer=stl',
|
||||||
|
'--disable-demuxer=subviewer',
|
||||||
|
'--disable-demuxer=subviewer1',
|
||||||
|
'--disable-demuxer=swf',
|
||||||
|
'--disable-demuxer=tedcaptions',
|
||||||
|
'--disable-demuxer=vobsub',
|
||||||
|
'--disable-demuxer=vplayer',
|
||||||
|
'--disable-demuxer=webvtt',
|
||||||
|
'--disable-demuxer=yuv4mpegpipe',
|
||||||
|
|
||||||
|
# we don't need these decoders, because we have the dedicated
|
||||||
|
# libraries
|
||||||
|
'--disable-decoder=flac',
|
||||||
|
'--disable-decoder=opus',
|
||||||
|
'--disable-decoder=vorbis',
|
||||||
|
|
||||||
|
# audio codecs nobody uses
|
||||||
|
'--disable-decoder=atrac1',
|
||||||
|
'--disable-decoder=atrac3',
|
||||||
|
'--disable-decoder=atrac3al',
|
||||||
|
'--disable-decoder=atrac3p',
|
||||||
|
'--disable-decoder=atrac3pal',
|
||||||
|
'--disable-decoder=binkaudio_dct',
|
||||||
|
'--disable-decoder=binkaudio_rdft',
|
||||||
|
'--disable-decoder=bmv_audio',
|
||||||
|
'--disable-decoder=dsicinaudio',
|
||||||
|
'--disable-decoder=dvaudio',
|
||||||
|
'--disable-decoder=metasound',
|
||||||
|
'--disable-decoder=paf_audio',
|
||||||
|
'--disable-decoder=ra_144',
|
||||||
|
'--disable-decoder=ra_288',
|
||||||
|
'--disable-decoder=ralf',
|
||||||
|
'--disable-decoder=qdm2',
|
||||||
|
'--disable-decoder=qdmc',
|
||||||
|
|
||||||
|
# disable lots of image and video codecs
|
||||||
|
'--disable-decoder=ass',
|
||||||
|
'--disable-decoder=asv1',
|
||||||
|
'--disable-decoder=asv2',
|
||||||
|
'--disable-decoder=apng',
|
||||||
|
'--disable-decoder=avrn',
|
||||||
|
'--disable-decoder=avrp',
|
||||||
|
'--disable-decoder=bethsoftvid',
|
||||||
|
'--disable-decoder=bink',
|
||||||
|
'--disable-decoder=bmp',
|
||||||
|
'--disable-decoder=bmv_video',
|
||||||
|
'--disable-decoder=cavs',
|
||||||
|
'--disable-decoder=ccaption',
|
||||||
|
'--disable-decoder=cdgraphics',
|
||||||
|
'--disable-decoder=clearvideo',
|
||||||
|
'--disable-decoder=dirac',
|
||||||
|
'--disable-decoder=dsicinvideo',
|
||||||
|
'--disable-decoder=dvbsub',
|
||||||
|
'--disable-decoder=dvdsub',
|
||||||
|
'--disable-decoder=dvvideo',
|
||||||
|
'--disable-decoder=exr',
|
||||||
|
'--disable-decoder=ffv1',
|
||||||
|
'--disable-decoder=ffvhuff',
|
||||||
|
'--disable-decoder=ffwavesynth',
|
||||||
|
'--disable-decoder=flic',
|
||||||
|
'--disable-decoder=flv',
|
||||||
|
'--disable-decoder=fraps',
|
||||||
|
'--disable-decoder=gif',
|
||||||
|
'--disable-decoder=h261',
|
||||||
|
'--disable-decoder=h263',
|
||||||
|
'--disable-decoder=h263i',
|
||||||
|
'--disable-decoder=h263p',
|
||||||
|
'--disable-decoder=h264',
|
||||||
'--disable-decoder=hevc',
|
'--disable-decoder=hevc',
|
||||||
|
'--disable-decoder=hnm4_video',
|
||||||
|
'--disable-decoder=hq_hqa',
|
||||||
|
'--disable-decoder=hqx',
|
||||||
|
'--disable-decoder=idcin',
|
||||||
|
'--disable-decoder=iff_ilbm',
|
||||||
|
'--disable-decoder=indeo2',
|
||||||
|
'--disable-decoder=indeo3',
|
||||||
|
'--disable-decoder=indeo4',
|
||||||
|
'--disable-decoder=indeo5',
|
||||||
|
'--disable-decoder=interplay_video',
|
||||||
|
'--disable-decoder=jacosub',
|
||||||
|
'--disable-decoder=jpeg2000',
|
||||||
|
'--disable-decoder=jpegls',
|
||||||
|
'--disable-decoder=microdvd',
|
||||||
|
'--disable-decoder=mimic',
|
||||||
|
'--disable-decoder=mjpeg',
|
||||||
|
'--disable-decoder=mmvideo',
|
||||||
|
'--disable-decoder=mpl2',
|
||||||
|
'--disable-decoder=motionpixels',
|
||||||
|
'--disable-decoder=mpeg1video',
|
||||||
|
'--disable-decoder=mpeg2video',
|
||||||
|
'--disable-decoder=mpeg4',
|
||||||
|
'--disable-decoder=mpegvideo',
|
||||||
|
'--disable-decoder=mscc',
|
||||||
|
'--disable-decoder=msmpeg4_crystalhd',
|
||||||
|
'--disable-decoder=msmpeg4v1',
|
||||||
|
'--disable-decoder=msmpeg4v2',
|
||||||
|
'--disable-decoder=msmpeg4v3',
|
||||||
|
'--disable-decoder=msvideo1',
|
||||||
|
'--disable-decoder=mszh',
|
||||||
|
'--disable-decoder=mvc1',
|
||||||
|
'--disable-decoder=mvc2',
|
||||||
|
'--disable-decoder=on2avc',
|
||||||
|
'--disable-decoder=paf_video',
|
||||||
|
'--disable-decoder=png',
|
||||||
|
'--disable-decoder=qdraw',
|
||||||
|
'--disable-decoder=qpeg',
|
||||||
|
'--disable-decoder=rawvideo',
|
||||||
|
'--disable-decoder=realtext',
|
||||||
|
'--disable-decoder=roq',
|
||||||
|
'--disable-decoder=roq_dpcm',
|
||||||
|
'--disable-decoder=rscc',
|
||||||
|
'--disable-decoder=rv10',
|
||||||
|
'--disable-decoder=rv20',
|
||||||
|
'--disable-decoder=rv30',
|
||||||
|
'--disable-decoder=rv40',
|
||||||
|
'--disable-decoder=sami',
|
||||||
|
'--disable-decoder=sheervideo',
|
||||||
|
'--disable-decoder=snow',
|
||||||
|
'--disable-decoder=srt',
|
||||||
|
'--disable-decoder=stl',
|
||||||
|
'--disable-decoder=subrip',
|
||||||
|
'--disable-decoder=subviewer',
|
||||||
|
'--disable-decoder=subviewer1',
|
||||||
|
'--disable-decoder=svq1',
|
||||||
|
'--disable-decoder=svq3',
|
||||||
|
'--disable-decoder=tiff',
|
||||||
|
'--disable-decoder=tiertexseqvideo',
|
||||||
|
'--disable-decoder=truemotion1',
|
||||||
|
'--disable-decoder=truemotion2',
|
||||||
|
'--disable-decoder=truemotion2rt',
|
||||||
|
'--disable-decoder=twinvq',
|
||||||
|
'--disable-decoder=utvideo',
|
||||||
|
'--disable-decoder=vc1',
|
||||||
|
'--disable-decoder=vmdvideo',
|
||||||
|
'--disable-decoder=vp3',
|
||||||
|
'--disable-decoder=vp5',
|
||||||
|
'--disable-decoder=vp6',
|
||||||
|
'--disable-decoder=vp7',
|
||||||
|
'--disable-decoder=vp8',
|
||||||
|
'--disable-decoder=vp9',
|
||||||
|
'--disable-decoder=vqa',
|
||||||
|
'--disable-decoder=webvtt',
|
||||||
|
'--disable-decoder=wmv1',
|
||||||
|
'--disable-decoder=wmv2',
|
||||||
|
'--disable-decoder=wmv3',
|
||||||
|
'--disable-decoder=yuv4',
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
curl = AutotoolsProject(
|
curl = AutotoolsProject(
|
||||||
'http://curl.haxx.se/download/curl-7.57.0.tar.xz',
|
'http://curl.haxx.se/download/curl-7.61.1.tar.xz',
|
||||||
'f5f6fd3c72b7b8389969f4fb671ed8532fa9b5bb7a5cae7ca89bc1cea45c7878',
|
'3d5913d6a39bd22e68e34dff697fd6e4c3c81563f580c76fca2009315cd81891',
|
||||||
'lib/libcurl.a',
|
'lib/libcurl.a',
|
||||||
[
|
[
|
||||||
'--disable-shared', '--enable-static',
|
'--disable-shared', '--enable-static',
|
||||||
@@ -114,16 +353,46 @@ curl = AutotoolsProject(
|
|||||||
'--disable-ldap', '--disable-ldaps',
|
'--disable-ldap', '--disable-ldaps',
|
||||||
'--disable-rtsp', '--disable-proxy', '--disable-dict', '--disable-telnet',
|
'--disable-rtsp', '--disable-proxy', '--disable-dict', '--disable-telnet',
|
||||||
'--disable-tftp', '--disable-pop3', '--disable-imap', '--disable-smtp',
|
'--disable-tftp', '--disable-pop3', '--disable-imap', '--disable-smtp',
|
||||||
|
'--disable-smb',
|
||||||
'--disable-gopher',
|
'--disable-gopher',
|
||||||
'--disable-manual',
|
'--disable-manual',
|
||||||
'--disable-threaded-resolver', '--disable-verbose', '--disable-sspi',
|
'--disable-threaded-resolver', '--disable-verbose', '--disable-sspi',
|
||||||
'--disable-crypto-auth', '--disable-ntlm-wb', '--disable-tls-srp', '--disable-cookies',
|
'--disable-crypto-auth', '--disable-ntlm-wb', '--disable-tls-srp', '--disable-cookies',
|
||||||
'--without-ssl', '--without-gnutls', '--without-nss', '--without-libssh2',
|
'--without-ssl', '--without-gnutls', '--without-nss', '--without-libssh2',
|
||||||
],
|
],
|
||||||
|
|
||||||
|
patches='src/lib/curl/patches',
|
||||||
|
)
|
||||||
|
|
||||||
|
libexpat = AutotoolsProject(
|
||||||
|
'https://github.com/libexpat/libexpat/releases/download/R_2_2_6/expat-2.2.6.tar.bz2',
|
||||||
|
'17b43c2716d521369f82fc2dc70f359860e90fa440bea65b3b85f0b246ea81f2',
|
||||||
|
'lib/libexpat.a',
|
||||||
|
[
|
||||||
|
'--disable-shared', '--enable-static',
|
||||||
|
'--without-docbook',
|
||||||
|
],
|
||||||
|
)
|
||||||
|
|
||||||
|
libnfs = AutotoolsProject(
|
||||||
|
'https://github.com/sahlberg/libnfs/archive/libnfs-3.0.0.tar.gz',
|
||||||
|
'445d92c5fc55e4a5b115e358e60486cf8f87ee50e0103d46a02e7fb4618566a5',
|
||||||
|
'lib/libnfs.a',
|
||||||
|
[
|
||||||
|
'--disable-shared', '--enable-static',
|
||||||
|
'--disable-debug',
|
||||||
|
|
||||||
|
# work around -Wtautological-compare
|
||||||
|
'--disable-werror',
|
||||||
|
|
||||||
|
'--disable-utils', '--disable-examples',
|
||||||
|
],
|
||||||
|
base='libnfs-libnfs-3.0.0',
|
||||||
|
autoreconf=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
boost = BoostProject(
|
boost = BoostProject(
|
||||||
'http://downloads.sourceforge.net/project/boost/boost/1.65.1/boost_1_65_1.tar.bz2',
|
'http://downloads.sourceforge.net/project/boost/boost/1.68.0/boost_1_68_0.tar.bz2',
|
||||||
'9807a5d16566c57fd74fb522764e0b134a8bbe6b6e8967b83afefd30dcd3be81',
|
'7f6130bc3cf65f56a618888ce9d5ea704fa10b462be126ad053e80e553d6d8b7',
|
||||||
'include/boost/version.hpp',
|
'include/boost/version.hpp',
|
||||||
)
|
)
|
||||||
|
28
python/build/makeproject.py
Normal file
28
python/build/makeproject.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import subprocess
|
||||||
|
|
||||||
|
from build.project import Project
|
||||||
|
|
||||||
|
class MakeProject(Project):
|
||||||
|
def __init__(self, url, md5, installed,
|
||||||
|
install_target='install',
|
||||||
|
**kwargs):
|
||||||
|
Project.__init__(self, url, md5, installed, **kwargs)
|
||||||
|
self.install_target = install_target
|
||||||
|
|
||||||
|
def get_simultaneous_jobs(self):
|
||||||
|
return 12
|
||||||
|
|
||||||
|
def get_make_args(self, toolchain):
|
||||||
|
return ['--quiet', '-j' + str(self.get_simultaneous_jobs())]
|
||||||
|
|
||||||
|
def get_make_install_args(self, toolchain):
|
||||||
|
return ['--quiet', self.install_target]
|
||||||
|
|
||||||
|
def make(self, toolchain, wd, args):
|
||||||
|
subprocess.check_call(['/usr/bin/make'] + args,
|
||||||
|
cwd=wd, env=toolchain.env)
|
||||||
|
|
||||||
|
def build(self, toolchain, wd, install=True):
|
||||||
|
self.make(toolchain, wd, self.get_make_args(toolchain))
|
||||||
|
if install:
|
||||||
|
self.make(toolchain, wd, self.get_make_install_args(toolchain))
|
102
python/build/meson.py
Normal file
102
python/build/meson.py
Normal file
@@ -0,0 +1,102 @@
|
|||||||
|
import os.path, subprocess, sys
|
||||||
|
|
||||||
|
from build.project import Project
|
||||||
|
|
||||||
|
class MesonProject(Project):
|
||||||
|
def __init__(self, url, md5, installed, configure_args=[],
|
||||||
|
**kwargs):
|
||||||
|
Project.__init__(self, url, md5, installed, **kwargs)
|
||||||
|
self.configure_args = configure_args
|
||||||
|
|
||||||
|
def _make_cross_file(self, toolchain):
|
||||||
|
if toolchain.is_windows:
|
||||||
|
system = 'windows'
|
||||||
|
else:
|
||||||
|
system = 'linux'
|
||||||
|
|
||||||
|
if toolchain.is_arm:
|
||||||
|
cpu_family = 'arm'
|
||||||
|
if toolchain.is_armv7:
|
||||||
|
cpu = 'armv7'
|
||||||
|
else:
|
||||||
|
cpu = 'armv6'
|
||||||
|
elif toolchain.is_aarch64:
|
||||||
|
cpu_family = 'aarch64'
|
||||||
|
cpu = 'arm64-v8a'
|
||||||
|
else:
|
||||||
|
cpu_family = 'x86'
|
||||||
|
if 'x86_64' in toolchain.arch:
|
||||||
|
cpu = 'x86_64'
|
||||||
|
else:
|
||||||
|
cpu = 'i686'
|
||||||
|
|
||||||
|
# TODO: support more CPUs
|
||||||
|
endian = 'little'
|
||||||
|
|
||||||
|
# TODO: write pkg-config wrapper
|
||||||
|
|
||||||
|
path = os.path.join(toolchain.build_path, 'meson.cross')
|
||||||
|
os.makedirs(toolchain.build_path, exist_ok=True)
|
||||||
|
with open(path, 'w') as f:
|
||||||
|
f.write("""
|
||||||
|
[binaries]
|
||||||
|
c = '%s'
|
||||||
|
cpp = '%s'
|
||||||
|
ar = '%s'
|
||||||
|
strip = '%s'
|
||||||
|
|
||||||
|
[properties]
|
||||||
|
root = '%s'
|
||||||
|
|
||||||
|
c_args = %s
|
||||||
|
c_link_args = %s
|
||||||
|
|
||||||
|
cpp_args = %s
|
||||||
|
cpp_link_args = %s
|
||||||
|
|
||||||
|
# Keep Meson from executing Android-x86 test binariees
|
||||||
|
needs_exe_wrapper = true
|
||||||
|
|
||||||
|
[host_machine]
|
||||||
|
system = '%s'
|
||||||
|
cpu_family = '%s'
|
||||||
|
cpu = '%s'
|
||||||
|
endian = '%s'
|
||||||
|
""" % (toolchain.cc, toolchain.cxx, toolchain.ar, toolchain.strip,
|
||||||
|
toolchain.install_prefix,
|
||||||
|
repr((toolchain.cppflags + ' ' + toolchain.cflags).split()),
|
||||||
|
repr(toolchain.ldflags.split()),
|
||||||
|
repr((toolchain.cppflags + ' ' + toolchain.cxxflags).split()),
|
||||||
|
repr(toolchain.ldflags.split()),
|
||||||
|
system, cpu_family, cpu, endian))
|
||||||
|
return path
|
||||||
|
|
||||||
|
def configure(self, toolchain):
|
||||||
|
src = self.unpack(toolchain)
|
||||||
|
cross_file = self._make_cross_file(toolchain)
|
||||||
|
build = self.make_build_path(toolchain)
|
||||||
|
configure = [
|
||||||
|
'meson',
|
||||||
|
src, build,
|
||||||
|
|
||||||
|
'--prefix', toolchain.install_prefix,
|
||||||
|
|
||||||
|
# this is necessary because Meson uses Debian's build machine
|
||||||
|
# MultiArch path (e.g. "lib/x86_64-linux-gnu") for cross
|
||||||
|
# builds, which is obviously wrong
|
||||||
|
'--libdir', 'lib',
|
||||||
|
|
||||||
|
'--buildtype', 'plain',
|
||||||
|
|
||||||
|
'--default-library=static',
|
||||||
|
|
||||||
|
'--cross-file', cross_file,
|
||||||
|
] + self.configure_args
|
||||||
|
|
||||||
|
subprocess.check_call(configure, env=toolchain.env)
|
||||||
|
return build
|
||||||
|
|
||||||
|
def build(self, toolchain):
|
||||||
|
build = self.configure(toolchain)
|
||||||
|
subprocess.check_call(['ninja', 'install'],
|
||||||
|
cwd=build, env=toolchain.env)
|
@@ -3,10 +3,13 @@ import re
|
|||||||
|
|
||||||
from build.download import download_and_verify
|
from build.download import download_and_verify
|
||||||
from build.tar import untar
|
from build.tar import untar
|
||||||
|
from build.quilt import push_all
|
||||||
|
|
||||||
class Project:
|
class Project:
|
||||||
def __init__(self, url, md5, installed, name=None, version=None,
|
def __init__(self, url, md5, installed, name=None, version=None,
|
||||||
base=None,
|
base=None,
|
||||||
|
patches=None,
|
||||||
|
edits=None,
|
||||||
use_cxx=False):
|
use_cxx=False):
|
||||||
if base is None:
|
if base is None:
|
||||||
basename = os.path.basename(url)
|
basename = os.path.basename(url)
|
||||||
@@ -17,7 +20,7 @@ class Project:
|
|||||||
self.base = base
|
self.base = base
|
||||||
|
|
||||||
if name is None or version is None:
|
if name is None or version is None:
|
||||||
m = re.match(r'^([-\w]+)-(\d[\d.]*[a-z]?)$', self.base)
|
m = re.match(r'^([-\w]+)-(\d[\d.]*[a-z]?[\d.]*)$', self.base)
|
||||||
if name is None: name = m.group(1)
|
if name is None: name = m.group(1)
|
||||||
if version is None: version = m.group(2)
|
if version is None: version = m.group(2)
|
||||||
|
|
||||||
@@ -28,6 +31,11 @@ class Project:
|
|||||||
self.md5 = md5
|
self.md5 = md5
|
||||||
self.installed = installed
|
self.installed = installed
|
||||||
|
|
||||||
|
if patches is not None:
|
||||||
|
srcdir = os.path.dirname(os.path.dirname(os.path.dirname(__file__)))
|
||||||
|
patches = os.path.join(srcdir, patches)
|
||||||
|
self.patches = patches
|
||||||
|
self.edits = edits
|
||||||
self.use_cxx = use_cxx
|
self.use_cxx = use_cxx
|
||||||
|
|
||||||
def download(self, toolchain):
|
def download(self, toolchain):
|
||||||
@@ -47,7 +55,21 @@ class Project:
|
|||||||
parent_path = toolchain.src_path
|
parent_path = toolchain.src_path
|
||||||
else:
|
else:
|
||||||
parent_path = toolchain.build_path
|
parent_path = toolchain.build_path
|
||||||
return untar(self.download(toolchain), parent_path, self.base)
|
path = untar(self.download(toolchain), parent_path, self.base)
|
||||||
|
|
||||||
|
if self.patches is not None:
|
||||||
|
push_all(toolchain, path, self.patches)
|
||||||
|
|
||||||
|
if self.edits is not None:
|
||||||
|
for filename, function in self.edits.items():
|
||||||
|
with open(os.path.join(path, filename), 'r+t') as f:
|
||||||
|
old_data = f.read()
|
||||||
|
new_data = function(old_data)
|
||||||
|
f.seek(0)
|
||||||
|
f.truncate(0)
|
||||||
|
f.write(new_data)
|
||||||
|
|
||||||
|
return path
|
||||||
|
|
||||||
def make_build_path(self, toolchain):
|
def make_build_path(self, toolchain):
|
||||||
path = os.path.join(toolchain.build_path, self.base)
|
path = os.path.join(toolchain.build_path, self.base)
|
||||||
|
9
python/build/quilt.py
Normal file
9
python/build/quilt.py
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
import subprocess
|
||||||
|
|
||||||
|
def run_quilt(toolchain, cwd, patches_path, *args):
|
||||||
|
env = dict(toolchain.env)
|
||||||
|
env['QUILT_PATCHES'] = patches_path
|
||||||
|
subprocess.check_call(['quilt'] + list(args), cwd=cwd, env=env)
|
||||||
|
|
||||||
|
def push_all(toolchain, src_path, patches_path):
|
||||||
|
run_quilt(toolchain, src_path, patches_path, 'push', '-a')
|
@@ -19,9 +19,9 @@
|
|||||||
|
|
||||||
#include "AudioFormat.hxx"
|
#include "AudioFormat.hxx"
|
||||||
#include "util/StringBuffer.hxx"
|
#include "util/StringBuffer.hxx"
|
||||||
|
#include "util/StringFormat.hxx"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
void
|
void
|
||||||
AudioFormat::ApplyMask(AudioFormat mask) noexcept
|
AudioFormat::ApplyMask(AudioFormat mask) noexcept
|
||||||
@@ -44,21 +44,16 @@ AudioFormat::ApplyMask(AudioFormat mask) noexcept
|
|||||||
StringBuffer<24>
|
StringBuffer<24>
|
||||||
ToString(const AudioFormat af) noexcept
|
ToString(const AudioFormat af) noexcept
|
||||||
{
|
{
|
||||||
StringBuffer<24> buffer;
|
|
||||||
|
|
||||||
if (af.format == SampleFormat::DSD && af.sample_rate > 0 &&
|
if (af.format == SampleFormat::DSD && af.sample_rate > 0 &&
|
||||||
af.sample_rate % 44100 == 0) {
|
af.sample_rate % 44100 == 0) {
|
||||||
/* use shortcuts such as "dsd64" which implies the
|
/* use shortcuts such as "dsd64" which implies the
|
||||||
sample rate */
|
sample rate */
|
||||||
snprintf(buffer.data(), buffer.capacity(), "dsd%u:%u",
|
return StringFormat<24>("dsd%u:%u",
|
||||||
af.sample_rate * 8 / 44100,
|
af.sample_rate * 8 / 44100,
|
||||||
af.channels);
|
af.channels);
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(buffer.data(), buffer.capacity(), "%u:%s:%u",
|
return StringFormat<24>("%u:%s:%u",
|
||||||
af.sample_rate, sample_format_to_string(af.format),
|
af.sample_rate, sample_format_to_string(af.format),
|
||||||
af.channels);
|
af.channels);
|
||||||
|
|
||||||
return buffer;
|
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,6 @@
|
|||||||
#include "pcm/SampleFormat.hxx"
|
#include "pcm/SampleFormat.hxx"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
#include <assert.h>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
|
||||||
|
@@ -27,12 +27,17 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
static struct {
|
static struct IOThread {
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
Cond cond;
|
Cond cond;
|
||||||
|
|
||||||
EventLoop *loop;
|
EventLoop *loop;
|
||||||
Thread thread;
|
Thread thread;
|
||||||
|
|
||||||
|
IOThread():thread(BIND_THIS_METHOD(Run)) {}
|
||||||
|
|
||||||
|
private:
|
||||||
|
void Run() noexcept;
|
||||||
} io;
|
} io;
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -44,15 +49,15 @@ io_thread_run(void)
|
|||||||
io.loop->Run();
|
io.loop->Run();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
inline void
|
||||||
io_thread_func(gcc_unused void *arg)
|
IOThread::Run() noexcept
|
||||||
{
|
{
|
||||||
SetThreadName("io");
|
SetThreadName("io");
|
||||||
|
|
||||||
/* lock+unlock to synchronize with io_thread_start(), to be
|
/* lock+unlock to synchronize with io_thread_start(), to be
|
||||||
sure that io.thread is set */
|
sure that io.thread is set */
|
||||||
io.mutex.lock();
|
mutex.lock();
|
||||||
io.mutex.unlock();
|
mutex.unlock();
|
||||||
|
|
||||||
io_thread_run();
|
io_thread_run();
|
||||||
}
|
}
|
||||||
@@ -73,7 +78,7 @@ io_thread_start()
|
|||||||
assert(!io.thread.IsDefined());
|
assert(!io.thread.IsDefined());
|
||||||
|
|
||||||
const std::lock_guard<Mutex> protect(io.mutex);
|
const std::lock_guard<Mutex> protect(io.mutex);
|
||||||
io.thread.Start(io_thread_func, nullptr);
|
io.thread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -103,8 +108,12 @@ io_thread_get() noexcept
|
|||||||
return *io.loop;
|
return *io.loop;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
|
||||||
bool
|
bool
|
||||||
io_thread_inside() noexcept
|
io_thread_inside() noexcept
|
||||||
{
|
{
|
||||||
return io.thread.IsInside();
|
return io.thread.IsInside();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#ifndef MPD_IO_THREAD_HXX
|
#ifndef MPD_IO_THREAD_HXX
|
||||||
#define MPD_IO_THREAD_HXX
|
#define MPD_IO_THREAD_HXX
|
||||||
|
|
||||||
|
#include "check.h"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
class EventLoop;
|
class EventLoop;
|
||||||
@@ -53,6 +54,8 @@ gcc_const
|
|||||||
EventLoop &
|
EventLoop &
|
||||||
io_thread_get() noexcept;
|
io_thread_get() noexcept;
|
||||||
|
|
||||||
|
#ifndef NDEBUG
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the current thread the I/O thread?
|
* Is the current thread the I/O thread?
|
||||||
*/
|
*/
|
||||||
@@ -61,3 +64,5 @@ bool
|
|||||||
io_thread_inside() noexcept;
|
io_thread_inside() noexcept;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#endif
|
||||||
|
@@ -23,7 +23,7 @@
|
|||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "ls.hxx"
|
#include "ls.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/ASCII.hxx"
|
||||||
|
|
||||||
#ifdef ENABLE_DATABASE
|
#ifdef ENABLE_DATABASE
|
||||||
#include "storage/StorageInterface.hxx"
|
#include "storage/StorageInterface.hxx"
|
||||||
@@ -83,7 +83,7 @@ LocateUri(const char *uri, const Client *client
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
/* skip the obsolete "file://" prefix */
|
/* skip the obsolete "file://" prefix */
|
||||||
const char *path_utf8 = StringAfterPrefix(uri, "file://");
|
const char *path_utf8 = StringAfterPrefixCaseASCII(uri, "file://");
|
||||||
if (path_utf8 != nullptr) {
|
if (path_utf8 != nullptr) {
|
||||||
if (!PathTraitsUTF8::IsAbsolute(path_utf8))
|
if (!PathTraitsUTF8::IsAbsolute(path_utf8))
|
||||||
throw std::runtime_error("Malformed file:// URI");
|
throw std::runtime_error("Malformed file:// URI");
|
||||||
|
@@ -34,6 +34,8 @@
|
|||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
#include <android/log.h>
|
#include <android/log.h>
|
||||||
|
#include "android/LogListener.hxx"
|
||||||
|
#include "Main.hxx"
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ToAndroidLogLevel(LogLevel log_level)
|
ToAndroidLogLevel(LogLevel log_level)
|
||||||
@@ -177,6 +179,9 @@ Log(const Domain &domain, LogLevel level, const char *msg)
|
|||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
__android_log_print(ToAndroidLogLevel(level), "MPD",
|
__android_log_print(ToAndroidLogLevel(level), "MPD",
|
||||||
"%s: %s", domain.GetName(), msg);
|
"%s: %s", domain.GetName(), msg);
|
||||||
|
if (logListener != nullptr)
|
||||||
|
logListener->OnLog(Java::GetEnv(), ToAndroidLogLevel(level),
|
||||||
|
"%s: %s", domain.GetName(), msg);
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if (level < log_threshold)
|
if (level < log_threshold)
|
||||||
|
58
src/Main.cxx
58
src/Main.cxx
@@ -50,6 +50,7 @@
|
|||||||
#include "unix/SignalHandlers.hxx"
|
#include "unix/SignalHandlers.hxx"
|
||||||
#include "system/FatalError.hxx"
|
#include "system/FatalError.hxx"
|
||||||
#include "thread/Slack.hxx"
|
#include "thread/Slack.hxx"
|
||||||
|
#include "net/Init.hxx"
|
||||||
#include "lib/icu/Init.hxx"
|
#include "lib/icu/Init.hxx"
|
||||||
#include "config/ConfigGlobal.hxx"
|
#include "config/ConfigGlobal.hxx"
|
||||||
#include "config/Param.hxx"
|
#include "config/Param.hxx"
|
||||||
@@ -91,6 +92,7 @@
|
|||||||
#include "java/File.hxx"
|
#include "java/File.hxx"
|
||||||
#include "android/Environment.hxx"
|
#include "android/Environment.hxx"
|
||||||
#include "android/Context.hxx"
|
#include "android/Context.hxx"
|
||||||
|
#include "android/LogListener.hxx"
|
||||||
#include "fs/StandardDirectory.hxx"
|
#include "fs/StandardDirectory.hxx"
|
||||||
#include "fs/FileSystem.hxx"
|
#include "fs/FileSystem.hxx"
|
||||||
#include "org_musicpd_Bridge.h"
|
#include "org_musicpd_Bridge.h"
|
||||||
@@ -106,15 +108,6 @@
|
|||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
#include <winsock2.h>
|
|
||||||
#include <ws2tcpip.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef __BLOCKS__
|
|
||||||
#include <dispatch/dispatch.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
static constexpr size_t KILOBYTE = 1024;
|
static constexpr size_t KILOBYTE = 1024;
|
||||||
@@ -136,6 +129,7 @@ static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
|
|||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
Context *context;
|
Context *context;
|
||||||
|
LogListener *logListener;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Instance *instance;
|
Instance *instance;
|
||||||
@@ -284,25 +278,6 @@ glue_state_file_init()
|
|||||||
instance->state_file->Read();
|
instance->state_file->Read();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Windows-only initialization of the Winsock2 library.
|
|
||||||
*/
|
|
||||||
static void winsock_init(void)
|
|
||||||
{
|
|
||||||
#ifdef _WIN32
|
|
||||||
WSADATA sockinfo;
|
|
||||||
|
|
||||||
int retval = WSAStartup(MAKEWORD(2, 2), &sockinfo);
|
|
||||||
if(retval != 0)
|
|
||||||
FormatFatalError("Attempt to open Winsock2 failed; error code %d",
|
|
||||||
retval);
|
|
||||||
|
|
||||||
if (LOBYTE(sockinfo.wVersion) != 2)
|
|
||||||
FatalError("We use Winsock2 but your version is either too new "
|
|
||||||
"or old; please install Winsock 2.x");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the decoder and player core, including the music pipe.
|
* Initialize the decoder and player core, including the music pipe.
|
||||||
*/
|
*/
|
||||||
@@ -451,7 +426,8 @@ try {
|
|||||||
|
|
||||||
IcuInit();
|
IcuInit();
|
||||||
|
|
||||||
winsock_init();
|
const ScopeNetInit net_init;
|
||||||
|
|
||||||
io_thread_init();
|
io_thread_init();
|
||||||
config_global_init();
|
config_global_init();
|
||||||
|
|
||||||
@@ -505,21 +481,8 @@ try {
|
|||||||
daemonize_begin(options.daemon);
|
daemonize_begin(options.daemon);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef __BLOCKS__
|
|
||||||
/* Runs the OS X native event loop in the main thread, and runs
|
|
||||||
the rest of mpd_main on a new thread. This lets CoreAudio receive
|
|
||||||
route change notifications (e.g. plugging or unplugging headphones).
|
|
||||||
All hardware output on OS X ultimately uses CoreAudio internally.
|
|
||||||
This must be run after forking; if dispatch is called before forking,
|
|
||||||
the child process will have a broken internal dispatch state. */
|
|
||||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
||||||
exit(mpd_main_after_fork(config));
|
|
||||||
});
|
|
||||||
dispatch_main();
|
|
||||||
return EXIT_FAILURE; // unreachable, because dispatch_main never returns
|
|
||||||
#else
|
|
||||||
return mpd_main_after_fork(config);
|
return mpd_main_after_fork(config);
|
||||||
#endif
|
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
LogError(e);
|
LogError(e);
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
@@ -702,10 +665,6 @@ try {
|
|||||||
daemonize_finish();
|
daemonize_finish();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef _WIN32
|
|
||||||
WSACleanup();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
IcuFinish();
|
IcuFinish();
|
||||||
|
|
||||||
log_deinit();
|
log_deinit();
|
||||||
@@ -719,16 +678,19 @@ try {
|
|||||||
|
|
||||||
gcc_visibility_default
|
gcc_visibility_default
|
||||||
JNIEXPORT void JNICALL
|
JNIEXPORT void JNICALL
|
||||||
Java_org_musicpd_Bridge_run(JNIEnv *env, jclass, jobject _context)
|
Java_org_musicpd_Bridge_run(JNIEnv *env, jclass, jobject _context, jobject _logListener)
|
||||||
{
|
{
|
||||||
Java::Init(env);
|
Java::Init(env);
|
||||||
Java::File::Initialise(env);
|
Java::File::Initialise(env);
|
||||||
Environment::Initialise(env);
|
Environment::Initialise(env);
|
||||||
|
|
||||||
context = new Context(env, _context);
|
context = new Context(env, _context);
|
||||||
|
if (_logListener != nullptr)
|
||||||
|
logListener = new LogListener(env, _logListener);
|
||||||
|
|
||||||
mpd_main(0, nullptr);
|
mpd_main(0, nullptr);
|
||||||
|
|
||||||
|
delete logListener;
|
||||||
delete context;
|
delete context;
|
||||||
Environment::Deinitialise(env);
|
Environment::Deinitialise(env);
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,10 @@ class Context;
|
|||||||
struct Instance;
|
struct Instance;
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
|
#include "android/LogListener.hxx"
|
||||||
|
|
||||||
extern Context *context;
|
extern Context *context;
|
||||||
|
extern LogListener *logListener;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern Instance *instance;
|
extern Instance *instance;
|
||||||
|
@@ -95,6 +95,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const MusicChunk *Peek() const noexcept {
|
const MusicChunk *Peek() const noexcept {
|
||||||
|
const std::lock_guard<Mutex> protect(mutex);
|
||||||
return head;
|
return head;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,6 +121,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
unsigned GetSize() const noexcept {
|
unsigned GetSize() const noexcept {
|
||||||
|
const std::lock_guard<Mutex> protect(mutex);
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -22,8 +22,11 @@
|
|||||||
#include "db/LightSong.hxx"
|
#include "db/LightSong.hxx"
|
||||||
#include "DetachedSong.hxx"
|
#include "DetachedSong.hxx"
|
||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
|
#include "tag/Fallback.hxx"
|
||||||
#include "util/ConstBuffer.hxx"
|
#include "util/ConstBuffer.hxx"
|
||||||
#include "util/StringAPI.hxx"
|
#include "util/StringAPI.hxx"
|
||||||
|
#include "util/StringCompare.hxx"
|
||||||
|
#include "util/StringView.hxx"
|
||||||
#include "util/ASCII.hxx"
|
#include "util/ASCII.hxx"
|
||||||
#include "util/TimeParser.hxx"
|
#include "util/TimeParser.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
@@ -59,13 +62,13 @@ locate_parse_type(const char *str) noexcept
|
|||||||
|
|
||||||
SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case)
|
SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case)
|
||||||
:tag(_tag),
|
:tag(_tag),
|
||||||
value(AllocatedString<>::Duplicate(_value)),
|
value(_value),
|
||||||
fold_case(_fold_case ? IcuCompare(value.c_str()) : IcuCompare())
|
fold_case(_fold_case ? IcuCompare(value.c_str()) : IcuCompare())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SongFilter::Item::Item(unsigned _tag, time_t _time)
|
SongFilter::Item::Item(unsigned _tag, time_t _time)
|
||||||
:tag(_tag), value(nullptr), time(_time)
|
:tag(_tag), time(_time)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,6 +110,24 @@ SongFilter::Item::Match(const Tag &_tag) const noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tag < TAG_NUM_OF_ITEM_TYPES && !visited_types[tag]) {
|
if (tag < TAG_NUM_OF_ITEM_TYPES && !visited_types[tag]) {
|
||||||
|
bool result = false;
|
||||||
|
if (ApplyTagFallback(TagType(tag),
|
||||||
|
[&](TagType tag2) {
|
||||||
|
if (!visited_types[tag2])
|
||||||
|
return false;
|
||||||
|
|
||||||
|
for (const auto &item : _tag) {
|
||||||
|
if (item.type == tag2 &&
|
||||||
|
StringMatch(item.value)) {
|
||||||
|
result = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}))
|
||||||
|
return result;
|
||||||
|
|
||||||
/* If the search critieron was not visited during the
|
/* If the search critieron was not visited during the
|
||||||
sweep through the song's tag, it means this field
|
sweep through the song's tag, it means this field
|
||||||
is absent from the tag or empty. Thus, if the
|
is absent from the tag or empty. Thus, if the
|
||||||
@@ -115,15 +136,6 @@ SongFilter::Item::Match(const Tag &_tag) const noexcept
|
|||||||
true. */
|
true. */
|
||||||
if (value.empty())
|
if (value.empty())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (tag == TAG_ALBUM_ARTIST && visited_types[TAG_ARTIST]) {
|
|
||||||
/* if we're looking for "album artist", but
|
|
||||||
only "artist" exists, use that */
|
|
||||||
for (const auto &item : _tag)
|
|
||||||
if (item.type == TAG_ARTIST &&
|
|
||||||
StringMatch(item.value))
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
@@ -274,3 +286,33 @@ SongFilter::GetBase() const noexcept
|
|||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SongFilter
|
||||||
|
SongFilter::WithoutBasePrefix(const char *_prefix) const noexcept
|
||||||
|
{
|
||||||
|
const StringView prefix(_prefix);
|
||||||
|
SongFilter result;
|
||||||
|
|
||||||
|
for (const auto &i : items) {
|
||||||
|
if (i.GetTag() == LOCATE_TAG_BASE_TYPE) {
|
||||||
|
const char *s = StringAfterPrefix(i.GetValue(), prefix);
|
||||||
|
if (s != nullptr) {
|
||||||
|
if (*s == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (*s == '/') {
|
||||||
|
++s;
|
||||||
|
|
||||||
|
if (*s != 0)
|
||||||
|
result.items.emplace_back(LOCATE_TAG_BASE_TYPE, s);
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
result.items.emplace_back(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
@@ -21,9 +21,9 @@
|
|||||||
#define MPD_SONG_FILTER_HXX
|
#define MPD_SONG_FILTER_HXX
|
||||||
|
|
||||||
#include "lib/icu/Compare.hxx"
|
#include "lib/icu/Compare.hxx"
|
||||||
#include "util/AllocatedString.hxx"
|
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@@ -49,7 +49,7 @@ public:
|
|||||||
class Item {
|
class Item {
|
||||||
uint8_t tag;
|
uint8_t tag;
|
||||||
|
|
||||||
AllocatedString<> value;
|
std::string value;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This value is only set if case folding is enabled.
|
* This value is only set if case folding is enabled.
|
||||||
@@ -66,11 +66,6 @@ public:
|
|||||||
Item(unsigned tag, const char *value, bool fold_case=false);
|
Item(unsigned tag, const char *value, bool fold_case=false);
|
||||||
Item(unsigned tag, time_t time);
|
Item(unsigned tag, time_t time);
|
||||||
|
|
||||||
Item(const Item &other) = delete;
|
|
||||||
Item(Item &&) = default;
|
|
||||||
|
|
||||||
Item &operator=(const Item &other) = delete;
|
|
||||||
|
|
||||||
unsigned GetTag() const {
|
unsigned GetTag() const {
|
||||||
return tag;
|
return tag;
|
||||||
}
|
}
|
||||||
@@ -157,6 +152,13 @@ public:
|
|||||||
*/
|
*/
|
||||||
gcc_pure
|
gcc_pure
|
||||||
const char *GetBase() const noexcept;
|
const char *GetBase() const noexcept;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a copy of the filter with the given prefix stripped
|
||||||
|
* from all #LOCATE_TAG_BASE_TYPE items. This is used to
|
||||||
|
* filter songs in mounted databases.
|
||||||
|
*/
|
||||||
|
SongFilter WithoutBasePrefix(const char *prefix) const noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "tag/TagBuilder.hxx"
|
#include "tag/TagBuilder.hxx"
|
||||||
#include "util/StringUtil.hxx"
|
#include "util/StringUtil.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
|
#include "util/NumberParser.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -94,7 +95,7 @@ song_load(TextFile &file, const char *uri)
|
|||||||
if ((type = tag_name_parse(line)) != TAG_NUM_OF_ITEM_TYPES) {
|
if ((type = tag_name_parse(line)) != TAG_NUM_OF_ITEM_TYPES) {
|
||||||
tag.AddItem(type, value);
|
tag.AddItem(type, value);
|
||||||
} else if (strcmp(line, "Time") == 0) {
|
} else if (strcmp(line, "Time") == 0) {
|
||||||
tag.SetDuration(SignedSongTime::FromS(atof(value)));
|
tag.SetDuration(SignedSongTime::FromS(ParseDouble(value)));
|
||||||
} else if (strcmp(line, "Playlist") == 0) {
|
} else if (strcmp(line, "Playlist") == 0) {
|
||||||
tag.SetHasPlaylist(strcmp(value, "yes") == 0);
|
tag.SetHasPlaylist(strcmp(value, "yes") == 0);
|
||||||
} else if (strcmp(line, SONG_MTIME) == 0) {
|
} else if (strcmp(line, SONG_MTIME) == 0) {
|
||||||
|
46
src/android/LogListener.cxx
Normal file
46
src/android/LogListener.cxx
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* 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 "config.h"
|
||||||
|
#include "LogListener.hxx"
|
||||||
|
#include "java/Class.hxx"
|
||||||
|
#include "java/String.hxx"
|
||||||
|
#include "util/AllocatedString.hxx"
|
||||||
|
#include "util/FormatString.hxx"
|
||||||
|
|
||||||
|
void
|
||||||
|
LogListener::OnLog(JNIEnv *env, int priority, const char *fmt, ...) const
|
||||||
|
{
|
||||||
|
assert(env != nullptr);
|
||||||
|
|
||||||
|
Java::Class cls(env, env->GetObjectClass(Get()));
|
||||||
|
|
||||||
|
jmethodID method = env->GetMethodID(cls, "onLog",
|
||||||
|
"(ILjava/lang/String;)V");
|
||||||
|
|
||||||
|
assert(method);
|
||||||
|
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
const auto log = FormatStringV(fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
env->CallVoidMethod(Get(), method, priority,
|
||||||
|
Java::String(env, log.c_str()).Get());
|
||||||
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2003-2017 The Music Player Daemon Project
|
* Copyright 2003-2018 The Music Player Daemon Project
|
||||||
* http://www.musicpd.org
|
* http://www.musicpd.org
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@@ -17,8 +17,16 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "config.h"
|
#ifndef MPD_ANDROID_LOG_LISTENER_HXX
|
||||||
#include "Domain.hxx"
|
#define MPD_ANDROID_LOG_LISTENER_HXX
|
||||||
#include "util/Domain.hxx"
|
|
||||||
|
|
||||||
const Domain input_domain("input");
|
#include "java/Object.hxx"
|
||||||
|
|
||||||
|
class LogListener : public Java::Object {
|
||||||
|
public:
|
||||||
|
LogListener(JNIEnv *env, jobject obj):Java::Object(env, obj) {}
|
||||||
|
|
||||||
|
void OnLog(JNIEnv *env, int priority, const char *fmt, ...) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
@@ -162,7 +162,7 @@ Bzip2InputStream::FillBuffer()
|
|||||||
if (bzstream.avail_in > 0)
|
if (bzstream.avail_in > 0)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
size_t count = archive->istream->Read(buffer, sizeof(buffer));
|
size_t count = archive->istream->LockRead(buffer, sizeof(buffer));
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@@ -174,6 +174,8 @@ Bzip2InputStream::FillBuffer()
|
|||||||
size_t
|
size_t
|
||||||
Bzip2InputStream::Read(void *ptr, size_t length)
|
Bzip2InputStream::Read(void *ptr, size_t length)
|
||||||
{
|
{
|
||||||
|
const ScopeUnlock unlock(mutex);
|
||||||
|
|
||||||
int bz_result;
|
int bz_result;
|
||||||
size_t nbytes = 0;
|
size_t nbytes = 0;
|
||||||
|
|
||||||
@@ -224,4 +226,3 @@ const ArchivePlugin bz2_archive_plugin = {
|
|||||||
bz2_open,
|
bz2_open,
|
||||||
bz2_extensions,
|
bz2_extensions,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -115,7 +115,12 @@ Iso9660ArchiveFile::Visit(char *path, size_t length, size_t capacity,
|
|||||||
visitor.VisitArchiveEntry(path + 1);
|
visitor.VisitArchiveEntry(path + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if LIBCDIO_VERSION_NUM >= 20000
|
||||||
|
iso9660_filelist_free(entlist);
|
||||||
|
#else
|
||||||
_cdio_list_free (entlist, true);
|
_cdio_list_free (entlist, true);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static ArchiveFile *
|
static ArchiveFile *
|
||||||
@@ -182,6 +187,8 @@ Iso9660ArchiveFile::OpenStream(const char *pathname,
|
|||||||
size_t
|
size_t
|
||||||
Iso9660InputStream::Read(void *ptr, size_t read_size)
|
Iso9660InputStream::Read(void *ptr, size_t read_size)
|
||||||
{
|
{
|
||||||
|
const ScopeUnlock unlock(mutex);
|
||||||
|
|
||||||
int readed = 0;
|
int readed = 0;
|
||||||
int no_blocks, cur_block;
|
int no_blocks, cur_block;
|
||||||
size_t left_bytes = statbuf->size - offset;
|
size_t left_bytes = statbuf->size - offset;
|
||||||
|
@@ -138,6 +138,8 @@ ZzipArchiveFile::OpenStream(const char *pathname,
|
|||||||
size_t
|
size_t
|
||||||
ZzipInputStream::Read(void *ptr, size_t read_size)
|
ZzipInputStream::Read(void *ptr, size_t read_size)
|
||||||
{
|
{
|
||||||
|
const ScopeUnlock unlock(mutex);
|
||||||
|
|
||||||
int ret = zzip_file_read(file, ptr, read_size);
|
int ret = zzip_file_read(file, ptr, read_size);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
throw std::runtime_error("zzip_file_read() has failed");
|
throw std::runtime_error("zzip_file_read() has failed");
|
||||||
@@ -155,6 +157,8 @@ ZzipInputStream::IsEOF() noexcept
|
|||||||
void
|
void
|
||||||
ZzipInputStream::Seek(offset_type new_offset)
|
ZzipInputStream::Seek(offset_type new_offset)
|
||||||
{
|
{
|
||||||
|
const ScopeUnlock unlock(mutex);
|
||||||
|
|
||||||
zzip_off_t ofs = zzip_seek(file, new_offset, SEEK_SET);
|
zzip_off_t ofs = zzip_seek(file, new_offset, SEEK_SET);
|
||||||
if (ofs < 0)
|
if (ofs < 0)
|
||||||
throw std::runtime_error("zzip_seek() has failed");
|
throw std::runtime_error("zzip_seek() has failed");
|
||||||
|
@@ -123,6 +123,10 @@ ToAck(std::exception_ptr ep) noexcept
|
|||||||
return ACK_ERROR_SYSTEM;
|
return ACK_ERROR_SYSTEM;
|
||||||
} catch (const std::invalid_argument &e) {
|
} catch (const std::invalid_argument &e) {
|
||||||
return ACK_ERROR_ARG;
|
return ACK_ERROR_ARG;
|
||||||
|
} catch (const std::length_error &e) {
|
||||||
|
return ACK_ERROR_ARG;
|
||||||
|
} catch (const std::out_of_range &e) {
|
||||||
|
return ACK_ERROR_ARG;
|
||||||
#ifdef GLIBCXX_49X
|
#ifdef GLIBCXX_49X
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
#else
|
#else
|
||||||
|
@@ -191,7 +191,7 @@ handle_list(Client &client, Request args, Response &r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::unique_ptr<SongFilter> filter;
|
std::unique_ptr<SongFilter> filter;
|
||||||
tag_mask_t group_mask = 0;
|
TagType group = TAG_NUM_OF_ITEM_TYPES;
|
||||||
|
|
||||||
if (args.size == 1) {
|
if (args.size == 1) {
|
||||||
/* for compatibility with < 0.12.0 */
|
/* for compatibility with < 0.12.0 */
|
||||||
@@ -206,18 +206,16 @@ handle_list(Client &client, Request args, Response &r)
|
|||||||
args.shift()));
|
args.shift()));
|
||||||
}
|
}
|
||||||
|
|
||||||
while (args.size >= 2 &&
|
if (args.size >= 2 &&
|
||||||
StringIsEqual(args[args.size - 2], "group")) {
|
StringIsEqual(args[args.size - 2], "group")) {
|
||||||
const char *s = args[args.size - 1];
|
const char *s = args[args.size - 1];
|
||||||
TagType gt = tag_name_parse_i(s);
|
group = tag_name_parse_i(s);
|
||||||
if (gt == TAG_NUM_OF_ITEM_TYPES) {
|
if (group == TAG_NUM_OF_ITEM_TYPES) {
|
||||||
r.FormatError(ACK_ERROR_ARG,
|
r.FormatError(ACK_ERROR_ARG,
|
||||||
"Unknown tag type: %s", s);
|
"Unknown tag type: %s", s);
|
||||||
return CommandResult::ERROR;
|
return CommandResult::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
group_mask |= tag_mask_t(1) << unsigned(gt);
|
|
||||||
|
|
||||||
args.pop_back();
|
args.pop_back();
|
||||||
args.pop_back();
|
args.pop_back();
|
||||||
}
|
}
|
||||||
@@ -230,14 +228,13 @@ handle_list(Client &client, Request args, Response &r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tagType < TAG_NUM_OF_ITEM_TYPES &&
|
if (tagType < TAG_NUM_OF_ITEM_TYPES && tagType == group) {
|
||||||
group_mask & (tag_mask_t(1) << tagType)) {
|
|
||||||
r.Error(ACK_ERROR_ARG, "Conflicting group");
|
r.Error(ACK_ERROR_ARG, "Conflicting group");
|
||||||
return CommandResult::ERROR;
|
return CommandResult::ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrintUniqueTags(r, client.partition,
|
PrintUniqueTags(r, client.partition,
|
||||||
tagType, group_mask, filter.get());
|
tagType, group, filter.get());
|
||||||
return CommandResult::OK;
|
return CommandResult::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -25,6 +25,7 @@
|
|||||||
#include "client/Response.hxx"
|
#include "client/Response.hxx"
|
||||||
#include "LightSong.hxx"
|
#include "LightSong.hxx"
|
||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
|
#include "tag/VisitFallback.hxx"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <map>
|
#include <map>
|
||||||
@@ -72,24 +73,15 @@ stats_visitor_song(SearchStats &stats, const LightSong &song)
|
|||||||
stats.total_duration += duration;
|
stats.total_duration += duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static void
|
||||||
CollectGroupCounts(TagCountMap &map, TagType group, const Tag &tag)
|
CollectGroupCounts(TagCountMap &map, const Tag &tag,
|
||||||
|
const char *value) noexcept
|
||||||
{
|
{
|
||||||
bool found = false;
|
auto r = map.insert(std::make_pair(value, SearchStats()));
|
||||||
for (const auto &item : tag) {
|
SearchStats &s = r.first->second;
|
||||||
if (item.type == group) {
|
++s.n_songs;
|
||||||
auto r = map.insert(std::make_pair(item.value,
|
if (!tag.duration.IsNegative())
|
||||||
SearchStats()));
|
s.total_duration += tag.duration;
|
||||||
SearchStats &s = r.first->second;
|
|
||||||
++s.n_songs;
|
|
||||||
if (!tag.duration.IsNegative())
|
|
||||||
s.total_duration += tag.duration;
|
|
||||||
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return found;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -98,9 +90,10 @@ GroupCountVisitor(TagCountMap &map, TagType group, const LightSong &song)
|
|||||||
assert(song.tag != nullptr);
|
assert(song.tag != nullptr);
|
||||||
|
|
||||||
const Tag &tag = *song.tag;
|
const Tag &tag = *song.tag;
|
||||||
if (!CollectGroupCounts(map, group, tag) && group == TAG_ALBUM_ARTIST)
|
VisitTagWithFallbackOrEmpty(tag, group,
|
||||||
/* fall back to "Artist" if no "AlbumArtist" was found */
|
std::bind(CollectGroupCounts, std::ref(map),
|
||||||
CollectGroupCounts(map, TAG_ARTIST, tag);
|
std::cref(tag),
|
||||||
|
std::placeholders::_1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@@ -187,22 +187,34 @@ PrintSongURIVisitor(Response &r, Partition &partition, const LightSong &song)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
PrintUniqueTag(Response &r, TagType tag_type,
|
PrintUniqueTags(Response &r, TagType tag_type,
|
||||||
const Tag &tag)
|
const std::set<std::string> &values)
|
||||||
{
|
{
|
||||||
const char *value = tag.GetValue(tag_type);
|
const char *const name = tag_item_names[tag_type];
|
||||||
assert(value != nullptr);
|
for (const auto &i : values)
|
||||||
r.Format("%s: %s\n", tag_item_names[tag_type], value);
|
r.Format("%s: %s\n", name, i.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
for (const auto &item : tag)
|
static void
|
||||||
if (item.type != tag_type)
|
PrintGroupedUniqueTags(Response &r, TagType tag_type, TagType group,
|
||||||
r.Format("%s: %s\n",
|
const std::map<std::string, std::set<std::string>> &groups)
|
||||||
tag_item_names[item.type], item.value);
|
{
|
||||||
|
if (group == TAG_NUM_OF_ITEM_TYPES) {
|
||||||
|
for (const auto &i : groups)
|
||||||
|
PrintUniqueTags(r, tag_type, i.second);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *const group_name = tag_item_names[group];
|
||||||
|
for (const auto &i : groups) {
|
||||||
|
r.Format("%s: %s\n", group_name, i.first.c_str());
|
||||||
|
PrintUniqueTags(r, tag_type, i.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
PrintUniqueTags(Response &r, Partition &partition,
|
PrintUniqueTags(Response &r, Partition &partition,
|
||||||
unsigned type, tag_mask_t group_mask,
|
unsigned type, TagType group,
|
||||||
const SongFilter *filter)
|
const SongFilter *filter)
|
||||||
{
|
{
|
||||||
const Database &db = partition.GetDatabaseOrThrow();
|
const Database &db = partition.GetDatabaseOrThrow();
|
||||||
@@ -217,10 +229,9 @@ PrintUniqueTags(Response &r, Partition &partition,
|
|||||||
} else {
|
} else {
|
||||||
assert(type < TAG_NUM_OF_ITEM_TYPES);
|
assert(type < TAG_NUM_OF_ITEM_TYPES);
|
||||||
|
|
||||||
using namespace std::placeholders;
|
PrintGroupedUniqueTags(r, TagType(type), group,
|
||||||
const auto f = std::bind(PrintUniqueTag, std::ref(r),
|
db.CollectUniqueTags(selection,
|
||||||
(TagType)type, _1);
|
TagType(type),
|
||||||
db.VisitUniqueTags(selection, (TagType)type,
|
group));
|
||||||
group_mask, f);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -20,7 +20,7 @@
|
|||||||
#ifndef MPD_DB_PRINT_H
|
#ifndef MPD_DB_PRINT_H
|
||||||
#define MPD_DB_PRINT_H
|
#define MPD_DB_PRINT_H
|
||||||
|
|
||||||
#include "tag/Mask.hxx"
|
#include "tag/TagType.h"
|
||||||
|
|
||||||
class SongFilter;
|
class SongFilter;
|
||||||
struct DatabaseSelection;
|
struct DatabaseSelection;
|
||||||
@@ -44,7 +44,7 @@ db_selection_print(Response &r, Partition &partition,
|
|||||||
|
|
||||||
void
|
void
|
||||||
PrintUniqueTags(Response &r, Partition &partition,
|
PrintUniqueTags(Response &r, Partition &partition,
|
||||||
unsigned type, tag_mask_t group_mask,
|
unsigned type, TagType group,
|
||||||
const SongFilter *filter);
|
const SongFilter *filter);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -22,9 +22,12 @@
|
|||||||
|
|
||||||
#include "Visitor.hxx"
|
#include "Visitor.hxx"
|
||||||
#include "tag/TagType.h"
|
#include "tag/TagType.h"
|
||||||
#include "tag/Mask.hxx"
|
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
|
|
||||||
struct DatabasePlugin;
|
struct DatabasePlugin;
|
||||||
@@ -99,12 +102,9 @@ public:
|
|||||||
return Visit(selection, VisitDirectory(), visit_song);
|
return Visit(selection, VisitDirectory(), visit_song);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
virtual std::map<std::string, std::set<std::string>> CollectUniqueTags(const DatabaseSelection &selection,
|
||||||
* Visit all unique tag values.
|
TagType tag_type,
|
||||||
*/
|
TagType group=TAG_NUM_OF_ITEM_TYPES) const = 0;
|
||||||
virtual void VisitUniqueTags(const DatabaseSelection &selection,
|
|
||||||
TagType tag_type, tag_mask_t group_mask,
|
|
||||||
VisitTag visit_tag) const = 0;
|
|
||||||
|
|
||||||
virtual DatabaseStats GetStats(const DatabaseSelection &selection) const = 0;
|
virtual DatabaseStats GetStats(const DatabaseSelection &selection) const = 0;
|
||||||
|
|
||||||
|
@@ -20,34 +20,42 @@
|
|||||||
#include "UniqueTags.hxx"
|
#include "UniqueTags.hxx"
|
||||||
#include "Interface.hxx"
|
#include "Interface.hxx"
|
||||||
#include "LightSong.hxx"
|
#include "LightSong.hxx"
|
||||||
#include "tag/Set.hxx"
|
#include "tag/VisitFallback.hxx"
|
||||||
|
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
static void
|
static void
|
||||||
CollectTags(TagSet &set, TagType tag_type, tag_mask_t group_mask,
|
CollectTags(std::set<std::string> &result,
|
||||||
const LightSong &song)
|
const Tag &tag,
|
||||||
|
TagType tag_type) noexcept
|
||||||
{
|
{
|
||||||
assert(song.tag != nullptr);
|
VisitTagWithFallbackOrEmpty(tag, tag_type, [&result](const char *value){
|
||||||
const Tag &tag = *song.tag;
|
result.emplace(value);
|
||||||
|
});
|
||||||
set.InsertUnique(tag, tag_type, group_mask);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
static void
|
||||||
VisitUniqueTags(const Database &db, const DatabaseSelection &selection,
|
CollectGroupTags(std::map<std::string, std::set<std::string>> &result,
|
||||||
TagType tag_type, tag_mask_t group_mask,
|
const Tag &tag,
|
||||||
VisitTag visit_tag)
|
TagType tag_type,
|
||||||
|
TagType group) noexcept
|
||||||
{
|
{
|
||||||
TagSet set;
|
VisitTagWithFallbackOrEmpty(tag, group, [&](const char *group_name){
|
||||||
|
CollectTags(result[group_name], tag, tag_type);
|
||||||
using namespace std::placeholders;
|
});
|
||||||
const auto f = std::bind(CollectTags, std::ref(set),
|
}
|
||||||
tag_type, group_mask, _1);
|
|
||||||
db.Visit(selection, f);
|
std::map<std::string, std::set<std::string>>
|
||||||
|
CollectUniqueTags(const Database &db, const DatabaseSelection &selection,
|
||||||
for (const auto &value : set)
|
TagType tag_type, TagType group)
|
||||||
visit_tag(value);
|
{
|
||||||
|
std::map<std::string, std::set<std::string>> result;
|
||||||
|
|
||||||
|
db.Visit(selection, [&result, tag_type, group](const LightSong &song){
|
||||||
|
CollectGroupTags(result, *song.tag, tag_type, group);
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
@@ -20,16 +20,19 @@
|
|||||||
#ifndef MPD_DB_UNIQUE_TAGS_HXX
|
#ifndef MPD_DB_UNIQUE_TAGS_HXX
|
||||||
#define MPD_DB_UNIQUE_TAGS_HXX
|
#define MPD_DB_UNIQUE_TAGS_HXX
|
||||||
|
|
||||||
#include "Visitor.hxx"
|
|
||||||
#include "tag/TagType.h"
|
#include "tag/TagType.h"
|
||||||
#include "tag/Mask.hxx"
|
#include "Compiler.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <set>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
class Database;
|
class Database;
|
||||||
struct DatabaseSelection;
|
struct DatabaseSelection;
|
||||||
|
|
||||||
void
|
gcc_pure
|
||||||
VisitUniqueTags(const Database &db, const DatabaseSelection &selection,
|
std::map<std::string, std::set<std::string>>
|
||||||
TagType tag_type, tag_mask_t group_mask,
|
CollectUniqueTags(const Database &db, const DatabaseSelection &selection,
|
||||||
VisitTag visit_tag);
|
TagType tag_type, TagType group);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -82,6 +82,7 @@ class ProxyDatabase final : public Database, SocketMonitor, IdleMonitor {
|
|||||||
DatabaseListener &listener;
|
DatabaseListener &listener;
|
||||||
|
|
||||||
const std::string host;
|
const std::string host;
|
||||||
|
const std::string password;
|
||||||
const unsigned port;
|
const unsigned port;
|
||||||
const bool keepalive;
|
const bool keepalive;
|
||||||
|
|
||||||
@@ -119,9 +120,9 @@ public:
|
|||||||
VisitSong visit_song,
|
VisitSong visit_song,
|
||||||
VisitPlaylist visit_playlist) const override;
|
VisitPlaylist visit_playlist) const override;
|
||||||
|
|
||||||
void VisitUniqueTags(const DatabaseSelection &selection,
|
std::map<std::string, std::set<std::string>> CollectUniqueTags(const DatabaseSelection &selection,
|
||||||
TagType tag_type, tag_mask_t group_mask,
|
TagType tag_type,
|
||||||
VisitTag visit_tag) const override;
|
TagType group) const override;
|
||||||
|
|
||||||
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
|
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
|
||||||
|
|
||||||
@@ -169,6 +170,13 @@ static constexpr struct {
|
|||||||
#if LIBMPDCLIENT_CHECK_VERSION(2,10,0)
|
#if LIBMPDCLIENT_CHECK_VERSION(2,10,0)
|
||||||
{ TAG_MUSICBRAINZ_RELEASETRACKID,
|
{ TAG_MUSICBRAINZ_RELEASETRACKID,
|
||||||
MPD_TAG_MUSICBRAINZ_RELEASETRACKID },
|
MPD_TAG_MUSICBRAINZ_RELEASETRACKID },
|
||||||
|
#endif
|
||||||
|
#if LIBMPDCLIENT_CHECK_VERSION(2,11,0)
|
||||||
|
{ TAG_ARTIST_SORT, MPD_TAG_ARTIST_SORT },
|
||||||
|
{ TAG_ALBUM_ARTIST_SORT, MPD_TAG_ALBUM_ARTIST_SORT },
|
||||||
|
#endif
|
||||||
|
#if LIBMPDCLIENT_CHECK_VERSION(2,12,0)
|
||||||
|
{ TAG_ALBUM_SORT, MPD_TAG_ALBUM_SORT },
|
||||||
#endif
|
#endif
|
||||||
{ TAG_NUM_OF_ITEM_TYPES, MPD_TAG_COUNT }
|
{ TAG_NUM_OF_ITEM_TYPES, MPD_TAG_COUNT }
|
||||||
};
|
};
|
||||||
@@ -325,12 +333,32 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool
|
||||||
|
SendGroup(mpd_connection *connection, TagType group)
|
||||||
|
{
|
||||||
|
if (group == TAG_NUM_OF_ITEM_TYPES)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
#if LIBMPDCLIENT_CHECK_VERSION(2,12,0)
|
||||||
|
const auto tag = Convert(group);
|
||||||
|
if (tag == MPD_TAG_COUNT)
|
||||||
|
throw std::runtime_error("Unsupported tag");
|
||||||
|
|
||||||
|
return mpd_search_add_group_tag(connection, tag);
|
||||||
|
#else
|
||||||
|
(void)connection;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
ProxyDatabase::ProxyDatabase(EventLoop &_loop, DatabaseListener &_listener,
|
ProxyDatabase::ProxyDatabase(EventLoop &_loop, DatabaseListener &_listener,
|
||||||
const ConfigBlock &block)
|
const ConfigBlock &block)
|
||||||
:Database(proxy_db_plugin),
|
:Database(proxy_db_plugin),
|
||||||
SocketMonitor(_loop), IdleMonitor(_loop),
|
SocketMonitor(_loop), IdleMonitor(_loop),
|
||||||
listener(_listener),
|
listener(_listener),
|
||||||
host(block.GetBlockValue("host", "")),
|
host(block.GetBlockValue("host", "")),
|
||||||
|
password(block.GetBlockValue("password", "")),
|
||||||
port(block.GetBlockValue("port", 0u)),
|
port(block.GetBlockValue("port", 0u)),
|
||||||
keepalive(block.GetBlockValue("keepalive", false))
|
keepalive(block.GetBlockValue("keepalive", false))
|
||||||
{
|
{
|
||||||
@@ -374,6 +402,10 @@ ProxyDatabase::Connect()
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
CheckError(connection);
|
CheckError(connection);
|
||||||
|
|
||||||
|
if (!password.empty() &&
|
||||||
|
!mpd_run_password(connection, password.c_str()))
|
||||||
|
ThrowError(connection);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
mpd_connection_free(connection);
|
mpd_connection_free(connection);
|
||||||
connection = nullptr;
|
connection = nullptr;
|
||||||
@@ -682,7 +714,7 @@ static void
|
|||||||
SearchSongs(struct mpd_connection *connection,
|
SearchSongs(struct mpd_connection *connection,
|
||||||
const DatabaseSelection &selection,
|
const DatabaseSelection &selection,
|
||||||
VisitSong visit_song)
|
VisitSong visit_song)
|
||||||
{
|
try {
|
||||||
assert(selection.recursive);
|
assert(selection.recursive);
|
||||||
assert(visit_song);
|
assert(visit_song);
|
||||||
|
|
||||||
@@ -709,6 +741,11 @@ SearchSongs(struct mpd_connection *connection,
|
|||||||
|
|
||||||
if (!mpd_response_finish(connection))
|
if (!mpd_response_finish(connection))
|
||||||
ThrowError(connection);
|
ThrowError(connection);
|
||||||
|
} catch (...) {
|
||||||
|
if (connection != nullptr)
|
||||||
|
mpd_search_cancel(connection);
|
||||||
|
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -753,12 +790,10 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
|
|||||||
visit_directory, visit_song, visit_playlist);
|
visit_directory, visit_song, visit_playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
std::map<std::string, std::set<std::string>>
|
||||||
ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
|
ProxyDatabase::CollectUniqueTags(const DatabaseSelection &selection,
|
||||||
TagType tag_type,
|
TagType tag_type, TagType group) const
|
||||||
gcc_unused tag_mask_t group_mask,
|
try {
|
||||||
VisitTag visit_tag) const
|
|
||||||
{
|
|
||||||
// TODO: eliminate the const_cast
|
// TODO: eliminate the const_cast
|
||||||
const_cast<ProxyDatabase *>(this)->EnsureConnected();
|
const_cast<ProxyDatabase *>(this)->EnsureConnected();
|
||||||
|
|
||||||
@@ -767,40 +802,62 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
|
|||||||
throw std::runtime_error("Unsupported tag");
|
throw std::runtime_error("Unsupported tag");
|
||||||
|
|
||||||
if (!mpd_search_db_tags(connection, tag_type2) ||
|
if (!mpd_search_db_tags(connection, tag_type2) ||
|
||||||
!SendConstraints(connection, selection))
|
!SendConstraints(connection, selection) ||
|
||||||
|
!SendGroup(connection, group))
|
||||||
ThrowError(connection);
|
ThrowError(connection);
|
||||||
|
|
||||||
// TODO: use group_mask
|
|
||||||
|
|
||||||
if (!mpd_search_commit(connection))
|
if (!mpd_search_commit(connection))
|
||||||
ThrowError(connection);
|
ThrowError(connection);
|
||||||
|
|
||||||
while (auto *pair = mpd_recv_pair_tag(connection, tag_type2)) {
|
std::map<std::string, std::set<std::string>> result;
|
||||||
AtScopeExit(this, pair) {
|
|
||||||
mpd_return_pair(connection, pair);
|
|
||||||
};
|
|
||||||
|
|
||||||
TagBuilder tag;
|
if (group == TAG_NUM_OF_ITEM_TYPES) {
|
||||||
tag.AddItem(tag_type, pair->value);
|
auto &values = result[std::string()];
|
||||||
|
|
||||||
if (tag.IsEmpty())
|
while (auto *pair = mpd_recv_pair(connection)) {
|
||||||
/* if no tag item has been added, then the
|
AtScopeExit(this, pair) {
|
||||||
given value was not acceptable
|
mpd_return_pair(connection, pair);
|
||||||
(e.g. empty); forcefully insert an empty
|
};
|
||||||
tag in this case, as the caller expects the
|
|
||||||
given tag type to be present */
|
|
||||||
tag.AddEmptyItem(tag_type);
|
|
||||||
|
|
||||||
try {
|
const auto current_type = tag_name_parse_i(pair->name);
|
||||||
visit_tag(tag.Commit());
|
if (current_type == TAG_NUM_OF_ITEM_TYPES)
|
||||||
} catch (...) {
|
continue;
|
||||||
mpd_response_finish(connection);
|
|
||||||
throw;
|
if (current_type == tag_type)
|
||||||
|
values.emplace(pair->value);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
std::set<std::string> *current_group = nullptr;
|
||||||
|
|
||||||
|
while (auto *pair = mpd_recv_pair(connection)) {
|
||||||
|
AtScopeExit(this, pair) {
|
||||||
|
mpd_return_pair(connection, pair);
|
||||||
|
};
|
||||||
|
|
||||||
|
const auto current_type = tag_name_parse_i(pair->name);
|
||||||
|
if (current_type == TAG_NUM_OF_ITEM_TYPES)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (current_type == tag_type) {
|
||||||
|
if (current_group == nullptr)
|
||||||
|
current_group = &result[std::string()];
|
||||||
|
|
||||||
|
current_group->emplace(pair->value);
|
||||||
|
} else if (current_type == group) {
|
||||||
|
current_group = &result[pair->value];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mpd_response_finish(connection))
|
if (!mpd_response_finish(connection))
|
||||||
ThrowError(connection);
|
ThrowError(connection);
|
||||||
|
|
||||||
|
return result;
|
||||||
|
} catch (...) {
|
||||||
|
if (connection != nullptr)
|
||||||
|
mpd_search_cancel(connection);
|
||||||
|
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseStats
|
DatabaseStats
|
||||||
|
@@ -82,10 +82,11 @@ directory_save(BufferedOutputStream &os, const Directory &directory)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &child : directory.children) {
|
for (const auto &child : directory.children) {
|
||||||
os.Format(DIRECTORY_DIR "%s\n", child.GetName());
|
if (child.IsMount())
|
||||||
|
continue;
|
||||||
|
|
||||||
if (!child.IsMount())
|
os.Format(DIRECTORY_DIR "%s\n", child.GetName());
|
||||||
directory_save(os, child);
|
directory_save(os, child);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto &song : directory.songs)
|
for (const auto &song : directory.songs)
|
||||||
|
@@ -20,18 +20,12 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "Mount.hxx"
|
#include "Mount.hxx"
|
||||||
#include "PrefixedLightSong.hxx"
|
#include "PrefixedLightSong.hxx"
|
||||||
|
#include "SongFilter.hxx"
|
||||||
#include "db/Selection.hxx"
|
#include "db/Selection.hxx"
|
||||||
#include "db/LightDirectory.hxx"
|
#include "db/LightDirectory.hxx"
|
||||||
#include "db/Interface.hxx"
|
#include "db/Interface.hxx"
|
||||||
#include "fs/Traits.hxx"
|
#include "fs/Traits.hxx"
|
||||||
|
|
||||||
#ifdef _LIBCPP_VERSION
|
|
||||||
/* workaround for "error: incomplete type 'PlaylistInfo' used in type
|
|
||||||
trait expression" with libc++ version 3900 (from Android NDK
|
|
||||||
r13b) */
|
|
||||||
#include "db/PlaylistInfo.hxx"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct PrefixedLightDirectory : LightDirectory {
|
struct PrefixedLightDirectory : LightDirectory {
|
||||||
@@ -93,5 +87,16 @@ WalkMount(const char *base, const Database &db,
|
|||||||
vp = std::bind(PrefixVisitPlaylist,
|
vp = std::bind(PrefixVisitPlaylist,
|
||||||
base, std::ref(visit_playlist), _1, _2);
|
base, std::ref(visit_playlist), _1, _2);
|
||||||
|
|
||||||
|
SongFilter prefix_filter;
|
||||||
|
|
||||||
|
if (base != nullptr && filter != nullptr) {
|
||||||
|
/* if the SongFilter contains a LOCATE_TAG_BASE_TYPE
|
||||||
|
item, copy the SongFilter and drop the mount point
|
||||||
|
from the filter, because the mounted database
|
||||||
|
doesn't know its own location within MPD's VFS */
|
||||||
|
prefix_filter = filter->WithoutBasePrefix(base);
|
||||||
|
filter = &prefix_filter;
|
||||||
|
}
|
||||||
|
|
||||||
db.Visit(DatabaseSelection(uri, recursive, filter), vd, vs, vp);
|
db.Visit(DatabaseSelection(uri, recursive, filter), vd, vs, vp);
|
||||||
}
|
}
|
||||||
|
@@ -312,12 +312,11 @@ SimpleDatabase::Visit(const DatabaseSelection &selection,
|
|||||||
"No such directory");
|
"No such directory");
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
std::map<std::string, std::set<std::string>>
|
||||||
SimpleDatabase::VisitUniqueTags(const DatabaseSelection &selection,
|
SimpleDatabase::CollectUniqueTags(const DatabaseSelection &selection,
|
||||||
TagType tag_type, tag_mask_t group_mask,
|
TagType tag_type, TagType group) const
|
||||||
VisitTag visit_tag) const
|
|
||||||
{
|
{
|
||||||
::VisitUniqueTags(*this, selection, tag_type, group_mask, visit_tag);
|
return ::CollectUniqueTags(*this, selection, tag_type, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseStats
|
DatabaseStats
|
||||||
|
@@ -119,9 +119,9 @@ public:
|
|||||||
VisitSong visit_song,
|
VisitSong visit_song,
|
||||||
VisitPlaylist visit_playlist) const override;
|
VisitPlaylist visit_playlist) const override;
|
||||||
|
|
||||||
void VisitUniqueTags(const DatabaseSelection &selection,
|
std::map<std::string, std::set<std::string>> CollectUniqueTags(const DatabaseSelection &selection,
|
||||||
TagType tag_type, tag_mask_t group_mask,
|
TagType tag_type,
|
||||||
VisitTag visit_tag) const override;
|
TagType group) const override;
|
||||||
|
|
||||||
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
|
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
|
||||||
|
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
#include "util/ScopeExit.hxx"
|
#include "util/ScopeExit.hxx"
|
||||||
|
#include "util/StringFormat.hxx"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -47,10 +48,6 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl,
|
|||||||
unsigned &didreadp,
|
unsigned &didreadp,
|
||||||
unsigned &totalp) const
|
unsigned &totalp) const
|
||||||
{
|
{
|
||||||
// Create request
|
|
||||||
char ofbuf[100], cntbuf[100];
|
|
||||||
sprintf(ofbuf, "%u", offset);
|
|
||||||
sprintf(cntbuf, "%u", count);
|
|
||||||
// Some devices require an empty SortCriteria, else bad params
|
// Some devices require an empty SortCriteria, else bad params
|
||||||
IXML_Document *request =
|
IXML_Document *request =
|
||||||
MakeActionHelper("Browse", m_serviceType.c_str(),
|
MakeActionHelper("Browse", m_serviceType.c_str(),
|
||||||
@@ -58,8 +55,10 @@ ContentDirectoryService::readDirSlice(UpnpClient_Handle hdl,
|
|||||||
"BrowseFlag", "BrowseDirectChildren",
|
"BrowseFlag", "BrowseDirectChildren",
|
||||||
"Filter", "*",
|
"Filter", "*",
|
||||||
"SortCriteria", "",
|
"SortCriteria", "",
|
||||||
"StartingIndex", ofbuf,
|
"StartingIndex",
|
||||||
"RequestedCount", cntbuf);
|
StringFormat<32>("%u", offset).c_str(),
|
||||||
|
"RequestedCount",
|
||||||
|
StringFormat<32>("%u", count).c_str());
|
||||||
if (request == nullptr)
|
if (request == nullptr)
|
||||||
throw std::runtime_error("UpnpMakeAction() failed");
|
throw std::runtime_error("UpnpMakeAction() failed");
|
||||||
|
|
||||||
@@ -112,15 +111,13 @@ ContentDirectoryService::search(UpnpClient_Handle hdl,
|
|||||||
unsigned offset = 0, total = -1, count;
|
unsigned offset = 0, total = -1, count;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
char ofbuf[100];
|
|
||||||
sprintf(ofbuf, "%d", offset);
|
|
||||||
|
|
||||||
UniqueIxmlDocument request(MakeActionHelper("Search", m_serviceType.c_str(),
|
UniqueIxmlDocument request(MakeActionHelper("Search", m_serviceType.c_str(),
|
||||||
"ContainerID", objectId,
|
"ContainerID", objectId,
|
||||||
"SearchCriteria", ss,
|
"SearchCriteria", ss,
|
||||||
"Filter", "*",
|
"Filter", "*",
|
||||||
"SortCriteria", "",
|
"SortCriteria", "",
|
||||||
"StartingIndex", ofbuf,
|
"StartingIndex",
|
||||||
|
StringFormat<32>("%u", offset).c_str(),
|
||||||
"RequestedCount", "0")); // Setting a value here gets twonky into fits
|
"RequestedCount", "0")); // Setting a value here gets twonky into fits
|
||||||
if (!request)
|
if (!request)
|
||||||
throw std::runtime_error("UpnpMakeAction() failed");
|
throw std::runtime_error("UpnpMakeAction() failed");
|
||||||
|
@@ -87,9 +87,9 @@ public:
|
|||||||
VisitSong visit_song,
|
VisitSong visit_song,
|
||||||
VisitPlaylist visit_playlist) const override;
|
VisitPlaylist visit_playlist) const override;
|
||||||
|
|
||||||
void VisitUniqueTags(const DatabaseSelection &selection,
|
std::map<std::string, std::set<std::string>> CollectUniqueTags(const DatabaseSelection &selection,
|
||||||
TagType tag_type, tag_mask_t group_mask,
|
TagType tag_type,
|
||||||
VisitTag visit_tag) const override;
|
TagType group) const override;
|
||||||
|
|
||||||
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
|
DatabaseStats GetStats(const DatabaseSelection &selection) const override;
|
||||||
|
|
||||||
@@ -603,17 +603,15 @@ UpnpDatabase::Visit(const DatabaseSelection &selection,
|
|||||||
visit_directory, visit_song, visit_playlist);
|
visit_directory, visit_song, visit_playlist);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
std::map<std::string, std::set<std::string>>
|
||||||
UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection,
|
UpnpDatabase::CollectUniqueTags(const DatabaseSelection &selection,
|
||||||
TagType tag, gcc_unused tag_mask_t group_mask,
|
TagType tag, TagType group) const
|
||||||
VisitTag visit_tag) const
|
|
||||||
{
|
{
|
||||||
// TODO: use group_mask
|
(void)group; // TODO: use group
|
||||||
|
|
||||||
if (!visit_tag)
|
std::map<std::string, std::set<std::string>> result;
|
||||||
return;
|
auto &values = result[std::string()];
|
||||||
|
|
||||||
std::set<std::string> values;
|
|
||||||
for (auto& server : discovery->GetDirectories()) {
|
for (auto& server : discovery->GetDirectories()) {
|
||||||
const auto dirbuf = SearchSongs(server, rootid, selection);
|
const auto dirbuf = SearchSongs(server, rootid, selection);
|
||||||
|
|
||||||
@@ -633,11 +631,7 @@ UpnpDatabase::VisitUniqueTags(const DatabaseSelection &selection,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const auto& value : values) {
|
return result;
|
||||||
TagBuilder builder;
|
|
||||||
builder.AddItem(tag, value.c_str());
|
|
||||||
visit_tag(builder.Commit());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
DatabaseStats
|
DatabaseStats
|
||||||
|
@@ -26,8 +26,8 @@
|
|||||||
#include "ExcludeList.hxx"
|
#include "ExcludeList.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "fs/NarrowPath.hxx"
|
#include "fs/NarrowPath.hxx"
|
||||||
#include "fs/io/TextFile.hxx"
|
#include "input/TextInputStream.hxx"
|
||||||
#include "system/Error.hxx"
|
#include "util/StringUtil.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -35,35 +35,29 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
inline void
|
||||||
|
ExcludeList::ParseLine(char *line) noexcept
|
||||||
|
{
|
||||||
|
char *p = Strip(line);
|
||||||
|
if (*p != 0 && *p != '#')
|
||||||
|
patterns.emplace_front(p);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ExcludeList::LoadFile(Path path_fs) noexcept
|
ExcludeList::Load(InputStreamPtr is)
|
||||||
try {
|
{
|
||||||
#ifdef HAVE_CLASS_GLOB
|
#ifdef HAVE_CLASS_GLOB
|
||||||
TextFile file(path_fs);
|
TextInputStream tis(std::move(is));
|
||||||
|
|
||||||
char *line;
|
char *line;
|
||||||
while ((line = file.ReadLine()) != nullptr) {
|
while ((line = tis.ReadLine()) != nullptr)
|
||||||
char *p = strchr(line, '#');
|
ParseLine(line);
|
||||||
if (p != nullptr)
|
|
||||||
*p = 0;
|
|
||||||
|
|
||||||
p = Strip(line);
|
|
||||||
if (*p != 0)
|
|
||||||
patterns.emplace_front(p);
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
/* not implemented */
|
/* not implemented */
|
||||||
(void)path_fs;
|
(void)path_fs;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} catch (const std::system_error &e) {
|
|
||||||
if (!IsFileNotFound(e))
|
|
||||||
LogError(e);
|
|
||||||
return false;
|
|
||||||
} catch (const std::exception &e) {
|
|
||||||
LogError(e);
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@@ -28,6 +28,7 @@
|
|||||||
#include "check.h"
|
#include "check.h"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
#include "fs/Glob.hxx"
|
#include "fs/Glob.hxx"
|
||||||
|
#include "input/Ptr.hxx"
|
||||||
|
|
||||||
#ifdef HAVE_CLASS_GLOB
|
#ifdef HAVE_CLASS_GLOB
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
@@ -62,13 +63,16 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Loads and parses a .mpdignore file.
|
* Loads and parses a .mpdignore file.
|
||||||
*/
|
*/
|
||||||
bool LoadFile(Path path_fs) noexcept;
|
bool Load(InputStreamPtr is);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks whether one of the patterns in the .mpdignore file matches
|
* Checks whether one of the patterns in the .mpdignore file matches
|
||||||
* the specified file name.
|
* the specified file name.
|
||||||
*/
|
*/
|
||||||
bool Check(Path name_fs) const noexcept;
|
bool Check(Path name_fs) const noexcept;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void ParseLine(char *line) noexcept;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -49,6 +49,10 @@ struct UpdateQueueItem {
|
|||||||
bool IsDefined() const {
|
bool IsDefined() const {
|
||||||
return id != 0;
|
return id != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Clear() {
|
||||||
|
id = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class UpdateQueue {
|
class UpdateQueue {
|
||||||
|
@@ -29,6 +29,7 @@
|
|||||||
#include "Idle.hxx"
|
#include "Idle.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
#include "thread/Thread.hxx"
|
#include "thread/Thread.hxx"
|
||||||
|
#include "thread/Name.hxx"
|
||||||
#include "thread/Util.hxx"
|
#include "thread/Util.hxx"
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
@@ -43,6 +44,7 @@ UpdateService::UpdateService(EventLoop &_loop, SimpleDatabase &_db,
|
|||||||
:DeferredMonitor(_loop),
|
:DeferredMonitor(_loop),
|
||||||
db(_db), storage(_storage),
|
db(_db), storage(_storage),
|
||||||
listener(_listener),
|
listener(_listener),
|
||||||
|
update_thread(BIND_THIS_METHOD(Task)),
|
||||||
update_task_id(0),
|
update_task_id(0),
|
||||||
walk(nullptr)
|
walk(nullptr)
|
||||||
{
|
{
|
||||||
@@ -112,6 +114,8 @@ UpdateService::Task()
|
|||||||
{
|
{
|
||||||
assert(walk != nullptr);
|
assert(walk != nullptr);
|
||||||
|
|
||||||
|
SetThreadName("update");
|
||||||
|
|
||||||
if (!next.path_utf8.empty())
|
if (!next.path_utf8.empty())
|
||||||
FormatDebug(update_domain, "starting: %s",
|
FormatDebug(update_domain, "starting: %s",
|
||||||
next.path_utf8.c_str());
|
next.path_utf8.c_str());
|
||||||
@@ -140,13 +144,6 @@ UpdateService::Task()
|
|||||||
DeferredMonitor::Schedule();
|
DeferredMonitor::Schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
UpdateService::Task(void *ctx)
|
|
||||||
{
|
|
||||||
UpdateService &service = *(UpdateService *)ctx;
|
|
||||||
return service.Task();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
UpdateService::StartThread(UpdateQueueItem &&i)
|
UpdateService::StartThread(UpdateQueueItem &&i)
|
||||||
{
|
{
|
||||||
@@ -158,7 +155,7 @@ UpdateService::StartThread(UpdateQueueItem &&i)
|
|||||||
next = std::move(i);
|
next = std::move(i);
|
||||||
walk = new UpdateWalk(GetEventLoop(), listener, *next.storage);
|
walk = new UpdateWalk(GetEventLoop(), listener, *next.storage);
|
||||||
|
|
||||||
update_thread.Start(Task, this);
|
update_thread.Start();
|
||||||
|
|
||||||
FormatDebug(update_domain,
|
FormatDebug(update_domain,
|
||||||
"spawned thread for update job id %i", next.id);
|
"spawned thread for update job id %i", next.id);
|
||||||
@@ -258,7 +255,7 @@ UpdateService::RunDeferred()
|
|||||||
delete walk;
|
delete walk;
|
||||||
walk = nullptr;
|
walk = nullptr;
|
||||||
|
|
||||||
next = UpdateQueueItem();
|
next.Clear();
|
||||||
|
|
||||||
idle_add(IDLE_UPDATE);
|
idle_add(IDLE_UPDATE);
|
||||||
|
|
||||||
|
@@ -98,7 +98,6 @@ private:
|
|||||||
|
|
||||||
/* the update thread */
|
/* the update thread */
|
||||||
void Task();
|
void Task();
|
||||||
static void Task(void *ctx);
|
|
||||||
|
|
||||||
void StartThread(UpdateQueueItem &&i);
|
void StartThread(UpdateQueueItem &&i);
|
||||||
|
|
||||||
|
@@ -36,6 +36,9 @@
|
|||||||
#include "fs/Traits.hxx"
|
#include "fs/Traits.hxx"
|
||||||
#include "fs/FileSystem.hxx"
|
#include "fs/FileSystem.hxx"
|
||||||
#include "storage/FileInfo.hxx"
|
#include "storage/FileInfo.hxx"
|
||||||
|
#include "input/InputStream.hxx"
|
||||||
|
#include "input/Error.hxx"
|
||||||
|
#include "thread/Cond.hxx"
|
||||||
#include "util/Alloc.hxx"
|
#include "util/Alloc.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
@@ -345,11 +348,16 @@ UpdateWalk::UpdateDirectory(Directory &directory,
|
|||||||
|
|
||||||
ExcludeList child_exclude_list(exclude_list);
|
ExcludeList child_exclude_list(exclude_list);
|
||||||
|
|
||||||
{
|
try {
|
||||||
const auto exclude_path_fs =
|
Mutex mutex;
|
||||||
storage.MapChildFS(directory.GetPath(), ".mpdignore");
|
Cond cond;
|
||||||
if (!exclude_path_fs.IsNull())
|
auto is = InputStream::OpenReady(PathTraitsUTF8::Build(storage.MapUTF8(directory.GetPath()).c_str(),
|
||||||
child_exclude_list.LoadFile(exclude_path_fs);
|
".mpdignore").c_str(),
|
||||||
|
mutex, cond);
|
||||||
|
child_exclude_list.Load(std::move(is));
|
||||||
|
} catch (...) {
|
||||||
|
if (!IsFileNotFound(std::current_exception()))
|
||||||
|
LogError(std::current_exception());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!child_exclude_list.IsEmpty())
|
if (!child_exclude_list.IsEmpty())
|
||||||
|
@@ -300,6 +300,7 @@ DecoderBridge::CommandFinished()
|
|||||||
|
|
||||||
initial_seek_running = false;
|
initial_seek_running = false;
|
||||||
timestamp = dc.start_time.ToDoubleS();
|
timestamp = dc.start_time.ToDoubleS();
|
||||||
|
absolute_frame = dc.start_time.ToScale<uint64_t>(dc.in_audio_format.sample_rate);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,6 +320,7 @@ DecoderBridge::CommandFinished()
|
|||||||
convert->Reset();
|
convert->Reset();
|
||||||
|
|
||||||
timestamp = dc.seek_time.ToDoubleS();
|
timestamp = dc.seek_time.ToDoubleS();
|
||||||
|
absolute_frame = dc.seek_time.ToScale<uint64_t>(dc.in_audio_format.sample_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
dc.command = DecoderCommand::NONE;
|
dc.command = DecoderCommand::NONE;
|
||||||
@@ -427,6 +429,7 @@ DecoderBridge::SubmitTimestamp(double t)
|
|||||||
assert(t >= 0);
|
assert(t >= 0);
|
||||||
|
|
||||||
timestamp = t;
|
timestamp = t;
|
||||||
|
absolute_frame = uint64_t(t * dc.in_audio_format.sample_rate);
|
||||||
}
|
}
|
||||||
|
|
||||||
DecoderCommand
|
DecoderCommand
|
||||||
@@ -464,6 +467,29 @@ DecoderBridge::SubmitData(InputStream *is,
|
|||||||
return cmd;
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmd = DecoderCommand::NONE;
|
||||||
|
|
||||||
|
const size_t frame_size = dc.in_audio_format.GetFrameSize();
|
||||||
|
size_t data_frames = length / frame_size;
|
||||||
|
|
||||||
|
if (dc.end_time.IsPositive()) {
|
||||||
|
/* enforce the given end time */
|
||||||
|
|
||||||
|
const uint64_t end_frame =
|
||||||
|
dc.end_time.ToScale<uint64_t>(dc.in_audio_format.sample_rate);
|
||||||
|
if (absolute_frame >= end_frame)
|
||||||
|
return DecoderCommand::STOP;
|
||||||
|
|
||||||
|
const uint64_t remaining_frames = end_frame - absolute_frame;
|
||||||
|
if (data_frames >= remaining_frames) {
|
||||||
|
/* past the end of the range: truncate this
|
||||||
|
data submission and stop the decoder */
|
||||||
|
data_frames = remaining_frames;
|
||||||
|
length = data_frames * frame_size;
|
||||||
|
cmd = DecoderCommand::STOP;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (convert != nullptr) {
|
if (convert != nullptr) {
|
||||||
assert(dc.in_audio_format != dc.out_audio_format);
|
assert(dc.in_audio_format != dc.out_audio_format);
|
||||||
|
|
||||||
@@ -521,15 +547,11 @@ DecoderBridge::SubmitData(InputStream *is,
|
|||||||
|
|
||||||
timestamp += (double)nbytes /
|
timestamp += (double)nbytes /
|
||||||
dc.out_audio_format.GetTimeToSize();
|
dc.out_audio_format.GetTimeToSize();
|
||||||
|
|
||||||
if (dc.end_time.IsPositive() &&
|
|
||||||
timestamp >= dc.end_time.ToDoubleS())
|
|
||||||
/* the end of this range has been reached:
|
|
||||||
stop decoding */
|
|
||||||
return DecoderCommand::STOP;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DecoderCommand::NONE;
|
absolute_frame += data_frames;
|
||||||
|
|
||||||
|
return cmd;
|
||||||
}
|
}
|
||||||
|
|
||||||
DecoderCommand
|
DecoderCommand
|
||||||
|
@@ -49,6 +49,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
double timestamp = 0;
|
double timestamp = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The time stamp of the next data chunk, in PCM frames.
|
||||||
|
*/
|
||||||
|
uint64_t absolute_frame = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the initial seek (to the start position of the sub-song)
|
* Is the initial seek (to the start position of the sub-song)
|
||||||
* pending, or has it been performed already?
|
* pending, or has it been performed already?
|
||||||
|
@@ -30,7 +30,8 @@
|
|||||||
DecoderControl::DecoderControl(Mutex &_mutex, Cond &_client_cond,
|
DecoderControl::DecoderControl(Mutex &_mutex, Cond &_client_cond,
|
||||||
const AudioFormat _configured_audio_format,
|
const AudioFormat _configured_audio_format,
|
||||||
const ReplayGainConfig &_replay_gain_config)
|
const ReplayGainConfig &_replay_gain_config)
|
||||||
:mutex(_mutex), client_cond(_client_cond),
|
:thread(BIND_THIS_METHOD(RunThread)),
|
||||||
|
mutex(_mutex), client_cond(_client_cond),
|
||||||
configured_audio_format(_configured_audio_format),
|
configured_audio_format(_configured_audio_format),
|
||||||
replay_gain_config(_replay_gain_config) {}
|
replay_gain_config(_replay_gain_config) {}
|
||||||
|
|
||||||
|
@@ -308,9 +308,14 @@ struct DecoderControl {
|
|||||||
bool IsCurrentSong(const DetachedSong &_song) const noexcept;
|
bool IsCurrentSong(const DetachedSong &_song) const noexcept;
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool LockIsCurrentSong(const DetachedSong &_song) const noexcept {
|
bool IsSeekableCurrentSong(const DetachedSong &_song) const noexcept {
|
||||||
|
return seekable && IsCurrentSong(_song);
|
||||||
|
}
|
||||||
|
|
||||||
|
gcc_pure
|
||||||
|
bool LockIsSeeakbleCurrentSong(const DetachedSong &_song) const noexcept {
|
||||||
const std::lock_guard<Mutex> protect(mutex);
|
const std::lock_guard<Mutex> protect(mutex);
|
||||||
return IsCurrentSong(_song);
|
return IsSeekableCurrentSong(_song);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -415,6 +420,9 @@ public:
|
|||||||
* mixramp_start/mixramp_end.
|
* mixramp_start/mixramp_end.
|
||||||
*/
|
*/
|
||||||
void CycleMixRamp();
|
void CycleMixRamp();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void RunThread();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -513,30 +513,28 @@ try {
|
|||||||
dc.client_cond.signal();
|
dc.client_cond.signal();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
decoder_task(void *arg)
|
DecoderControl::RunThread()
|
||||||
{
|
{
|
||||||
DecoderControl &dc = *(DecoderControl *)arg;
|
|
||||||
|
|
||||||
SetThreadName("decoder");
|
SetThreadName("decoder");
|
||||||
|
|
||||||
const std::lock_guard<Mutex> protect(dc.mutex);
|
const std::lock_guard<Mutex> protect(mutex);
|
||||||
|
|
||||||
do {
|
do {
|
||||||
assert(dc.state == DecoderState::STOP ||
|
assert(state == DecoderState::STOP ||
|
||||||
dc.state == DecoderState::ERROR);
|
state == DecoderState::ERROR);
|
||||||
|
|
||||||
switch (dc.command) {
|
switch (command) {
|
||||||
case DecoderCommand::START:
|
case DecoderCommand::START:
|
||||||
dc.CycleMixRamp();
|
CycleMixRamp();
|
||||||
dc.replay_gain_prev_db = dc.replay_gain_db;
|
replay_gain_prev_db = replay_gain_db;
|
||||||
dc.replay_gain_db = 0;
|
replay_gain_db = 0;
|
||||||
|
|
||||||
decoder_run(dc);
|
decoder_run(*this);
|
||||||
|
|
||||||
if (dc.state == DecoderState::ERROR) {
|
if (state == DecoderState::ERROR) {
|
||||||
try {
|
try {
|
||||||
std::rethrow_exception(dc.error);
|
std::rethrow_exception(error);
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
LogError(e);
|
LogError(e);
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
@@ -552,20 +550,20 @@ decoder_task(void *arg)
|
|||||||
/* we need to clear the pipe here; usually the
|
/* we need to clear the pipe here; usually the
|
||||||
PlayerThread is responsible, but it is not
|
PlayerThread is responsible, but it is not
|
||||||
aware that the decoder has finished */
|
aware that the decoder has finished */
|
||||||
dc.pipe->Clear(*dc.buffer);
|
pipe->Clear(*buffer);
|
||||||
|
|
||||||
decoder_run(dc);
|
decoder_run(*this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DecoderCommand::STOP:
|
case DecoderCommand::STOP:
|
||||||
dc.CommandFinishedLocked();
|
CommandFinishedLocked();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DecoderCommand::NONE:
|
case DecoderCommand::NONE:
|
||||||
dc.Wait();
|
Wait();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} while (dc.command != DecoderCommand::NONE || !dc.quit);
|
} while (command != DecoderCommand::NONE || !quit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -574,5 +572,5 @@ decoder_thread_start(DecoderControl &dc)
|
|||||||
assert(!dc.thread.IsDefined());
|
assert(!dc.thread.IsDefined());
|
||||||
|
|
||||||
dc.quit = false;
|
dc.quit = false;
|
||||||
dc.thread.Start(decoder_task, &dc);
|
dc.thread.Start();
|
||||||
}
|
}
|
||||||
|
@@ -128,7 +128,7 @@ dsdlib_tag_id3(InputStream &is,
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
const auto count64 = size - tagoffset;
|
const auto count64 = size - tagoffset;
|
||||||
if (count64 < 10 || count64 > 1024 * 1024)
|
if (count64 < 10 || count64 > 4 * 1024 * 1024)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!dsdlib_skip_to(nullptr, is, tagoffset))
|
if (!dsdlib_skip_to(nullptr, is, tagoffset))
|
||||||
|
@@ -484,6 +484,8 @@ static const char *const dsdiff_suffixes[] = {
|
|||||||
|
|
||||||
static const char *const dsdiff_mime_types[] = {
|
static const char *const dsdiff_mime_types[] = {
|
||||||
"application/x-dff",
|
"application/x-dff",
|
||||||
|
"audio/x-dff",
|
||||||
|
"audio/x-dsd",
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -358,6 +358,8 @@ static const char *const dsf_suffixes[] = {
|
|||||||
|
|
||||||
static const char *const dsf_mime_types[] = {
|
static const char *const dsf_mime_types[] = {
|
||||||
"application/x-dsf",
|
"application/x-dsf",
|
||||||
|
"audio/x-dsf",
|
||||||
|
"audio/x-dsd",
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -24,7 +24,6 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "FlacCommon.hxx"
|
#include "FlacCommon.hxx"
|
||||||
#include "FlacMetadata.hxx"
|
#include "FlacMetadata.hxx"
|
||||||
#include "util/ConstBuffer.hxx"
|
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
@@ -143,25 +142,10 @@ FlacDecoder::OnWrite(const FLAC__Frame &frame,
|
|||||||
if (!initialized && !OnFirstFrame(frame.header))
|
if (!initialized && !OnFirstFrame(frame.header))
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
||||||
|
|
||||||
const auto data = pcm_import.Import(buf, frame.header.blocksize);
|
chunk = pcm_import.Import(buf, frame.header.blocksize);
|
||||||
|
|
||||||
unsigned bit_rate = nbytes * 8 * frame.header.sample_rate /
|
kbit_rate = nbytes * 8 * frame.header.sample_rate /
|
||||||
(1000 * frame.header.blocksize);
|
(1000 * frame.header.blocksize);
|
||||||
|
|
||||||
auto cmd = GetClient()->SubmitData(GetInputStream(),
|
|
||||||
data.data, data.size,
|
|
||||||
bit_rate);
|
|
||||||
switch (cmd) {
|
|
||||||
case DecoderCommand::NONE:
|
|
||||||
case DecoderCommand::START:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case DecoderCommand::STOP:
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_ABORT;
|
|
||||||
|
|
||||||
case DecoderCommand::SEEK:
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
return FLAC__STREAM_DECODER_WRITE_STATUS_CONTINUE;
|
||||||
}
|
}
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include "FlacInput.hxx"
|
#include "FlacInput.hxx"
|
||||||
#include "FlacPcm.hxx"
|
#include "FlacPcm.hxx"
|
||||||
#include "../DecoderAPI.hxx"
|
#include "../DecoderAPI.hxx"
|
||||||
|
#include "util/ConstBuffer.hxx"
|
||||||
|
|
||||||
#include <FLAC/stream_decoder.h>
|
#include <FLAC/stream_decoder.h>
|
||||||
|
|
||||||
@@ -41,6 +42,12 @@ struct FlacDecoder : public FlacInput {
|
|||||||
*/
|
*/
|
||||||
bool unsupported = false;
|
bool unsupported = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The kbit_rate parameter for the next
|
||||||
|
* DecoderBridge::SubmitData() call.
|
||||||
|
*/
|
||||||
|
uint16_t kbit_rate;
|
||||||
|
|
||||||
FlacPcmImport pcm_import;
|
FlacPcmImport pcm_import;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,6 +58,13 @@ struct FlacDecoder : public FlacInput {
|
|||||||
|
|
||||||
Tag tag;
|
Tag tag;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decoded PCM data obtained by our libFLAC write callback.
|
||||||
|
* If this is non-empty, then DecoderBridge::SubmitData()
|
||||||
|
* should be called.
|
||||||
|
*/
|
||||||
|
ConstBuffer<void> chunk = nullptr;
|
||||||
|
|
||||||
FlacDecoder(DecoderClient &_client, InputStream &_input_stream)
|
FlacDecoder(DecoderClient &_client, InputStream &_input_stream)
|
||||||
:FlacInput(_input_stream, &_client) {}
|
:FlacInput(_input_stream, &_client) {}
|
||||||
|
|
||||||
|
@@ -139,19 +139,40 @@ flac_decoder_initialize(FlacDecoder *data, FLAC__StreamDecoder *sd)
|
|||||||
return data->initialized;
|
return data->initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DecoderCommand
|
||||||
|
FlacSubmitToClient(DecoderClient &client, FlacDecoder &d) noexcept
|
||||||
|
{
|
||||||
|
if (d.tag.IsEmpty() && d.chunk.IsEmpty())
|
||||||
|
return client.GetCommand();
|
||||||
|
|
||||||
|
if (!d.tag.IsEmpty()) {
|
||||||
|
auto cmd = client.SubmitTag(d.GetInputStream(),
|
||||||
|
std::move(d.tag));
|
||||||
|
d.tag.Clear();
|
||||||
|
if (cmd != DecoderCommand::NONE)
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!d.chunk.IsEmpty()) {
|
||||||
|
auto cmd = client.SubmitData(d.GetInputStream(),
|
||||||
|
d.chunk.data,
|
||||||
|
d.chunk.size,
|
||||||
|
d.kbit_rate);
|
||||||
|
d.chunk = nullptr;
|
||||||
|
if (cmd != DecoderCommand::NONE)
|
||||||
|
return cmd;
|
||||||
|
}
|
||||||
|
|
||||||
|
return DecoderCommand::NONE;
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flac_decoder_loop(FlacDecoder *data, FLAC__StreamDecoder *flac_dec)
|
flac_decoder_loop(FlacDecoder *data, FLAC__StreamDecoder *flac_dec)
|
||||||
{
|
{
|
||||||
DecoderClient &client = *data->GetClient();
|
DecoderClient &client = *data->GetClient();
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
DecoderCommand cmd;
|
DecoderCommand cmd = FlacSubmitToClient(client, *data);
|
||||||
if (!data->tag.IsEmpty()) {
|
|
||||||
cmd = client.SubmitTag(data->GetInputStream(),
|
|
||||||
std::move(data->tag));
|
|
||||||
data->tag.Clear();
|
|
||||||
} else
|
|
||||||
cmd = client.GetCommand();
|
|
||||||
|
|
||||||
if (cmd == DecoderCommand::SEEK) {
|
if (cmd == DecoderCommand::SEEK) {
|
||||||
FLAC__uint64 seek_sample = client.GetSeekFrame();
|
FLAC__uint64 seek_sample = client.GetSeekFrame();
|
||||||
@@ -160,6 +181,11 @@ flac_decoder_loop(FlacDecoder *data, FLAC__StreamDecoder *flac_dec)
|
|||||||
client.CommandFinished();
|
client.CommandFinished();
|
||||||
} else
|
} else
|
||||||
client.SeekError();
|
client.SeekError();
|
||||||
|
|
||||||
|
/* FLAC__stream_decoder_seek_absolute()
|
||||||
|
decodes one frame and may have provided
|
||||||
|
data to be submitted to the client */
|
||||||
|
continue;
|
||||||
} else if (cmd == DecoderCommand::STOP)
|
} else if (cmd == DecoderCommand::STOP)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@@ -64,7 +64,12 @@ fluidsynth_level_to_mpd(enum fluid_log_level level)
|
|||||||
* logging library.
|
* logging library.
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
fluidsynth_mpd_log_function(int level, char *message, gcc_unused void *data)
|
fluidsynth_mpd_log_function(int level,
|
||||||
|
#if FLUIDSYNTH_VERSION_MAJOR >= 2
|
||||||
|
const
|
||||||
|
#endif
|
||||||
|
char *message,
|
||||||
|
void *)
|
||||||
{
|
{
|
||||||
Log(fluidsynth_domain,
|
Log(fluidsynth_domain,
|
||||||
fluidsynth_level_to_mpd(fluid_log_level(level)),
|
fluidsynth_level_to_mpd(fluid_log_level(level)),
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "util/ScopeExit.hxx"
|
#include "util/ScopeExit.hxx"
|
||||||
#include "util/FormatString.hxx"
|
#include "util/StringFormat.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
@@ -38,7 +38,6 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define SUBTUNE_PREFIX "tune_"
|
#define SUBTUNE_PREFIX "tune_"
|
||||||
|
|
||||||
@@ -191,20 +190,17 @@ ScanGmeInfo(const gme_info_t &info, unsigned song_num, int track_count,
|
|||||||
tag_handler_invoke_duration(handler, handler_ctx,
|
tag_handler_invoke_duration(handler, handler_ctx,
|
||||||
SongTime::FromMS(info.play_length));
|
SongTime::FromMS(info.play_length));
|
||||||
|
|
||||||
if (track_count > 1) {
|
if (track_count > 1)
|
||||||
char track[16];
|
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK,
|
||||||
sprintf(track, "%u", song_num + 1);
|
StringFormat<16>("%u", song_num + 1));
|
||||||
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, track);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (info.song != nullptr) {
|
if (info.song != nullptr) {
|
||||||
if (track_count > 1) {
|
if (track_count > 1) {
|
||||||
/* start numbering subtunes from 1 */
|
/* start numbering subtunes from 1 */
|
||||||
char tag_title[1024];
|
const auto tag_title =
|
||||||
snprintf(tag_title, sizeof(tag_title),
|
StringFormat<1024>("%s (%u/%d)",
|
||||||
"%s (%u/%d)",
|
info.song, song_num + 1,
|
||||||
info.song, song_num + 1,
|
track_count);
|
||||||
track_count);
|
|
||||||
tag_handler_invoke_tag(handler, handler_ctx,
|
tag_handler_invoke_tag(handler, handler_ctx,
|
||||||
TAG_TITLE, tag_title);
|
TAG_TITLE, tag_title);
|
||||||
} else
|
} else
|
||||||
@@ -297,9 +293,9 @@ gme_container_scan(Path path_fs)
|
|||||||
ScanMusicEmu(emu, i,
|
ScanMusicEmu(emu, i,
|
||||||
add_tag_handler, &tag_builder);
|
add_tag_handler, &tag_builder);
|
||||||
|
|
||||||
char track_name[64];
|
const auto track_name =
|
||||||
snprintf(track_name, sizeof(track_name),
|
StringFormat<64>(SUBTUNE_PREFIX "%03u.%s", i+1,
|
||||||
SUBTUNE_PREFIX "%03u.%s", i+1, subtune_suffix);
|
subtune_suffix);
|
||||||
tail = list.emplace_after(tail, track_name,
|
tail = list.emplace_after(tail, track_name,
|
||||||
tag_builder.Commit());
|
tag_builder.Commit());
|
||||||
}
|
}
|
||||||
|
@@ -53,6 +53,14 @@ ScanOneOpusTag(const char *name, const char *value,
|
|||||||
long l = strtol(value, &endptr, 10);
|
long l = strtol(value, &endptr, 10);
|
||||||
if (endptr > value && *endptr == 0)
|
if (endptr > value && *endptr == 0)
|
||||||
rgi->track.gain = double(l) / 256.;
|
rgi->track.gain = double(l) / 256.;
|
||||||
|
} else if (rgi != nullptr && strcmp(name, "R128_ALBUM_GAIN") == 0) {
|
||||||
|
/* R128_ALBUM_GAIN is a Q7.8 fixed point number in
|
||||||
|
dB */
|
||||||
|
|
||||||
|
char *endptr;
|
||||||
|
long l = strtol(value, &endptr, 10);
|
||||||
|
if (endptr > value && *endptr == 0)
|
||||||
|
rgi->album.gain = double(l) / 256.;
|
||||||
}
|
}
|
||||||
|
|
||||||
tag_handler_invoke_pair(handler, ctx, name, value);
|
tag_handler_invoke_pair(handler, ctx, name, value);
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "util/Macros.hxx"
|
#include "util/Macros.hxx"
|
||||||
#include "util/FormatString.hxx"
|
#include "util/StringFormat.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "system/ByteOrder.hxx"
|
#include "system/ByteOrder.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
@@ -413,10 +413,9 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
|
|||||||
title = "";
|
title = "";
|
||||||
|
|
||||||
if (n_tracks > 1) {
|
if (n_tracks > 1) {
|
||||||
char tag_title[1024];
|
const auto tag_title =
|
||||||
snprintf(tag_title, sizeof(tag_title),
|
StringFormat<1024>("%s (%u/%u)",
|
||||||
"%s (%u/%u)",
|
title, track, n_tracks);
|
||||||
title, track, n_tracks);
|
|
||||||
tag_handler_invoke_tag(handler, handler_ctx,
|
tag_handler_invoke_tag(handler, handler_ctx,
|
||||||
TAG_TITLE, tag_title);
|
TAG_TITLE, tag_title);
|
||||||
} else
|
} else
|
||||||
@@ -435,9 +434,8 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
|
|||||||
date);
|
date);
|
||||||
|
|
||||||
/* track */
|
/* track */
|
||||||
char track_buffer[16];
|
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK,
|
||||||
sprintf(track_buffer, "%d", track);
|
StringFormat<16>("%u", track));
|
||||||
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, track_buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@@ -52,7 +52,7 @@ class OpusEncoder final : public OggEncoder {
|
|||||||
|
|
||||||
ogg_int64_t packetno = 0;
|
ogg_int64_t packetno = 0;
|
||||||
|
|
||||||
ogg_int64_t granulepos;
|
ogg_int64_t granulepos = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
OpusEncoder(AudioFormat &_audio_format, ::OpusEncoder *_enc);
|
OpusEncoder(AudioFormat &_audio_format, ::OpusEncoder *_enc);
|
||||||
|
@@ -27,7 +27,7 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
EventLoop::EventLoop()
|
EventLoop::EventLoop()
|
||||||
:SocketMonitor(*this)
|
:SocketMonitor(*this), quit(false)
|
||||||
{
|
{
|
||||||
SocketMonitor::Open(wake_fd.Get());
|
SocketMonitor::Open(wake_fd.Get());
|
||||||
SocketMonitor::Schedule(SocketMonitor::READ);
|
SocketMonitor::Schedule(SocketMonitor::READ);
|
||||||
@@ -46,7 +46,9 @@ EventLoop::~EventLoop()
|
|||||||
void
|
void
|
||||||
EventLoop::Break()
|
EventLoop::Break()
|
||||||
{
|
{
|
||||||
quit = true;
|
if (quit.exchange(true))
|
||||||
|
return;
|
||||||
|
|
||||||
wake_fd.Write();
|
wake_fd.Write();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "SocketMonitor.hxx"
|
#include "SocketMonitor.hxx"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
#include <atomic>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
@@ -82,7 +83,7 @@ class EventLoop final : SocketMonitor
|
|||||||
|
|
||||||
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
|
||||||
|
|
||||||
bool quit = false;
|
std::atomic_bool quit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* True when the object has been modified and another check is
|
* True when the object has been modified and another check is
|
||||||
|
@@ -73,6 +73,10 @@ public:
|
|||||||
return filter;
|
return filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Reset() override {
|
||||||
|
filter->Reset();
|
||||||
|
}
|
||||||
|
|
||||||
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override {
|
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override {
|
||||||
return filter->FilterPCM(src);
|
return filter->FilterPCM(src);
|
||||||
}
|
}
|
||||||
|
@@ -53,10 +53,16 @@ public:
|
|||||||
void Set(const AudioFormat &_out_audio_format);
|
void Set(const AudioFormat &_out_audio_format);
|
||||||
|
|
||||||
void Reset() override {
|
void Reset() override {
|
||||||
state.Reset();
|
if (IsActive())
|
||||||
|
state.Reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override;
|
ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
bool IsActive() const noexcept {
|
||||||
|
return out_audio_format != in_audio_format;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
class PreparedConvertFilter final : public PreparedFilter {
|
class PreparedConvertFilter final : public PreparedFilter {
|
||||||
@@ -80,7 +86,7 @@ ConvertFilter::Set(const AudioFormat &_out_audio_format)
|
|||||||
/* no change */
|
/* no change */
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (out_audio_format != in_audio_format) {
|
if (IsActive()) {
|
||||||
out_audio_format = in_audio_format;
|
out_audio_format = in_audio_format;
|
||||||
state.Close();
|
state.Close();
|
||||||
}
|
}
|
||||||
@@ -111,7 +117,7 @@ ConvertFilter::~ConvertFilter()
|
|||||||
{
|
{
|
||||||
assert(in_audio_format.IsValid());
|
assert(in_audio_format.IsValid());
|
||||||
|
|
||||||
if (out_audio_format != in_audio_format)
|
if (IsActive())
|
||||||
state.Close();
|
state.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -120,11 +126,10 @@ ConvertFilter::FilterPCM(ConstBuffer<void> src)
|
|||||||
{
|
{
|
||||||
assert(in_audio_format.IsValid());
|
assert(in_audio_format.IsValid());
|
||||||
|
|
||||||
if (out_audio_format == in_audio_format)
|
return IsActive()
|
||||||
|
? state.Convert(src)
|
||||||
/* optimized special case: no-op */
|
/* optimized special case: no-op */
|
||||||
return src;
|
: src;
|
||||||
|
|
||||||
return state.Convert(src);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const FilterPlugin convert_filter_plugin = {
|
const FilterPlugin convert_filter_plugin = {
|
||||||
|
@@ -20,6 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "FileOutputStream.hxx"
|
#include "FileOutputStream.hxx"
|
||||||
#include "system/Error.hxx"
|
#include "system/Error.hxx"
|
||||||
|
#include "util/StringFormat.hxx"
|
||||||
|
|
||||||
FileOutputStream::FileOutputStream(Path _path, Mode _mode)
|
FileOutputStream::FileOutputStream(Path _path, Mode _mode)
|
||||||
:path(_path), mode(_mode)
|
:path(_path), mode(_mode)
|
||||||
@@ -212,10 +213,9 @@ FileOutputStream::Commit()
|
|||||||
unlink(GetPath().c_str());
|
unlink(GetPath().c_str());
|
||||||
|
|
||||||
/* hard-link the temporary file to the final path */
|
/* hard-link the temporary file to the final path */
|
||||||
char fd_path[64];
|
if (linkat(AT_FDCWD,
|
||||||
snprintf(fd_path, sizeof(fd_path), "/proc/self/fd/%d",
|
StringFormat<64>("/proc/self/fd/%d", fd.Get()),
|
||||||
fd.Get());
|
AT_FDCWD, path.c_str(),
|
||||||
if (linkat(AT_FDCWD, fd_path, AT_FDCWD, path.c_str(),
|
|
||||||
AT_SYMLINK_FOLLOW) < 0)
|
AT_SYMLINK_FOLLOW) < 0)
|
||||||
throw FormatErrno("Failed to commit %s",
|
throw FormatErrno("Failed to commit %s",
|
||||||
path.c_str());
|
path.c_str());
|
||||||
|
@@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "AsyncInputStream.hxx"
|
#include "AsyncInputStream.hxx"
|
||||||
#include "Domain.hxx"
|
|
||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
#include "thread/Cond.hxx"
|
#include "thread/Cond.hxx"
|
||||||
#include "IOThread.hxx"
|
#include "IOThread.hxx"
|
||||||
|
53
src/input/Error.cxx
Normal file
53
src/input/Error.cxx
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
/*
|
||||||
|
* 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 "config.h"
|
||||||
|
#include "Error.hxx"
|
||||||
|
#include "system/Error.hxx"
|
||||||
|
|
||||||
|
#ifdef ENABLE_CURL
|
||||||
|
#include "lib/curl/Error.hxx"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ENABLE_NFS
|
||||||
|
#include "lib/nfs/Error.hxx"
|
||||||
|
#include <nfsc/libnfs-raw-nfs.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
bool
|
||||||
|
IsFileNotFound(std::exception_ptr ep)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
std::rethrow_exception(ep);
|
||||||
|
} catch (const std::system_error &e) {
|
||||||
|
return IsFileNotFound(e);
|
||||||
|
#ifdef ENABLE_CURL
|
||||||
|
} catch (const HttpStatusError &e) {
|
||||||
|
return e.GetStatus() == 404;
|
||||||
|
#endif
|
||||||
|
#ifdef ENABLE_NFS
|
||||||
|
} catch (const NfsClientError &e) {
|
||||||
|
return e.GetCode() == NFS3ERR_NOENT;
|
||||||
|
#endif
|
||||||
|
} catch (...) {
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
45
src/input/Error.hxx
Normal file
45
src/input/Error.hxx
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INPUT_ERROR_HXX
|
||||||
|
#define INPUT_ERROR_HXX
|
||||||
|
|
||||||
|
#include "check.h"
|
||||||
|
#include "Compiler.h"
|
||||||
|
|
||||||
|
#include <exception>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Was this exception thrown because the requested file does not
|
||||||
|
* exist? This function attempts to recognize exceptions thrown by
|
||||||
|
* various input plugins.
|
||||||
|
*/
|
||||||
|
#ifndef __clang__
|
||||||
|
/* the "pure" attribute must be disabled because it triggers a clang
|
||||||
|
bug, wrongfully leading to std::terminate() even though the
|
||||||
|
function catches all exceptions thrown by std::rethrow_exception();
|
||||||
|
this can be reproduced with clang 7 from Android NDK r18b and on
|
||||||
|
clang 6 on FreeBSD
|
||||||
|
(https://github.com/MusicPlayerDaemon/MPD/issues/373) */
|
||||||
|
gcc_pure
|
||||||
|
#endif
|
||||||
|
bool
|
||||||
|
IsFileNotFound(std::exception_ptr e);
|
||||||
|
|
||||||
|
#endif
|
@@ -20,7 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "InputStream.hxx"
|
#include "InputStream.hxx"
|
||||||
#include "thread/Cond.hxx"
|
#include "thread/Cond.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/ASCII.hxx"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
@@ -77,8 +77,8 @@ gcc_pure
|
|||||||
static bool
|
static bool
|
||||||
ExpensiveSeeking(const char *uri) noexcept
|
ExpensiveSeeking(const char *uri) noexcept
|
||||||
{
|
{
|
||||||
return StringStartsWith(uri, "http://") ||
|
return StringStartsWithCaseASCII(uri, "http://") ||
|
||||||
StringStartsWith(uri, "https://");
|
StringStartsWithCaseASCII(uri, "https://");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
|
@@ -29,4 +29,10 @@
|
|||||||
*/
|
*/
|
||||||
typedef uint64_t offset_type;
|
typedef uint64_t offset_type;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* To format an offset_type with printf(). To use this, include
|
||||||
|
* <cinttypes>.
|
||||||
|
*/
|
||||||
|
#define PRIoffset PRIu64
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
#include "Registry.hxx"
|
#include "Registry.hxx"
|
||||||
#include "InputPlugin.hxx"
|
#include "InputPlugin.hxx"
|
||||||
#include "LocalOpen.hxx"
|
#include "LocalOpen.hxx"
|
||||||
#include "Domain.hxx"
|
|
||||||
#include "plugins/RewindInputPlugin.hxx"
|
#include "plugins/RewindInputPlugin.hxx"
|
||||||
#include "fs/Traits.hxx"
|
#include "fs/Traits.hxx"
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
|
@@ -26,8 +26,12 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
ThreadInputStream::~ThreadInputStream()
|
void
|
||||||
|
ThreadInputStream::Stop() noexcept
|
||||||
{
|
{
|
||||||
|
if (!thread.IsDefined())
|
||||||
|
return;
|
||||||
|
|
||||||
{
|
{
|
||||||
const std::lock_guard<Mutex> lock(mutex);
|
const std::lock_guard<Mutex> lock(mutex);
|
||||||
close = true;
|
close = true;
|
||||||
@@ -42,6 +46,7 @@ ThreadInputStream::~ThreadInputStream()
|
|||||||
buffer->Clear();
|
buffer->Clear();
|
||||||
HugeFree(buffer->Write().data, buffer_size);
|
HugeFree(buffer->Write().data, buffer_size);
|
||||||
delete buffer;
|
delete buffer;
|
||||||
|
buffer = nullptr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -54,10 +59,10 @@ ThreadInputStream::Start()
|
|||||||
assert(p != nullptr);
|
assert(p != nullptr);
|
||||||
|
|
||||||
buffer = new CircularBuffer<uint8_t>((uint8_t *)p, buffer_size);
|
buffer = new CircularBuffer<uint8_t>((uint8_t *)p, buffer_size);
|
||||||
thread.Start(ThreadFunc, this);
|
thread.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void
|
void
|
||||||
ThreadInputStream::ThreadFunc()
|
ThreadInputStream::ThreadFunc()
|
||||||
{
|
{
|
||||||
FormatThreadName("input:%s", plugin);
|
FormatThreadName("input:%s", plugin);
|
||||||
@@ -68,7 +73,7 @@ ThreadInputStream::ThreadFunc()
|
|||||||
Open();
|
Open();
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
postponed_exception = std::current_exception();
|
postponed_exception = std::current_exception();
|
||||||
cond.broadcast();
|
SetReady();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -107,13 +112,6 @@ ThreadInputStream::ThreadFunc()
|
|||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
ThreadInputStream::ThreadFunc(void *ctx)
|
|
||||||
{
|
|
||||||
ThreadInputStream &tis = *(ThreadInputStream *)ctx;
|
|
||||||
tis.ThreadFunc();
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ThreadInputStream::Check()
|
ThreadInputStream::Check()
|
||||||
{
|
{
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
|
|
||||||
#include <exception>
|
#include <exception>
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
template<typename T> class CircularBuffer;
|
template<typename T> class CircularBuffer;
|
||||||
@@ -39,6 +40,11 @@ template<typename T> class CircularBuffer;
|
|||||||
* manages the thread and the buffer.
|
* manages the thread and the buffer.
|
||||||
*
|
*
|
||||||
* This works only for "streams": unknown length, no seeking, no tags.
|
* This works only for "streams": unknown length, no seeking, no tags.
|
||||||
|
*
|
||||||
|
* The implementation must call Stop() before its destruction
|
||||||
|
* completes. This cannot be done in ~ThreadInputStream() because at
|
||||||
|
* this point, the class has been morphed back to #ThreadInputStream
|
||||||
|
* and the still-running thread will crash due to pure method call.
|
||||||
*/
|
*/
|
||||||
class ThreadInputStream : public InputStream {
|
class ThreadInputStream : public InputStream {
|
||||||
const char *const plugin;
|
const char *const plugin;
|
||||||
@@ -73,9 +79,16 @@ public:
|
|||||||
size_t _buffer_size)
|
size_t _buffer_size)
|
||||||
:InputStream(_uri, _mutex, _cond),
|
:InputStream(_uri, _mutex, _cond),
|
||||||
plugin(_plugin),
|
plugin(_plugin),
|
||||||
|
thread(BIND_THIS_METHOD(ThreadFunc)),
|
||||||
buffer_size(_buffer_size) {}
|
buffer_size(_buffer_size) {}
|
||||||
|
|
||||||
virtual ~ThreadInputStream();
|
#ifndef NDEBUG
|
||||||
|
~ThreadInputStream() override {
|
||||||
|
/* Stop() must have been called already */
|
||||||
|
assert(!thread.IsDefined());
|
||||||
|
assert(buffer == nullptr);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the object and start the thread.
|
* Initialize the object and start the thread.
|
||||||
@@ -89,6 +102,12 @@ public:
|
|||||||
size_t Read(void *ptr, size_t size) override final;
|
size_t Read(void *ptr, size_t size) override final;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/**
|
||||||
|
* Stop the thread and free the buffer. This must be called
|
||||||
|
* before destruction of this object completes.
|
||||||
|
*/
|
||||||
|
void Stop() noexcept;
|
||||||
|
|
||||||
void SetMimeType(const char *_mime) {
|
void SetMimeType(const char *_mime) {
|
||||||
assert(thread.IsInside());
|
assert(thread.IsInside());
|
||||||
|
|
||||||
@@ -138,7 +157,6 @@ protected:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void ThreadFunc();
|
void ThreadFunc();
|
||||||
static void ThreadFunc(void *ctx);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -33,7 +33,7 @@
|
|||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/ReusableArray.hxx"
|
#include "util/ReusableArray.hxx"
|
||||||
|
#include "util/ASCII.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
#include "event/MultiSocketMonitor.hxx"
|
#include "event/MultiSocketMonitor.hxx"
|
||||||
#include "event/DeferredMonitor.hxx"
|
#include "event/DeferredMonitor.hxx"
|
||||||
@@ -147,7 +147,7 @@ private:
|
|||||||
inline InputStream *
|
inline InputStream *
|
||||||
AlsaInputStream::Create(const char *uri, Mutex &mutex, Cond &cond)
|
AlsaInputStream::Create(const char *uri, Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
const char *device = StringAfterPrefix(uri, "alsa://");
|
const char *device = StringAfterPrefixCaseASCII(uri, "alsa://");
|
||||||
if (device == nullptr)
|
if (device == nullptr)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
@@ -270,6 +270,12 @@ AlsaInputStream::Recover(int err)
|
|||||||
/* this is no error, so just keep running */
|
/* this is no error, so just keep running */
|
||||||
err = 0;
|
err = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
/* this default case is just here to work around
|
||||||
|
-Wswitch due to SND_PCM_STATE_PRIVATE1 (libasound
|
||||||
|
1.1.6) */
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@@ -26,7 +26,7 @@
|
|||||||
#include "../InputStream.hxx"
|
#include "../InputStream.hxx"
|
||||||
#include "../InputPlugin.hxx"
|
#include "../InputPlugin.hxx"
|
||||||
#include "util/StringUtil.hxx"
|
#include "util/StringUtil.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/ASCII.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "system/ByteOrder.hxx"
|
#include "system/ByteOrder.hxx"
|
||||||
@@ -128,7 +128,7 @@ struct cdio_uri {
|
|||||||
static bool
|
static bool
|
||||||
parse_cdio_uri(struct cdio_uri *dest, const char *src)
|
parse_cdio_uri(struct cdio_uri *dest, const char *src)
|
||||||
{
|
{
|
||||||
if (!StringStartsWith(src, "cdda://"))
|
if (!StringStartsWithCaseASCII(src, "cdda://"))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
src += 7;
|
src += 7;
|
||||||
|
@@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "CurlInputPlugin.hxx"
|
#include "CurlInputPlugin.hxx"
|
||||||
|
#include "lib/curl/Error.hxx"
|
||||||
#include "lib/curl/Easy.hxx"
|
#include "lib/curl/Easy.hxx"
|
||||||
#include "lib/curl/Global.hxx"
|
#include "lib/curl/Global.hxx"
|
||||||
#include "lib/curl/Request.hxx"
|
#include "lib/curl/Request.hxx"
|
||||||
@@ -34,12 +35,15 @@
|
|||||||
#include "IOThread.hxx"
|
#include "IOThread.hxx"
|
||||||
#include "util/ASCII.hxx"
|
#include "util/ASCII.hxx"
|
||||||
#include "util/StringUtil.hxx"
|
#include "util/StringUtil.hxx"
|
||||||
|
#include "util/StringFormat.hxx"
|
||||||
#include "util/NumberParser.hxx"
|
#include "util/NumberParser.hxx"
|
||||||
#include "util/RuntimeError.hxx"
|
#include "util/RuntimeError.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
#include "PluginUnavailable.hxx"
|
#include "PluginUnavailable.hxx"
|
||||||
|
|
||||||
|
#include <cinttypes>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
@@ -185,7 +189,9 @@ CurlInputStream::OnHeaders(unsigned status,
|
|||||||
assert(!postponed_exception);
|
assert(!postponed_exception);
|
||||||
|
|
||||||
if (status < 200 || status >= 300)
|
if (status < 200 || status >= 300)
|
||||||
throw FormatRuntimeError("got HTTP status %ld", status);
|
throw HttpStatusError(status,
|
||||||
|
StringFormat<40>("got HTTP status %u",
|
||||||
|
status).c_str());
|
||||||
|
|
||||||
const std::lock_guard<Mutex> protect(mutex);
|
const std::lock_guard<Mutex> protect(mutex);
|
||||||
|
|
||||||
@@ -266,6 +272,7 @@ CurlInputStream::OnData(ConstBuffer<void> data)
|
|||||||
void
|
void
|
||||||
CurlInputStream::OnEnd()
|
CurlInputStream::OnEnd()
|
||||||
{
|
{
|
||||||
|
const std::lock_guard<Mutex> protect(mutex);
|
||||||
cond.broadcast();
|
cond.broadcast();
|
||||||
|
|
||||||
AsyncInputStream::SetClosed();
|
AsyncInputStream::SetClosed();
|
||||||
@@ -274,6 +281,7 @@ CurlInputStream::OnEnd()
|
|||||||
void
|
void
|
||||||
CurlInputStream::OnError(std::exception_ptr e)
|
CurlInputStream::OnError(std::exception_ptr e)
|
||||||
{
|
{
|
||||||
|
const std::lock_guard<Mutex> protect(mutex);
|
||||||
postponed_exception = std::move(e);
|
postponed_exception = std::move(e);
|
||||||
|
|
||||||
if (IsSeekPending())
|
if (IsSeekPending())
|
||||||
@@ -369,13 +377,10 @@ CurlInputStream::InitEasy()
|
|||||||
if (proxy_port > 0)
|
if (proxy_port > 0)
|
||||||
request->SetOption(CURLOPT_PROXYPORT, (long)proxy_port);
|
request->SetOption(CURLOPT_PROXYPORT, (long)proxy_port);
|
||||||
|
|
||||||
if (proxy_user != nullptr && proxy_password != nullptr) {
|
if (proxy_user != nullptr && proxy_password != nullptr)
|
||||||
char proxy_auth_str[1024];
|
request->SetOption(CURLOPT_PROXYUSERPWD,
|
||||||
snprintf(proxy_auth_str, sizeof(proxy_auth_str),
|
StringFormat<1024>("%s:%s", proxy_user,
|
||||||
"%s:%s",
|
proxy_password).c_str());
|
||||||
proxy_user, proxy_password);
|
|
||||||
request->SetOption(CURLOPT_PROXYUSERPWD, proxy_auth_str);
|
|
||||||
}
|
|
||||||
|
|
||||||
request->SetOption(CURLOPT_SSL_VERIFYPEER, verify_peer ? 1l : 0l);
|
request->SetOption(CURLOPT_SSL_VERIFYPEER, verify_peer ? 1l : 0l);
|
||||||
request->SetOption(CURLOPT_SSL_VERIFYHOST, verify_host ? 2l : 0l);
|
request->SetOption(CURLOPT_SSL_VERIFYHOST, verify_host ? 2l : 0l);
|
||||||
@@ -412,16 +417,10 @@ CurlInputStream::SeekInternal(offset_type new_offset)
|
|||||||
|
|
||||||
/* send the "Range" header */
|
/* send the "Range" header */
|
||||||
|
|
||||||
if (offset > 0) {
|
if (offset > 0)
|
||||||
char range[32];
|
request->SetOption(CURLOPT_RANGE,
|
||||||
#ifdef _WIN32
|
StringFormat<40>("%" PRIoffset "-",
|
||||||
// TODO: what can we use on Windows to format 64 bit?
|
offset).c_str());
|
||||||
sprintf(range, "%lu-", (long)offset);
|
|
||||||
#else
|
|
||||||
sprintf(range, "%llu-", (unsigned long long)offset);
|
|
||||||
#endif
|
|
||||||
request->SetOption(CURLOPT_RANGE, range);
|
|
||||||
}
|
|
||||||
|
|
||||||
StartRequest();
|
StartRequest();
|
||||||
}
|
}
|
||||||
@@ -459,8 +458,8 @@ CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond)
|
|||||||
static InputStream *
|
static InputStream *
|
||||||
input_curl_open(const char *url, Mutex &mutex, Cond &cond)
|
input_curl_open(const char *url, Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
if (strncmp(url, "http://", 7) != 0 &&
|
if (!StringStartsWithCaseASCII(url, "http://") &&
|
||||||
strncmp(url, "https://", 8) != 0)
|
!StringStartsWithCaseASCII(url, "https://"))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return CurlInputStream::Open(url, mutex, cond);
|
return CurlInputStream::Open(url, mutex, cond);
|
||||||
|
@@ -28,7 +28,7 @@
|
|||||||
#include "../InputStream.hxx"
|
#include "../InputStream.hxx"
|
||||||
#include "../InputPlugin.hxx"
|
#include "../InputPlugin.hxx"
|
||||||
#include "PluginUnavailable.hxx"
|
#include "PluginUnavailable.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/ASCII.hxx"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <libavformat/avio.h>
|
#include <libavformat/avio.h>
|
||||||
@@ -85,12 +85,12 @@ static InputStream *
|
|||||||
input_ffmpeg_open(const char *uri,
|
input_ffmpeg_open(const char *uri,
|
||||||
Mutex &mutex, Cond &cond)
|
Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
if (!StringStartsWith(uri, "gopher://") &&
|
if (!StringStartsWithCaseASCII(uri, "gopher://") &&
|
||||||
!StringStartsWith(uri, "rtp://") &&
|
!StringStartsWithCaseASCII(uri, "rtp://") &&
|
||||||
!StringStartsWith(uri, "rtsp://") &&
|
!StringStartsWithCaseASCII(uri, "rtsp://") &&
|
||||||
!StringStartsWith(uri, "rtmp://") &&
|
!StringStartsWithCaseASCII(uri, "rtmp://") &&
|
||||||
!StringStartsWith(uri, "rtmpt://") &&
|
!StringStartsWithCaseASCII(uri, "rtmpt://") &&
|
||||||
!StringStartsWith(uri, "rtmps://"))
|
!StringStartsWithCaseASCII(uri, "rtmps://"))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
AVIOContext *h;
|
AVIOContext *h;
|
||||||
|
@@ -22,7 +22,7 @@
|
|||||||
#include "input/ThreadInputStream.hxx"
|
#include "input/ThreadInputStream.hxx"
|
||||||
#include "input/InputPlugin.hxx"
|
#include "input/InputPlugin.hxx"
|
||||||
#include "system/Error.hxx"
|
#include "system/Error.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/ASCII.hxx"
|
||||||
|
|
||||||
#include <libmms/mmsx.h>
|
#include <libmms/mmsx.h>
|
||||||
|
|
||||||
@@ -39,6 +39,10 @@ public:
|
|||||||
MMS_BUFFER_SIZE) {
|
MMS_BUFFER_SIZE) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
~MmsInputStream() noexcept override {
|
||||||
|
Stop();
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Open() override;
|
virtual void Open() override;
|
||||||
virtual size_t ThreadRead(void *ptr, size_t size) override;
|
virtual size_t ThreadRead(void *ptr, size_t size) override;
|
||||||
@@ -70,10 +74,10 @@ static InputStream *
|
|||||||
input_mms_open(const char *url,
|
input_mms_open(const char *url,
|
||||||
Mutex &mutex, Cond &cond)
|
Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
if (!StringStartsWith(url, "mms://") &&
|
if (!StringStartsWithCaseASCII(url, "mms://") &&
|
||||||
!StringStartsWith(url, "mmsh://") &&
|
!StringStartsWithCaseASCII(url, "mmsh://") &&
|
||||||
!StringStartsWith(url, "mmst://") &&
|
!StringStartsWithCaseASCII(url, "mmst://") &&
|
||||||
!StringStartsWith(url, "mmsu://"))
|
!StringStartsWithCaseASCII(url, "mmsu://"))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto m = new MmsInputStream(url, mutex, cond);
|
auto m = new MmsInputStream(url, mutex, cond);
|
||||||
|
@@ -23,9 +23,7 @@
|
|||||||
#include "../InputPlugin.hxx"
|
#include "../InputPlugin.hxx"
|
||||||
#include "lib/nfs/Glue.hxx"
|
#include "lib/nfs/Glue.hxx"
|
||||||
#include "lib/nfs/FileReader.hxx"
|
#include "lib/nfs/FileReader.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/ASCII.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Do not buffer more than this number of bytes. It should be a
|
* Do not buffer more than this number of bytes. It should be a
|
||||||
@@ -219,7 +217,7 @@ static InputStream *
|
|||||||
input_nfs_open(const char *uri,
|
input_nfs_open(const char *uri,
|
||||||
Mutex &mutex, Cond &cond)
|
Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
if (!StringStartsWith(uri, "nfs://"))
|
if (!StringStartsWithCaseASCII(uri, "nfs://"))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
NfsInputStream *is = new NfsInputStream(uri, mutex, cond);
|
NfsInputStream *is = new NfsInputStream(uri, mutex, cond);
|
||||||
|
@@ -25,7 +25,7 @@
|
|||||||
#include "../InputPlugin.hxx"
|
#include "../InputPlugin.hxx"
|
||||||
#include "PluginUnavailable.hxx"
|
#include "PluginUnavailable.hxx"
|
||||||
#include "system/Error.hxx"
|
#include "system/Error.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/ASCII.hxx"
|
||||||
|
|
||||||
#include <libsmbclient.h>
|
#include <libsmbclient.h>
|
||||||
|
|
||||||
@@ -87,7 +87,7 @@ static InputStream *
|
|||||||
input_smbclient_open(const char *uri,
|
input_smbclient_open(const char *uri,
|
||||||
Mutex &mutex, Cond &cond)
|
Mutex &mutex, Cond &cond)
|
||||||
{
|
{
|
||||||
if (!StringStartsWith(uri, "smb://"))
|
if (!StringStartsWithCaseASCII(uri, "smb://"))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const std::lock_guard<Mutex> protect(smbclient_mutex);
|
const std::lock_guard<Mutex> protect(smbclient_mutex);
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user