Compare commits
246 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
82e261ad33 | ||
![]() |
cae2811762 | ||
![]() |
09112c6869 | ||
![]() |
77aaf1baee | ||
![]() |
6626c2d00d | ||
![]() |
315f9d98f6 | ||
![]() |
f087518e7a | ||
![]() |
db9997a106 | ||
![]() |
0cbfb610f2 | ||
![]() |
f901cd042b | ||
![]() |
5719207dfa | ||
![]() |
a84fbbe327 | ||
![]() |
93c97972b9 | ||
![]() |
ac61d43720 | ||
![]() |
1958f78cc1 | ||
![]() |
a7ee64a25b | ||
![]() |
2a58f22649 | ||
![]() |
f066bb7716 | ||
![]() |
4e3d182189 | ||
![]() |
205fba74cf | ||
![]() |
a9bcf8d50d | ||
![]() |
b0ff3bc7a3 | ||
![]() |
06301e279c | ||
![]() |
6d6f274648 | ||
![]() |
9acefcb256 | ||
![]() |
e4d0293a31 | ||
![]() |
ae77542a11 | ||
![]() |
980187f856 | ||
![]() |
327a8e6c59 | ||
![]() |
d11e2724c4 | ||
![]() |
f768ca3a2d | ||
![]() |
947e902288 | ||
![]() |
3436a646b5 | ||
![]() |
aed0af1e00 | ||
![]() |
0d7ee2b014 | ||
![]() |
2f5fd91bd8 | ||
![]() |
5761800197 | ||
![]() |
0eebacc521 | ||
![]() |
4a5528697d | ||
![]() |
d38034bb5c | ||
![]() |
b3fe3e8b3d | ||
![]() |
5489dec28d | ||
![]() |
8a6b4db19f | ||
![]() |
df43b6a05c | ||
![]() |
3adca3c2fa | ||
![]() |
39abd3ecb4 | ||
![]() |
a4f4fc50b9 | ||
![]() |
7bf638b0de | ||
![]() |
56662a703c | ||
![]() |
8b5f47d3a3 | ||
![]() |
a289dcb9ee | ||
![]() |
023b9c1e7e | ||
![]() |
4c61662644 | ||
![]() |
ad1b6ef0ac | ||
![]() |
ed5c6be2f1 | ||
![]() |
30cb082932 | ||
![]() |
645554d12f | ||
![]() |
212b0faf0c | ||
![]() |
276a0d9500 | ||
![]() |
384b6c8288 | ||
![]() |
a2af158fd3 | ||
![]() |
f33d2fb2e7 | ||
![]() |
a9eec35aff | ||
![]() |
8534f2d1e2 | ||
![]() |
00740fb23b | ||
![]() |
37e9010887 | ||
![]() |
4bd2c75056 | ||
![]() |
b9ed850b98 | ||
![]() |
11cea17496 | ||
![]() |
163597ef69 | ||
![]() |
95f84afd33 | ||
![]() |
9f7fd1fbfb | ||
![]() |
940cab8620 | ||
![]() |
5b84c99d79 | ||
![]() |
b295024574 | ||
![]() |
34180f1745 | ||
![]() |
665031467a | ||
![]() |
df33171107 | ||
![]() |
53f4044890 | ||
![]() |
a5049136ff | ||
![]() |
705b3c6b63 | ||
![]() |
6b4ac66962 | ||
![]() |
0964b06240 | ||
![]() |
92eeca3ba7 | ||
![]() |
2a86554ac4 | ||
![]() |
805caa30ce | ||
![]() |
a56949e9fa | ||
![]() |
43da4c0eca | ||
![]() |
b9c7771830 | ||
![]() |
35db88affe | ||
![]() |
e38faca455 | ||
![]() |
0255e8710c | ||
![]() |
6d89020f80 | ||
![]() |
9c56c49e73 | ||
![]() |
acb798e544 | ||
![]() |
c5720a15c7 | ||
![]() |
90709b332a | ||
![]() |
81f17d10c8 | ||
![]() |
773de38bd9 | ||
![]() |
a48704925d | ||
![]() |
fa4beeee75 | ||
![]() |
d8351772d3 | ||
![]() |
68d1abdb85 | ||
![]() |
7e8474a85a | ||
![]() |
82da364b8b | ||
![]() |
7fa91ec175 | ||
![]() |
1d3a09d377 | ||
![]() |
02563a35f0 | ||
![]() |
d653f35bb7 | ||
![]() |
a543627abd | ||
![]() |
80f2ba7fca | ||
![]() |
32bca64920 | ||
![]() |
7fa1a84ec3 | ||
![]() |
ab4bb26a0a | ||
![]() |
4b8d258cff | ||
![]() |
3c29aa6271 | ||
![]() |
51464b4317 | ||
![]() |
2fec463542 | ||
![]() |
1affc641c4 | ||
![]() |
0cfd4fff62 | ||
![]() |
8904127c10 | ||
![]() |
c46f48abec | ||
![]() |
4acbf7b90d | ||
![]() |
cbc1a58e93 | ||
![]() |
1b5f33a435 | ||
![]() |
41b4a63f2b | ||
![]() |
d8fc2db910 | ||
![]() |
dc11dea7cc | ||
![]() |
811af02f56 | ||
![]() |
8780e23ed3 | ||
![]() |
be492ed108 | ||
![]() |
24da14f4f7 | ||
![]() |
03d2fb450f | ||
![]() |
67cba251c8 | ||
![]() |
0bc511715b | ||
![]() |
27ce80544f | ||
![]() |
04f627c2af | ||
![]() |
e72eef421b | ||
![]() |
016063c810 | ||
![]() |
38f19981b2 | ||
![]() |
40dd968f13 | ||
![]() |
3cef348f30 | ||
![]() |
b293b16007 | ||
![]() |
f5f43db2da | ||
![]() |
029555d192 | ||
![]() |
fa4d202e71 | ||
![]() |
a8ebfd7a92 | ||
![]() |
b19e5720cc | ||
![]() |
a254f5a3a8 | ||
![]() |
143c735f96 | ||
![]() |
951bad46e0 | ||
![]() |
716225cd2f | ||
![]() |
bbc618b8f9 | ||
![]() |
11ead56d6d | ||
![]() |
e972ae4afa | ||
![]() |
0709065f50 | ||
![]() |
d6bc5c35a7 | ||
![]() |
dc03f003ac | ||
![]() |
7aa2104596 | ||
![]() |
460cfba6ff | ||
![]() |
c8b93d6573 | ||
![]() |
3f5f96ac91 | ||
![]() |
7c6b991de7 | ||
![]() |
82460aa49f | ||
![]() |
7e7b403043 | ||
![]() |
e5217e6ce9 | ||
![]() |
c98cb1d6f9 | ||
![]() |
ba6f2b0467 | ||
![]() |
23465ad985 | ||
![]() |
7886a14b74 | ||
![]() |
466b6a23cd | ||
![]() |
4a04f73434 | ||
![]() |
134cb6a017 | ||
![]() |
8d036c4b7c | ||
![]() |
c64ad78c7b | ||
![]() |
4a043a915f | ||
![]() |
8ff0d99092 | ||
![]() |
2e47cb12c4 | ||
![]() |
ff6f1655f0 | ||
![]() |
b5ba94f1de | ||
![]() |
cbf79769d3 | ||
![]() |
125eb01e03 | ||
![]() |
ccb13205f4 | ||
![]() |
6f23e91e33 | ||
![]() |
1bd8a322f5 | ||
![]() |
362e73bea8 | ||
![]() |
9f8c2b3b56 | ||
![]() |
6a7f6cdacd | ||
![]() |
5715342fe0 | ||
![]() |
38a0d15190 | ||
![]() |
56f763a4a8 | ||
![]() |
a2eb14f3b3 | ||
![]() |
05c63af7c4 | ||
![]() |
1f59701c46 | ||
![]() |
ec3191f502 | ||
![]() |
32b5654a6e | ||
![]() |
674091424e | ||
![]() |
6ad336743d | ||
![]() |
c882568ccd | ||
![]() |
f6b2899dd2 | ||
![]() |
bccd4ef2f7 | ||
![]() |
94c240a026 | ||
![]() |
c50a0cf7bf | ||
![]() |
c37f7abb79 | ||
![]() |
432ce9b1de | ||
![]() |
054323c2bc | ||
![]() |
a8770aa606 | ||
![]() |
7d5442e103 | ||
![]() |
eab32f2e5d | ||
![]() |
d42c0f1dc5 | ||
![]() |
6ad1e4d99a | ||
![]() |
7350144ab3 | ||
![]() |
54c591bd9d | ||
![]() |
217d88f21f | ||
![]() |
394e3be482 | ||
![]() |
d7f024c510 | ||
![]() |
bc5a53574c | ||
![]() |
30df709736 | ||
![]() |
8cd17ce045 | ||
![]() |
1bfbced258 | ||
![]() |
6ac5980a17 | ||
![]() |
2e24adae89 | ||
![]() |
188b94cb3e | ||
![]() |
c48733e34f | ||
![]() |
f36db9bb04 | ||
![]() |
30dd29e251 | ||
![]() |
6cf1acfb48 | ||
![]() |
a7b09d3d1c | ||
![]() |
8fc3768166 | ||
![]() |
b07bddf742 | ||
![]() |
220f957cd8 | ||
![]() |
8ce48d83eb | ||
![]() |
200cdb6b0a | ||
![]() |
d9fb40203a | ||
![]() |
2d9e972195 | ||
![]() |
97a1a04116 | ||
![]() |
493cd866f1 | ||
![]() |
063d369672 | ||
![]() |
a0fae8dacc | ||
![]() |
bc840b69d5 | ||
![]() |
85301853d6 | ||
![]() |
7cd53fb452 | ||
![]() |
538ddf7af2 | ||
![]() |
d5afa181f7 | ||
![]() |
8ed4124184 | ||
![]() |
160242a74f |
.gitignoreINSTALLMakefile.amNEWS
android
configure.acdoc
m4
src
Compiler.hIdle.cxxLogBackend.cxxLogInit.cxxMain.cxxMain.hxxPlayerThread.cxxPlaylistFile.cxxSongFilter.cxxSongLoader.cxxTagStream.cxxls.cxx
archive
plugins
client
command
db
decoder
encoder
event
filter
plugins
fs
input
AsyncInputStream.cxxAsyncInputStream.hxxDomain.cxxDomain.hxxInit.cxxInputStream.cxxInputStream.hxxOpen.cxxRegistry.cxxTextInputStream.cxxThreadInputStream.cxx
plugins
java
lib
despotify
icu
nfs
Blocking.cxxBlocking.hxxCancellable.hxxConnection.cxxConnection.hxxFileReader.cxxFileReader.hxxManager.cxxManager.hxx
upnp
mixer
osx
output
pcm
playlist
storage
plugins
system
tag
thread
unix
util
systemd
test
2
.gitignore
vendored
2
.gitignore
vendored
@@ -77,6 +77,8 @@ tags
|
||||
/test/test_vorbis_encoder
|
||||
/test/DumpDatabase
|
||||
|
||||
/lib/
|
||||
|
||||
/*.tar.gz
|
||||
/*.tar.bz2
|
||||
/*.tar.xz
|
||||
|
6
INSTALL
6
INSTALL
@@ -116,12 +116,6 @@ For WavPack playback.
|
||||
libadplug - http://adplug.sourceforge.net/
|
||||
For AdLib playback.
|
||||
|
||||
despotify - https://github.com/SimonKagstrom/despotify
|
||||
For Spotify playback.
|
||||
|
||||
MP4v2 - https://code.google.com/p/mp4v2/
|
||||
For MP4 playback. You will need FAAD2.
|
||||
|
||||
|
||||
Optional Miscellaneous Dependencies
|
||||
-----------------------------------
|
||||
|
58
Makefile.am
58
Makefile.am
@@ -28,8 +28,6 @@ noinst_LIBRARIES = \
|
||||
libmixer_plugins.a \
|
||||
liboutput_plugins.a
|
||||
|
||||
libmpd_a_DEPENDENCIES =
|
||||
|
||||
libmpd_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||
$(LIBMPDCLIENT_CFLAGS) \
|
||||
$(AVAHI_CFLAGS) \
|
||||
@@ -130,7 +128,6 @@ libmpd_a_SOURCES = \
|
||||
src/IOThread.cxx src/IOThread.hxx \
|
||||
src/Instance.cxx src/Instance.hxx \
|
||||
src/win32/Win32Main.cxx \
|
||||
src/osx/OSXMain.cxx \
|
||||
src/GlobalEvents.cxx src/GlobalEvents.hxx \
|
||||
src/MixRampInfo.hxx \
|
||||
src/MusicBuffer.cxx src/MusicBuffer.hxx \
|
||||
@@ -284,13 +281,13 @@ android/build/build.xml: android/AndroidManifest.xml
|
||||
ln -s $(abs_srcdir)/android/res/values android/build/res
|
||||
$(ANDROID_SDK)/tools/android update project --path android/build --target android-17
|
||||
|
||||
android/build/bin/classes/org/musicpd/Bridge.class: android/src/Bridge.java android/build/build.xml
|
||||
android/build/bin/classes/org/musicpd/Bridge.class: android/src/Bridge.java android/build/build.xml android/build/res/drawable/icon.png
|
||||
cd android/build && ant compile-jni-classes
|
||||
|
||||
android/build/include/org_musicpd_Bridge.h: android/build/bin/classes/org/musicpd/Bridge.class
|
||||
javah -classpath $(ANDROID_SDK)/platforms/android-17/android.jar:android/build/bin/classes -d $(@D) org.musicpd.Bridge
|
||||
|
||||
libmpd_a_DEPENDENCIES += 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
|
||||
mkdir -p $(@D)
|
||||
@@ -829,7 +826,6 @@ libdecoder_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||
$(WAVPACK_CFLAGS) \
|
||||
$(MAD_CFLAGS) \
|
||||
$(MPG123_CFLAGS) \
|
||||
$(MP4V2_CFLAGS) \
|
||||
$(OPUS_CFLAGS) \
|
||||
$(FFMPEG_CFLAGS) \
|
||||
$(MPCDEC_CFLAGS) \
|
||||
@@ -849,7 +845,6 @@ DECODER_LIBS = \
|
||||
$(WAVPACK_LIBS) \
|
||||
$(MAD_LIBS) \
|
||||
$(MPG123_LIBS) \
|
||||
$(MP4V2_LIBS) \
|
||||
$(OPUS_LIBS) \
|
||||
$(FFMPEG_LIBS2) \
|
||||
$(MPCDEC_LIBS) \
|
||||
@@ -964,12 +959,6 @@ noinst_LIBRARIES += libmodplug_decoder_plugin.a
|
||||
DECODER_LIBS += libmodplug_decoder_plugin.a $(MODPLUG_LIBS)
|
||||
endif
|
||||
|
||||
if HAVE_MP4V2
|
||||
libdecoder_a_SOURCES += \
|
||||
src/decoder/plugins/Mp4v2DecoderPlugin.cxx \
|
||||
src/decoder/plugins/Mp4v2DecoderPlugin.hxx
|
||||
endif
|
||||
|
||||
if ENABLE_SIDPLAY
|
||||
libdecoder_a_SOURCES += \
|
||||
src/decoder/plugins/SidplayDecoderPlugin.cxx \
|
||||
@@ -1113,6 +1102,7 @@ endif
|
||||
#
|
||||
|
||||
libinput_a_SOURCES = \
|
||||
src/input/Domain.cxx src/input/Domain.hxx \
|
||||
src/input/Init.cxx src/input/Init.hxx \
|
||||
src/input/Registry.cxx src/input/Registry.hxx \
|
||||
src/input/Open.cxx \
|
||||
@@ -1133,7 +1123,6 @@ libinput_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||
$(NFS_CFLAGS) \
|
||||
$(CDIO_PARANOIA_CFLAGS) \
|
||||
$(FFMPEG_CFLAGS) \
|
||||
$(DESPOTIFY_CFLAGS) \
|
||||
$(MMS_CFLAGS)
|
||||
|
||||
INPUT_LIBS = \
|
||||
@@ -1143,7 +1132,6 @@ INPUT_LIBS = \
|
||||
$(NFS_LIBS) \
|
||||
$(CDIO_PARANOIA_LIBS) \
|
||||
$(FFMPEG_LIBS2) \
|
||||
$(DESPOTIFY_LIBS) \
|
||||
$(MMS_LIBS)
|
||||
|
||||
if HAVE_ALSA
|
||||
@@ -1189,15 +1177,6 @@ libinput_a_SOURCES += \
|
||||
src/input/plugins/MmsInputPlugin.cxx src/input/plugins/MmsInputPlugin.hxx
|
||||
endif
|
||||
|
||||
if ENABLE_DESPOTIFY
|
||||
libinput_a_SOURCES += \
|
||||
src/lib/despotify/DespotifyUtils.cxx \
|
||||
src/lib/despotify/DespotifyUtils.hxx \
|
||||
src/input/plugins/DespotifyInputPlugin.cxx \
|
||||
src/input/plugins/DespotifyInputPlugin.hxx
|
||||
endif
|
||||
|
||||
|
||||
liboutput_plugins_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||
$(AO_CFLAGS) \
|
||||
$(ALSA_CFLAGS) \
|
||||
@@ -1240,6 +1219,7 @@ liboutput_plugins_a_SOURCES = \
|
||||
|
||||
MIXER_LIBS = \
|
||||
libmixer_plugins.a \
|
||||
$(ALSA_LIBS) \
|
||||
$(PULSE_LIBS)
|
||||
|
||||
MIXER_API_SRC = \
|
||||
@@ -1402,14 +1382,6 @@ PLAYLIST_LIBS = \
|
||||
$(EXPAT_LIBS) \
|
||||
$(FLAC_LIBS)
|
||||
|
||||
if ENABLE_DESPOTIFY
|
||||
libplaylist_plugins_a_SOURCES += \
|
||||
src/lib/despotify/DespotifyUtils.cxx \
|
||||
src/lib/despotify/DespotifyUtils.hxx \
|
||||
src/playlist/plugins/DespotifyPlaylistPlugin.cxx \
|
||||
src/playlist/plugins/DespotifyPlaylistPlugin.hxx
|
||||
endif
|
||||
|
||||
if ENABLE_SOUNDCLOUD
|
||||
libplaylist_plugins_a_SOURCES += \
|
||||
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx \
|
||||
@@ -1646,12 +1618,6 @@ if HAVE_LIBUPNP
|
||||
test_run_neighbor_explorer_SOURCES += src/lib/expat/ExpatParser.cxx
|
||||
endif
|
||||
|
||||
if ENABLE_DESPOTIFY
|
||||
test_run_neighbor_explorer_SOURCES += \
|
||||
src/lib/despotify/DespotifyUtils.cxx \
|
||||
src/lib/despotify/DespotifyUtils.hxx
|
||||
endif
|
||||
|
||||
endif
|
||||
|
||||
if ENABLE_ARCHIVE
|
||||
@@ -2141,19 +2107,11 @@ user_DATA = $(wildcard doc/user/*.html)
|
||||
developerdir = $(docdir)/developer
|
||||
developer_DATA = $(wildcard doc/developer/*.html)
|
||||
|
||||
if HAVE_XMLTO
|
||||
|
||||
DOCBOOK_HTML = $(patsubst %.xml,%/index.html,$(DOCBOOK_FILES))
|
||||
|
||||
$(DOCBOOK_HTML): %/index.html: %.xml
|
||||
$(XMLTO) -o $(@D) --stringparam chunker.output.encoding=utf-8 html --stringparam use.id.as.filename=1 $<
|
||||
|
||||
else
|
||||
|
||||
DOCBOOK_HTML =
|
||||
|
||||
endif
|
||||
|
||||
doc/api/html/index.html: doc/doxygen.conf
|
||||
@$(MKDIR_P) $(@D)
|
||||
$(DOXYGEN) $<
|
||||
@@ -2194,4 +2152,12 @@ EXTRA_DIST = $(doc_DATA) autogen.sh \
|
||||
test/test_archive_zzip.sh \
|
||||
$(wildcard scripts/*.sh) \
|
||||
$(man_MANS) $(DOCBOOK_FILES) doc/mpdconf.example doc/doxygen.conf \
|
||||
systemd/mpd.socket \
|
||||
android/AndroidManifest.xml \
|
||||
android/build.py \
|
||||
android/custom_rules.xml \
|
||||
android/res/values/strings.xml \
|
||||
android/src/Bridge.java \
|
||||
android/src/Loader.java \
|
||||
android/src/Main.java \
|
||||
src/win32/mpd_win32_rc.rc.in src/win32/mpd.ico
|
||||
|
176
NEWS
176
NEWS
@@ -1,3 +1,141 @@
|
||||
ver 0.19.12 (2015/12/15)
|
||||
* fix assertion failure on malformed UTF-8 tag
|
||||
* fix build failure on non-Linux systems
|
||||
* fix LimitRTTIME in systemd unit file
|
||||
|
||||
ver 0.19.11 (2015/10/27)
|
||||
* tags
|
||||
- ape: fix buffer overflow
|
||||
* decoder
|
||||
- ffmpeg: fix crash due to wrong avio_alloc_context() call
|
||||
- gme: don't loop forever, fall back to GME's default play length
|
||||
* encoder
|
||||
- flac: fix crash with 32 bit playback
|
||||
* mixer
|
||||
- fix mixer lag after enabling/disabling output
|
||||
|
||||
ver 0.19.10 (2015/06/21)
|
||||
* input
|
||||
- curl: fix deadlock on small responses
|
||||
- smbclient: fix DFF playback
|
||||
* decoder
|
||||
- ffmpeg: improve seeking accuracy
|
||||
- fix stuck stream tags
|
||||
* encoder
|
||||
- opus: fix bogus granulepos
|
||||
* output
|
||||
- fix failure to open device right after booting
|
||||
* neighbor
|
||||
- nfs: fix deadlock when connecting
|
||||
* fix "single" mode breakage due to queue edits
|
||||
|
||||
ver 0.19.9 (2015/02/06)
|
||||
* decoder
|
||||
- dsdiff, dsf: raise ID3 tag limit to 1 MB
|
||||
* playlist: fix loading duplicate tag types from state file
|
||||
* despotify: remove defunct plugin
|
||||
* fix clock integer overflow on OS X
|
||||
* fix gcc 5.0 warnings
|
||||
* fix build failure with uClibc
|
||||
* fix build failure on non-POSIX operating systems
|
||||
* fix dependency issue on parallel Android build
|
||||
* fix database/state file saving on Windows
|
||||
|
||||
ver 0.19.8 (2015/01/14)
|
||||
* input
|
||||
- curl: fix bug after rewinding from end-of-file
|
||||
- mms: reduce delay at the beginning of playback
|
||||
* decoder
|
||||
- dsdiff, dsf: allow ID3 tags larger than 4 kB
|
||||
- ffmpeg: support interleaved floating point
|
||||
* fix clang 3.6 warnings
|
||||
* fix build failure on NetBSD
|
||||
|
||||
ver 0.19.7 (2014/12/17)
|
||||
* input
|
||||
- nfs: fix crash while canceling a failing file open operation
|
||||
- nfs: fix memory leak on connection failure
|
||||
- nfs: fix reconnect after mount failure
|
||||
- nfs: implement mount timeout (60 seconds)
|
||||
* storage
|
||||
- nfs: implement I/O timeout (60 seconds)
|
||||
* playlist
|
||||
- embcue: fix filename suffix detection
|
||||
- don't skip non-existent songs in "listplaylist"
|
||||
* decoder
|
||||
- ffmpeg: fix time stamp underflow
|
||||
* fix memory allocator bug on Windows
|
||||
|
||||
ver 0.19.6 (2014/12/08)
|
||||
* decoder
|
||||
- ffmpeg: support FFmpeg 2.5
|
||||
* fix build failure with musl
|
||||
* android
|
||||
- update libFLAC to 1.3.1
|
||||
- update FFmpeg to 2.5
|
||||
|
||||
ver 0.19.5 (2014/11/26)
|
||||
* input
|
||||
- nfs: fix crash on connection failure
|
||||
* archive
|
||||
- zzip: fix crash after seeking
|
||||
* decoder
|
||||
- dsdiff, dsf, opus: fix deadlock while seeking
|
||||
- mp4v2: remove because of incompatible license
|
||||
|
||||
ver 0.19.4 (2014/11/18)
|
||||
* protocol
|
||||
- workaround for buggy clients that send "add /"
|
||||
* decoder
|
||||
- ffmpeg: support opus
|
||||
- opus: add MIME types audio/ogg and application/ogg
|
||||
* fix crash on failed filename charset conversion
|
||||
* fix local socket detection from uid=0 (root)
|
||||
|
||||
ver 0.19.3 (2014/11/11)
|
||||
* protocol
|
||||
- fix "(null)" result string to "list" when AlbumArtist is disabled
|
||||
* database
|
||||
- upnp: fix breakage due to malformed URIs
|
||||
* input
|
||||
- curl: another fix for redirected streams
|
||||
* decoder
|
||||
- audiofile: fix crash while playing streams
|
||||
- audiofile: fix bit rate calculation
|
||||
- ffmpeg: support opus
|
||||
- opus: fix bogus duration on streams
|
||||
- opus: support chained streams
|
||||
- opus: improved error logging
|
||||
* fix distorted audio with soxr resampler
|
||||
* fix build failure on Mac OS X with non-Apple compilers
|
||||
|
||||
ver 0.19.2 (2014/11/02)
|
||||
* input
|
||||
- curl: fix redirected streams
|
||||
* playlist
|
||||
- don't allow empty playlist name
|
||||
- m3u: don't ignore unterminated last line
|
||||
- m3u: recognize the file suffix ".m3u8"
|
||||
* decoder
|
||||
- ignore URI query string for plugin detection
|
||||
- faad: remove workaround for ancient libfaad2 ABI bug
|
||||
- ffmpeg: recognize MIME type audio/aacp
|
||||
- mad: fix negative replay gain values
|
||||
* output
|
||||
- fix memory leak after filter initialization error
|
||||
- fall back to PCM if given DSD sample rate is not supported
|
||||
* fix assertion failure on unsupported PCM conversion
|
||||
* auto-disable plugins that require GLib when --disable-glib is used
|
||||
|
||||
ver 0.19.1 (2014/10/19)
|
||||
* input
|
||||
- mms: fix deadlock bug
|
||||
* playlist
|
||||
- extm3u: fix Extended M3U detection
|
||||
- m3u, extm3u, cue: fix truncated lines
|
||||
* fix build failure on Mac OS X
|
||||
* add missing file systemd/mpd.socket to tarball
|
||||
|
||||
ver 0.19 (2014/10/10)
|
||||
* protocol
|
||||
- new commands "addtagid", "cleartagid", "listfiles", "listmounts",
|
||||
@@ -76,6 +214,44 @@ ver 0.19 (2014/10/10)
|
||||
* install systemd unit for socket activation
|
||||
* Android port
|
||||
|
||||
ver 0.18.23 (2015/02/06)
|
||||
* despotify: remove defunct plugin
|
||||
* fix clock integer overflow on OS X
|
||||
* fix gcc 5.0 warnings
|
||||
|
||||
ver 0.18.22 (2015/01/14)
|
||||
* fix clang 3.6 warnings
|
||||
|
||||
ver 0.18.21 (2014/12/17)
|
||||
* playlist
|
||||
- embcue: fix filename suffix detection
|
||||
* decoder
|
||||
- ffmpeg: fix time stamp underflow
|
||||
|
||||
ver 0.18.20 (2014/12/08)
|
||||
* decoder
|
||||
- ffmpeg: support FFmpeg 2.5
|
||||
* fix build failure with musl
|
||||
|
||||
ver 0.18.19 (2014/11/26)
|
||||
* archive
|
||||
- zzip: fix crash after seeking
|
||||
|
||||
ver 0.18.18 (2014/11/18)
|
||||
* decoder
|
||||
- ffmpeg: support opus
|
||||
* fix crash on failed filename charset conversion
|
||||
* fix local socket detection from uid=0 (root)
|
||||
|
||||
ver 0.18.17 (2014/11/02)
|
||||
* playlist
|
||||
- don't allow empty playlist name
|
||||
- m3u: recognize the file suffix ".m3u8"
|
||||
* decoder
|
||||
- ignore URI query string for plugin detection
|
||||
- faad: remove workaround for ancient libfaad2 ABI bug
|
||||
- ffmpeg: recognize MIME type audio/aacp
|
||||
|
||||
ver 0.18.16 (2014/09/26)
|
||||
* fix DSD breakage due to typo in configure.ac
|
||||
|
||||
|
@@ -2,8 +2,8 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.musicpd"
|
||||
android:installLocation="auto"
|
||||
android:versionCode="6"
|
||||
android:versionName="0.19">
|
||||
android:versionCode="13"
|
||||
android:versionName="0.19.9">
|
||||
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17"/>
|
||||
|
||||
|
@@ -23,7 +23,7 @@ if not os.path.isdir(ndk_path):
|
||||
sys.exit(1)
|
||||
|
||||
# the path to the MPD sources
|
||||
mpd_path = os.path.dirname(os.path.dirname(sys.argv[0]))
|
||||
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
|
||||
|
||||
# output directories
|
||||
lib_path = os.path.abspath('lib')
|
||||
@@ -40,8 +40,8 @@ build_arch = 'linux-x86_64'
|
||||
os.environ['PKG_CONFIG_LIBDIR'] = os.path.join(root_path, 'lib/pkgconfig')
|
||||
|
||||
# select the NDK compiler
|
||||
gcc_version = '4.8'
|
||||
llvm_version = '3.3'
|
||||
gcc_version = '4.9'
|
||||
llvm_version = '3.5'
|
||||
|
||||
# select the NDK target
|
||||
ndk_arch = 'arm'
|
||||
@@ -314,8 +314,8 @@ thirdparty_libs = [
|
||||
),
|
||||
|
||||
AutotoolsProject(
|
||||
'https://svn.xiph.org/releases/flac/flac-1.3.0.tar.xz',
|
||||
'13b5c214cee8373464d3d65dee362cdd',
|
||||
'http://downloads.xiph.org/releases/flac/flac-1.3.1.tar.xz',
|
||||
'b9922c9a0378c88d3e901b234f852698',
|
||||
'lib/libFLAC.a',
|
||||
[
|
||||
'--disable-shared', '--enable-static',
|
||||
@@ -341,8 +341,8 @@ thirdparty_libs = [
|
||||
),
|
||||
|
||||
FfmpegProject(
|
||||
'http://www.ffmpeg.org/releases/ffmpeg-2.2.3.tar.bz2',
|
||||
'dbb5b6b69bd010916f17df0ae596e0b1',
|
||||
'http://ffmpeg.org/releases/ffmpeg-2.5.tar.bz2',
|
||||
'4346fe710cc6bdd981f6534d2420d1ab',
|
||||
'lib/libavcodec.a',
|
||||
[
|
||||
'--disable-shared', '--enable-static',
|
||||
@@ -366,8 +366,8 @@ thirdparty_libs = [
|
||||
),
|
||||
|
||||
AutotoolsProject(
|
||||
'http://curl.haxx.se/download/curl-7.37.0.tar.lzma',
|
||||
'54bfd1eb5214f604186d6f5ac61c7781',
|
||||
'http://curl.haxx.se/download/curl-7.39.0.tar.lzma',
|
||||
'e9aa6dec29920eba8ef706ea5823bad7',
|
||||
'lib/libcurl.a',
|
||||
[
|
||||
'--disable-shared', '--enable-static',
|
||||
|
83
configure.ac
83
configure.ac
@@ -1,10 +1,10 @@
|
||||
AC_PREREQ(2.60)
|
||||
|
||||
AC_INIT(mpd, 0.19, musicpd-dev-team@lists.sourceforge.net)
|
||||
AC_INIT(mpd, 0.19.12, musicpd-dev-team@lists.sourceforge.net)
|
||||
|
||||
VERSION_MAJOR=0
|
||||
VERSION_MINOR=19
|
||||
VERSION_REVISION=0
|
||||
VERSION_REVISION=12
|
||||
VERSION_EXTRA=0
|
||||
|
||||
AC_CONFIG_SRCDIR([src/Main.cxx])
|
||||
@@ -206,6 +206,7 @@ if test x$host_is_linux = xyes; then
|
||||
fi
|
||||
|
||||
AC_CHECK_FUNCS(getpwnam_r getpwuid_r)
|
||||
AC_CHECK_FUNCS(strndup)
|
||||
|
||||
if test x$host_is_linux = xyes; then
|
||||
MPD_OPTIONAL_FUNC(eventfd, eventfd, USE_EVENTFD)
|
||||
@@ -293,7 +294,9 @@ fi
|
||||
AC_ARG_ENABLE(libmpdclient,
|
||||
AS_HELP_STRING([--enable-libmpdclient],
|
||||
[enable support for the MPD client]),,
|
||||
enable_libmpdclient=$database_auto)
|
||||
enable_libmpdclient=auto)
|
||||
MPD_DEPENDS([enable_libmpdclient], [enable_database],
|
||||
[Cannot use --enable-libmpdclient with --disable-database])
|
||||
|
||||
AC_ARG_ENABLE(expat,
|
||||
AS_HELP_STRING([--enable-expat],
|
||||
@@ -303,7 +306,9 @@ AC_ARG_ENABLE(expat,
|
||||
AC_ARG_ENABLE(upnp,
|
||||
AS_HELP_STRING([--enable-upnp],
|
||||
[enable UPnP client support (default: auto)]),,
|
||||
enable_upnp=$database_auto)
|
||||
enable_upnp=auto)
|
||||
MPD_DEPENDS([enable_upnp], [enable_database],
|
||||
[Cannot use --enable-upnp with --disable-database])
|
||||
|
||||
AC_ARG_ENABLE(adplug,
|
||||
AS_HELP_STRING([--enable-adplug],
|
||||
@@ -323,6 +328,8 @@ AC_ARG_ENABLE(ao,
|
||||
AS_HELP_STRING([--enable-ao],
|
||||
[enable support for libao]),,
|
||||
enable_ao=auto)
|
||||
MPD_DEPENDS([enable_ao], [enable_glib],
|
||||
[Cannot use --enable-ao with --disable-glib])
|
||||
|
||||
AC_ARG_ENABLE(audiofile,
|
||||
AS_HELP_STRING([--enable-audiofile],
|
||||
@@ -343,6 +350,8 @@ AC_ARG_ENABLE(cdio-paranoia,
|
||||
AS_HELP_STRING([--enable-cdio-paranoia],
|
||||
[enable support for audio CD support]),,
|
||||
enable_cdio_paranoia=auto)
|
||||
MPD_DEPENDS([enable_cdio_paranoia], [enable_glib],
|
||||
[Cannot use --enable-cdio-paranoia with --disable-glib])
|
||||
|
||||
AC_ARG_ENABLE(curl,
|
||||
AS_HELP_STRING([--enable-curl],
|
||||
@@ -398,11 +407,15 @@ AC_ARG_ENABLE(gme,
|
||||
AS_HELP_STRING([--enable-gme],
|
||||
[enable Blargg's game music emulator plugin]),,
|
||||
enable_gme=auto)
|
||||
MPD_DEPENDS([enable_gme], [enable_glib],
|
||||
[Cannot use --enable-gme with --disable-glib])
|
||||
|
||||
AC_ARG_ENABLE(httpd-output,
|
||||
AS_HELP_STRING([--enable-httpd-output],
|
||||
[enables the HTTP server output]),,
|
||||
[enable_httpd_output=auto])
|
||||
MPD_DEPENDS([enable_httpd_output], [enable_glib],
|
||||
[Cannot use --enable-httpd-output with --disable-glib])
|
||||
|
||||
AC_ARG_ENABLE(id3,
|
||||
AS_HELP_STRING([--enable-id3],
|
||||
@@ -428,18 +441,17 @@ AC_ARG_ENABLE(jack,
|
||||
AS_HELP_STRING([--enable-jack],
|
||||
[enable jack support]),,
|
||||
enable_jack=auto)
|
||||
MPD_DEPENDS([enable_jack], [enable_glib],
|
||||
[Cannot use --enable-jack with --disable-glib])
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
AC_ARG_ENABLE(despotify,
|
||||
AS_HELP_STRING([--enable-despotify],
|
||||
[enable support for despotify (default: disable)]),,
|
||||
[enable_despotify=no])
|
||||
|
||||
AC_ARG_ENABLE(soundcloud,
|
||||
AS_HELP_STRING([--enable-soundcloud],
|
||||
[enable support for soundcloud.com]),,
|
||||
[enable_soundcloud=auto])
|
||||
MPD_DEPENDS([enable_soundcloud], [enable_glib],
|
||||
[Cannot use --enable-soundcloud with --disable-glib])
|
||||
|
||||
AC_ARG_ENABLE(lame-encoder,
|
||||
AS_HELP_STRING([--enable-lame-encoder],
|
||||
@@ -480,11 +492,6 @@ AC_ARG_ENABLE(modplug,
|
||||
[enable modplug decoder plugin]),,
|
||||
enable_modplug=auto)
|
||||
|
||||
AC_ARG_ENABLE(mp4v2,
|
||||
AS_HELP_STRING([--enable-mp4v2],
|
||||
[enable libmp4v2 decoder plugin]),,
|
||||
enable_mp4v2=auto)
|
||||
|
||||
AC_ARG_ENABLE(mpc,
|
||||
AS_HELP_STRING([--enable-mpc],
|
||||
[disable musepack (MPC) support (default: auto)]),,
|
||||
@@ -534,6 +541,8 @@ AC_ARG_ENABLE(sidplay,
|
||||
AS_HELP_STRING([--enable-sidplay],
|
||||
[enable C64 SID support via libsidplay2]),,
|
||||
enable_sidplay=auto)
|
||||
MPD_DEPENDS([enable_sidplay], [enable_glib],
|
||||
[Cannot use --enable-sidplay with --disable-glib])
|
||||
|
||||
AC_ARG_ENABLE(shine-encoder,
|
||||
AS_HELP_STRING([--enable-shine-encoder],
|
||||
@@ -559,6 +568,8 @@ AC_ARG_ENABLE(sqlite,
|
||||
AS_HELP_STRING([--enable-sqlite],
|
||||
[enable support for the SQLite database]),,
|
||||
[enable_sqlite=$database_auto])
|
||||
MPD_DEPENDS([enable_sqlite], [enable_glib],
|
||||
[Cannot use --enable-sqlite with --disable-glib])
|
||||
|
||||
AC_ARG_ENABLE(systemd-daemon,
|
||||
AS_HELP_STRING([--enable-systemd-daemon],
|
||||
@@ -599,6 +610,8 @@ AC_ARG_ENABLE(vorbis-encoder,
|
||||
AS_HELP_STRING([--enable-vorbis-encoder],
|
||||
[enable the Ogg Vorbis encoder]),,
|
||||
[enable_vorbis_encoder=auto])
|
||||
MPD_DEPENDS([enable_vorbis_encoder], [enable_glib],
|
||||
[Cannot use --enable-vorbis-encoder with --disable-glib])
|
||||
|
||||
AC_ARG_ENABLE(wave-encoder,
|
||||
AS_HELP_STRING([--enable-wave-encoder],
|
||||
@@ -609,6 +622,8 @@ AC_ARG_ENABLE(wavpack,
|
||||
AS_HELP_STRING([--enable-wavpack],
|
||||
[enable WavPack support]),,
|
||||
enable_wavpack=auto)
|
||||
MPD_DEPENDS([enable_wavpack], [enable_glib],
|
||||
[Cannot use --enable-wavpack with --disable-glib])
|
||||
|
||||
AC_ARG_ENABLE(werror,
|
||||
AS_HELP_STRING([--enable-werror],
|
||||
@@ -960,14 +975,6 @@ if test x$enable_nfs = xyes; then
|
||||
fi
|
||||
AM_CONDITIONAL(ENABLE_NFS, test x$enable_nfs = xyes)
|
||||
|
||||
dnl --------------------------------- Despotify ---------------------------------
|
||||
MPD_AUTO_PKG(despotify, DESPOTIFY, [despotify],
|
||||
[Despotify support], [despotify not found])
|
||||
if test x$enable_despotify = xyes; then
|
||||
AC_DEFINE(ENABLE_DESPOTIFY, 1, [Define when despotify is enabled])
|
||||
fi
|
||||
AM_CONDITIONAL(ENABLE_DESPOTIFY, test x$enable_despotify = xyes)
|
||||
|
||||
dnl --------------------------------- Soundcloud ------------------------------
|
||||
if test x$enable_soundcloud != xno; then
|
||||
PKG_CHECK_MODULES([YAJL], [yajl >= 2.0],
|
||||
@@ -1240,24 +1247,6 @@ if test x$enable_modplug = xyes; then
|
||||
fi
|
||||
AM_CONDITIONAL(HAVE_MODPLUG, test x$enable_modplug = xyes)
|
||||
|
||||
dnl -------------------------------- libmp4v2 ---------------------------------
|
||||
if test x$enable_aac = xyes; then
|
||||
MPD_AUTO_LIB(mp4v2, MP4V2, mp4v2, MP4Create, [-lmp4v2], [],
|
||||
[mp4v2], [libmp4v2 not found])
|
||||
|
||||
if test x$enable_mp4v2 = xyes; then
|
||||
AC_DEFINE(HAVE_MP4V2, 1, [Define to use libmp4v2 for MP4 decoding])
|
||||
fi
|
||||
else
|
||||
if test x$enable_mp4v2 = xyes; then
|
||||
AC_MSG_ERROR([MP4V2 requires AAC!])
|
||||
fi
|
||||
|
||||
enable_mp4v2=no
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(HAVE_MP4V2, test x$enable_mp4v2 = xyes)
|
||||
|
||||
dnl -------------------------------- libopus ----------------------------------
|
||||
MPD_AUTO_PKG(opus, OPUS, [opus ogg],
|
||||
[opus decoder plugin], [libopus not found])
|
||||
@@ -1709,8 +1698,11 @@ dnl Documentation
|
||||
dnl ---------------------------------------------------------------------------
|
||||
if test x$enable_documentation = xyes; then
|
||||
AC_PATH_PROG(XMLTO, xmlto)
|
||||
if test x$XMLTO = x; then
|
||||
AC_MSG_ERROR([xmlto not found])
|
||||
fi
|
||||
|
||||
AC_SUBST(XMLTO)
|
||||
AM_CONDITIONAL(HAVE_XMLTO, test x$XMLTO != x)
|
||||
|
||||
AC_PATH_PROG(DOXYGEN, doxygen)
|
||||
if test x$DOXYGEN = x; then
|
||||
@@ -1718,8 +1710,6 @@ if test x$enable_documentation = xyes; then
|
||||
fi
|
||||
|
||||
AC_SUBST(DOXYGEN)
|
||||
else
|
||||
AM_CONDITIONAL(HAVE_XMLTO, false)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL(ENABLE_DOCUMENTATION, test x$enable_documentation = xyes)
|
||||
@@ -1826,9 +1816,14 @@ results(ipv6, "IPv6")
|
||||
results(tcp, "TCP")
|
||||
results(un,[UNIX Domain Sockets])
|
||||
|
||||
printf '\nStorage support:\n\t'
|
||||
results(nfs, [NFS])
|
||||
results(smbclient, [SMB])
|
||||
|
||||
printf '\nFile format support:\n\t'
|
||||
results(aac, [AAC])
|
||||
results(adplug, [AdPlug])
|
||||
results(dsd, [DSD])
|
||||
results(sidplay, [C64 SID])
|
||||
results(ffmpeg, [FFMPEG])
|
||||
results(flac, [FLAC])
|
||||
@@ -1838,7 +1833,6 @@ printf '\n\t'
|
||||
results(sndfile, [libsndfile])
|
||||
results(mikmod, [MikMod])
|
||||
results(modplug, [MODPLUG])
|
||||
results(mp4v2, [MP4V2])
|
||||
results(mad, [MAD])
|
||||
results(mpg123, [MPG123])
|
||||
results(mpc, [Musepack])
|
||||
@@ -1897,7 +1891,6 @@ printf '\nStreaming support:\n\t'
|
||||
results(cdio_paranoia, [CDIO_PARANOIA])
|
||||
results(curl,[CURL])
|
||||
results(smbclient,[SMBCLIENT])
|
||||
results(despotify,[Despotify])
|
||||
results(soundcloud,[Soundcloud])
|
||||
printf '\n\t'
|
||||
results(mms,[MMS])
|
||||
|
@@ -195,16 +195,6 @@ of database.
|
||||
Limit the depth of the directories being watched, 0 means only watch
|
||||
the music directory itself. There is no limit by default.
|
||||
.TP
|
||||
.B despotify_user <name>
|
||||
This specifies the user to use when logging in to Spotify using the despotify plugins.
|
||||
.TP
|
||||
.B despotify_password <name>
|
||||
This specifies the password to use when logging in to Spotify using the despotify plugins.
|
||||
.TP
|
||||
.B despotify_high_bitrate <yes or no>
|
||||
This specifies if the requested bitrate for Spotify should be high or not. Higher sounds
|
||||
better but requires more processing and higher bandwidth. Default is yes.
|
||||
.TP
|
||||
.SH REQUIRED AUDIO OUTPUT PARAMETERS
|
||||
.TP
|
||||
.B type <type>
|
||||
|
@@ -1141,7 +1141,7 @@ OK
|
||||
</term>
|
||||
<listitem>
|
||||
<para>
|
||||
Searches case-sensitively for partial matches in the
|
||||
Searches case-insensitively for partial matches in the
|
||||
current playlist.
|
||||
</para>
|
||||
</listitem>
|
||||
@@ -1533,6 +1533,7 @@ OK
|
||||
<command>count</command>
|
||||
<arg choice="req"><replaceable>TAG</replaceable></arg>
|
||||
<arg choice="req"><replaceable>NEEDLE</replaceable></arg>
|
||||
<arg choice="opt"><replaceable>...</replaceable></arg>
|
||||
<arg choice="opt">group</arg>
|
||||
<arg choice="opt"><replaceable>GROUPTYPE</replaceable></arg>
|
||||
</cmdsynopsis>
|
||||
|
194
doc/user.xml
194
doc/user.xml
@@ -89,7 +89,7 @@ cd mpd-version</programlisting>
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
apt-get install g++ automake autoconf \
|
||||
apt-get install g++ \
|
||||
libmad0-dev libmpg123-dev libid3tag0-dev \
|
||||
libflac-dev libvorbis-dev libopus-dev \
|
||||
libadplug-dev libaudiofile-dev libsndfile1-dev libfaad-dev \
|
||||
@@ -98,19 +98,21 @@ apt-get install g++ automake autoconf \
|
||||
libsidplay2-dev libsidutils-dev libresid-builder-dev \
|
||||
libavcodec-dev libavformat-dev \
|
||||
libmp3lame-dev \
|
||||
libsamplerate0-dev \
|
||||
libsamplerate0-dev libsoxr-dev \
|
||||
libbz2-dev libcdio-paranoia-dev libiso9660-dev libmms-dev \
|
||||
libzzip-dev \
|
||||
libcurl4-gnutls-dev libyajl-dev \
|
||||
libcurl4-gnutls-dev libyajl-dev libexpat-dev \
|
||||
libasound2-dev libao-dev libjack-jackd2-dev libopenal-dev \
|
||||
libpulse-dev libroar-dev libshout3-dev \
|
||||
libmpdclient-dev \
|
||||
libnfs-dev libsmbclient-dev \
|
||||
libupnp-dev \
|
||||
libavahi-client-dev \
|
||||
libsqlite3-dev \
|
||||
libsystemd-daemon-dev libwrap0-dev \
|
||||
libcppunit-dev xmlto \
|
||||
libboost-dev \
|
||||
libglib2.0-dev
|
||||
libglib2.0-dev libicu-dev
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
@@ -313,9 +315,8 @@ systemctl start mpd.socket</programlisting>
|
||||
</para>
|
||||
|
||||
<programlisting>input {
|
||||
plugin "despotify"
|
||||
user "foo"
|
||||
password "bar"
|
||||
plugin "curl"
|
||||
proxy "proxy.local"
|
||||
}
|
||||
</programlisting>
|
||||
|
||||
@@ -1189,6 +1190,58 @@ database {
|
||||
plugin).
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section id="realtime">
|
||||
<title>Real-Time Scheduling</title>
|
||||
|
||||
<para>
|
||||
On Linux, <application>MPD</application> attempts to configure
|
||||
<ulink
|
||||
url="https://en.wikipedia.org/wiki/Real-time_computing">real-time
|
||||
scheduling</ulink> for some threads that benefit from it.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This is only possible you allow <application>MPD</application>
|
||||
to do it. This privilege is controlled by
|
||||
<varname>RLIMIT_RTPRIO</varname>
|
||||
<varname>RLIMIT_RTTIME</varname>. You can configure this
|
||||
privilege with <command>ulimit</command> before launching
|
||||
<application>MPD</application>:
|
||||
</para>
|
||||
|
||||
<programlisting>ulimit -HS -r 50; mpd</programlisting>
|
||||
|
||||
<para>
|
||||
Or you can use the <command>prlimit</command> program from the
|
||||
<application>util-linux</application> package:
|
||||
</para>
|
||||
|
||||
<programlisting>prlimit --rtprio=50 --rttime=unlimited mpd</programlisting>
|
||||
|
||||
<para>
|
||||
The <application>systemd</application> service file shipped
|
||||
with <application>MPD</application> comes with this setting.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
This works only if the Linux kernel was compiled with
|
||||
<varname>CONFIG_RT_GROUP_SCHED</varname> disabled. Use the
|
||||
following command to check this option for your current
|
||||
kernel:
|
||||
</para>
|
||||
|
||||
<programlisting>zgrep ^CONFIG_RT_GROUP_SCHED /proc/config.gz</programlisting>
|
||||
|
||||
<note>
|
||||
<para>
|
||||
There is a rumor that real-time scheduling improves audio
|
||||
quality. That is not true. All it does is reduce the
|
||||
probability of skipping (audio buffer xruns) when the
|
||||
computer is under heavy load.
|
||||
</para>
|
||||
</note>
|
||||
</section>
|
||||
</chapter>
|
||||
|
||||
<chapter id="use">
|
||||
@@ -1738,66 +1791,6 @@ buffer_size: 16384</programlisting>
|
||||
</informaltable>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title><varname>despotify</varname></title>
|
||||
|
||||
<para>
|
||||
Plays <ulink url="http://www.spotify.com">Spotify</ulink> tracks using the despotify
|
||||
library. The despotify plugin uses a <filename>spt://</filename> URI and a Spotify
|
||||
URL. So for example, you can add a song with:
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<filename>mpc add spt://spotify:track:5qENVY0YEdZ7fiuOax70x1</filename>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You need a Spotify premium account to use this plugin, and you need
|
||||
to setup username and password in the configuration file. The
|
||||
configuration settings are global since the despotify playlist plugin
|
||||
use the same settings.
|
||||
</para>
|
||||
|
||||
<informaltable>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Setting</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>
|
||||
<varname>despotify_user</varname>
|
||||
</entry>
|
||||
<entry>
|
||||
Sets up the Spotify username (required)
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<varname>despotify_password</varname>
|
||||
</entry>
|
||||
<entry>
|
||||
Sets up the Spotify password (required)
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<varname>despotify_high_bitrate</varname>
|
||||
</entry>
|
||||
<entry>
|
||||
Set up if high bitrate should be used for Spotify tunes.
|
||||
High bitrate sounds better but slow systems can have problems
|
||||
with playback (default yes).
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title><varname>file</varname></title>
|
||||
|
||||
@@ -2654,7 +2647,8 @@ buffer_size: 16384</programlisting>
|
||||
/ <ulink
|
||||
url="http://icecast.org/"><application>IceCast</application></ulink>.
|
||||
HTTP streaming clients like
|
||||
<application>mplayer</application> can connect to it.
|
||||
<application>mplayer</application>, <application>VLC</application>,
|
||||
and <application>mpv</application> can connect to it.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@@ -3284,70 +3278,6 @@ buffer_size: 16384</programlisting>
|
||||
playlist files.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title><varname>despotify</varname></title>
|
||||
|
||||
<para>
|
||||
Adds <ulink url="http://www.spotify.com/">Spotify</ulink>
|
||||
playlists. Spotify playlists use the <filename>spt://</filename> URI,
|
||||
and a Spotify playlist URL. So for example, you can load a playlist
|
||||
with
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<filename>mpc load spt://spotify:user:simon.kagstrom:playlist:3SUwkOe5VbVHysZcidEZtH</filename>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
See the despotify input plugin for configuration options (username
|
||||
and password needs to be setup)
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title><varname>soundcloud</varname></title>
|
||||
|
||||
<para>
|
||||
Adds <ulink url="https://www.soundcloud.com/">Soundcloud</ulink>
|
||||
playlists. SoundCloud playlists use the <filename>soundcloud://</filename> URI,
|
||||
and with a number of arguments, you may load different playlists with
|
||||
</para>
|
||||
|
||||
<programlisting>
|
||||
mpc load soundcloud://track/TRACK_ID
|
||||
mpc load soundcloud://playlist/PLAYLIST_ID
|
||||
mpc load soundcloud://user/USERNAME
|
||||
mpc load soundcloud://search/SEARCH_QUERY
|
||||
mpc load soundcloud://url/https://soundcloud.com/ARTIST/TRACK-NAME
|
||||
</programlisting>
|
||||
|
||||
<informaltable>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Setting</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>
|
||||
<varname>apikey</varname>
|
||||
<parameter>client_id</parameter>
|
||||
</entry>
|
||||
<entry>
|
||||
User apikey/client_id can override the
|
||||
<application>MPD</application> token provided by
|
||||
SoundCloud.
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</chapter>
|
||||
</book>
|
||||
|
31
m4/faad.m4
31
m4/faad.m4
@@ -62,36 +62,7 @@ int main() {
|
||||
CPPFLAGS=$oldcppflags
|
||||
fi
|
||||
|
||||
if test x$enable_aac = xyes; then
|
||||
oldcflags=$CFLAGS
|
||||
oldlibs=$LIBS
|
||||
oldcppflags=$CPPFLAGS
|
||||
CFLAGS="$CFLAGS $FAAD_CFLAGS -Werror"
|
||||
LIBS="$LIBS $FAAD_LIBS"
|
||||
CPPFLAGS=$CFLAGS
|
||||
|
||||
AC_MSG_CHECKING(for broken libfaad headers)
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
#include <faad.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main() {
|
||||
unsigned char channels;
|
||||
uint32_t sample_rate;
|
||||
|
||||
NeAACDecInit2(NULL, NULL, 0, &sample_rate, &channels);
|
||||
return 0;
|
||||
}
|
||||
])],
|
||||
[AC_MSG_RESULT(correct)],
|
||||
[AC_MSG_RESULT(broken);
|
||||
AC_DEFINE(HAVE_FAAD_LONG, 1, [Define if faad.h uses the broken "unsigned long" pointers])])
|
||||
|
||||
CFLAGS=$oldcflags
|
||||
LIBS=$oldlibs
|
||||
CPPFLAGS=$oldcppflags
|
||||
else
|
||||
if test x$enable_aac = xno; then
|
||||
FAAD_LIBS=""
|
||||
FAAD_CFLAGS=""
|
||||
fi
|
||||
|
9
m4/mpd_depends.m4
Normal file
9
m4/mpd_depends.m4
Normal file
@@ -0,0 +1,9 @@
|
||||
AC_DEFUN([MPD_DEPENDS], [
|
||||
if test x$$2 = xno; then
|
||||
if test x$$1 = xauto; then
|
||||
$1=no
|
||||
elif test x$$1 = xyes; then
|
||||
AC_MSG_ERROR([$3])
|
||||
fi
|
||||
fi
|
||||
])
|
@@ -20,33 +20,45 @@
|
||||
#ifndef COMPILER_H
|
||||
#define COMPILER_H
|
||||
|
||||
#define GCC_CHECK_VERSION(major, minor) \
|
||||
(defined(__GNUC__) && \
|
||||
(__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
|
||||
#define GCC_MAKE_VERSION(major, minor, patchlevel) ((major) * 10000 + (minor) * 100 + patchlevel)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
#define GCC_VERSION GCC_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
|
||||
#else
|
||||
#define GCC_VERSION 0
|
||||
#endif
|
||||
|
||||
#define GCC_CHECK_VERSION(major, minor) \
|
||||
(defined(__GNUC__) && GCC_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
|
||||
|
||||
/**
|
||||
* Are we building with gcc (not clang or any other compiler) and a
|
||||
* version older than the specified one?
|
||||
*/
|
||||
#define GCC_OLDER_THAN(major, minor) \
|
||||
(defined(__GNUC__) && !defined(__clang__) && \
|
||||
GCC_VERSION < GCC_MAKE_VERSION(major, minor, 0))
|
||||
|
||||
#ifdef __clang__
|
||||
# define CLANG_VERSION (__clang_major__ * 10000 \
|
||||
+ __clang_minor__ * 100 \
|
||||
+ __clang_patchlevel__)
|
||||
# define CLANG_VERSION GCC_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
|
||||
# if __clang_major__ < 3
|
||||
# error Sorry, your clang version is too old. You need at least version 3.1.
|
||||
# endif
|
||||
#elif defined(__GNUC__)
|
||||
# if !GCC_CHECK_VERSION(4,6)
|
||||
# if GCC_OLDER_THAN(4,6)
|
||||
# error Sorry, your gcc version is too old. You need at least version 4.6.
|
||||
# endif
|
||||
#else
|
||||
# warning Untested compiler. Use at your own risk!
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Are we building with the specified version of clang or newer?
|
||||
*/
|
||||
#define CLANG_CHECK_VERSION(major, minor) \
|
||||
(defined(__clang__) && \
|
||||
CLANG_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
|
||||
|
||||
#if GCC_CHECK_VERSION(4,0)
|
||||
|
||||
/* GCC 4.x */
|
||||
@@ -141,7 +153,7 @@
|
||||
#if defined(__cplusplus)
|
||||
|
||||
/* support for C++11 "override" was added in gcc 4.7 */
|
||||
#if !defined(__clang__) && !GCC_CHECK_VERSION(4,7)
|
||||
#if GCC_OLDER_THAN(4,7)
|
||||
#define override
|
||||
#define final
|
||||
#endif
|
||||
|
@@ -76,7 +76,10 @@ idle_get_names(void)
|
||||
unsigned
|
||||
idle_parse_name(const char *name)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(name != nullptr);
|
||||
#endif
|
||||
|
||||
for (unsigned i = 0; idle_names[i] != nullptr; ++i)
|
||||
if (StringEqualsCaseASCII(name, idle_names[i]))
|
||||
|
@@ -194,6 +194,12 @@ FileLog(const Domain &domain, const char *message)
|
||||
domain.GetName(),
|
||||
chomp_length(message), message);
|
||||
|
||||
#ifdef WIN32
|
||||
/* force-flush the log file, because setvbuf() does not seem
|
||||
to have an effect on WIN32 */
|
||||
fflush(stderr);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
g_free(converted);
|
||||
#endif
|
||||
|
@@ -111,6 +111,9 @@ log_early_init(bool verbose)
|
||||
#ifdef ANDROID
|
||||
(void)verbose;
|
||||
#else
|
||||
/* force stderr to be line-buffered */
|
||||
setvbuf(stderr, nullptr, _IOLBF, 0);
|
||||
|
||||
if (verbose)
|
||||
SetLogThreshold(LogLevel::DEBUG);
|
||||
#endif
|
||||
|
34
src/Main.cxx
34
src/Main.cxx
@@ -54,7 +54,6 @@
|
||||
#include "system/FatalError.hxx"
|
||||
#include "util/UriUtil.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "thread/Id.hxx"
|
||||
#include "thread/Slack.hxx"
|
||||
#include "lib/icu/Init.hxx"
|
||||
@@ -114,13 +113,15 @@
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
#include <dispatch/dispatch.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096;
|
||||
static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
|
||||
|
||||
static constexpr Domain main_domain("main");
|
||||
|
||||
#ifdef ANDROID
|
||||
Context *context;
|
||||
#endif
|
||||
@@ -401,8 +402,6 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
#ifdef WIN32
|
||||
return win32_main(argc, argv);
|
||||
#elif __APPLE__
|
||||
return osx_main(argc, argv);
|
||||
#else
|
||||
return mpd_main(argc, argv);
|
||||
#endif
|
||||
@@ -410,6 +409,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
#endif
|
||||
|
||||
static int mpd_main_after_fork(struct options);
|
||||
|
||||
#ifdef ANDROID
|
||||
static inline
|
||||
#endif
|
||||
@@ -513,6 +514,27 @@ int mpd_main(int argc, char *argv[])
|
||||
daemonize_begin(options.daemon);
|
||||
#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(options));
|
||||
});
|
||||
dispatch_main();
|
||||
return EXIT_FAILURE; // unreachable, because dispatch_main never returns
|
||||
#else
|
||||
return mpd_main_after_fork(options);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int mpd_main_after_fork(struct options options)
|
||||
{
|
||||
Error error;
|
||||
|
||||
GlobalEvents::Initialize(*instance->event_loop);
|
||||
GlobalEvents::Register(GlobalEvents::IDLE, idle_event_emitted);
|
||||
#ifdef WIN32
|
||||
@@ -608,7 +630,7 @@ int mpd_main(int argc, char *argv[])
|
||||
config_get_unsigned(CONF_AUTO_UPDATE_DEPTH,
|
||||
INT_MAX));
|
||||
#else
|
||||
FormatWarning(main_domain,
|
||||
FormatWarning(config_domain,
|
||||
"inotify: auto_update was disabled. enable during compilation phase");
|
||||
#endif
|
||||
}
|
||||
|
11
src/Main.hxx
11
src/Main.hxx
@@ -75,15 +75,4 @@ win32_app_stopping(void);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
/* Runs the OS X native event loop in the main thread, and runs
|
||||
* 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.
|
||||
*/
|
||||
int osx_main(int argc, char *argv[]);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@@ -612,6 +612,12 @@ Player::ProcessCommand()
|
||||
|
||||
queued = true;
|
||||
pc.CommandFinished();
|
||||
|
||||
pc.Unlock();
|
||||
if (dc.LockIsIdle())
|
||||
StartDecoder(*new MusicPipe());
|
||||
pc.Lock();
|
||||
|
||||
break;
|
||||
|
||||
case PlayerCommand::PAUSE:
|
||||
|
@@ -64,6 +64,10 @@ spl_global_init(void)
|
||||
bool
|
||||
spl_valid_name(const char *name_utf8)
|
||||
{
|
||||
if (*name_utf8 == 0)
|
||||
/* empty name not allowed */
|
||||
return false;
|
||||
|
||||
/*
|
||||
* Not supporting '/' was done out of laziness, and we should
|
||||
* really strive to support it in the future.
|
||||
|
@@ -77,7 +77,10 @@ SongFilter::Item::Item(unsigned _tag, time_t _time)
|
||||
bool
|
||||
SongFilter::Item::StringMatch(const char *s) const
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(s != nullptr);
|
||||
#endif
|
||||
|
||||
if (fold_case) {
|
||||
const std::string folded = IcuCaseFold(s);
|
||||
|
@@ -77,7 +77,10 @@ SongLoader::LoadFile(const char *path_utf8, Error &error) const
|
||||
DetachedSong *
|
||||
SongLoader::LoadSong(const char *uri_utf8, Error &error) const
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(uri_utf8 != nullptr);
|
||||
#endif
|
||||
|
||||
if (memcmp(uri_utf8, "file:///", 8) == 0)
|
||||
/* absolute path */
|
||||
|
@@ -46,7 +46,8 @@ tag_stream_scan(InputStream &is, const tag_handler &handler, void *ctx)
|
||||
{
|
||||
assert(is.IsReady());
|
||||
|
||||
const char *const suffix = uri_get_suffix(is.GetURI());
|
||||
UriSuffixBuffer suffix_buffer;
|
||||
const char *const suffix = uri_get_suffix(is.GetURI(), suffix_buffer);
|
||||
const char *const mime = is.GetMimeType();
|
||||
|
||||
if (suffix == nullptr && mime == nullptr)
|
||||
|
@@ -168,12 +168,13 @@ bool
|
||||
ZzipInputStream::Seek(offset_type new_offset, Error &error)
|
||||
{
|
||||
zzip_off_t ofs = zzip_seek(file, new_offset, SEEK_SET);
|
||||
if (ofs != -1) {
|
||||
if (ofs < 0) {
|
||||
error.Set(zzip_domain, "zzip_seek() has failed");
|
||||
offset = ofs;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
offset = ofs;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* exported structures */
|
||||
|
@@ -127,7 +127,7 @@ public:
|
||||
* a local (UNIX domain) socket?
|
||||
*/
|
||||
bool IsLocal() const {
|
||||
return uid > 0;
|
||||
return uid >= 0;
|
||||
}
|
||||
|
||||
unsigned GetPermission() const {
|
||||
|
@@ -41,7 +41,7 @@ Client::AllowFile(Path path_fs, Error &error) const
|
||||
instance */
|
||||
return true;
|
||||
|
||||
if (uid <= 0) {
|
||||
if (uid < 0) {
|
||||
/* unauthenticated client */
|
||||
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
|
||||
return false;
|
||||
|
@@ -41,7 +41,7 @@ client_process_command_list(Client &client, bool list_ok,
|
||||
|
||||
FormatDebug(client_domain, "process command \"%s\"", cmd);
|
||||
ret = command_process(client, num++, cmd);
|
||||
FormatDebug(client_domain, "command returned %i", ret);
|
||||
FormatDebug(client_domain, "command returned %i", int(ret));
|
||||
if (ret != CommandResult::OK || client.IsExpired())
|
||||
break;
|
||||
else if (list_ok)
|
||||
@@ -90,7 +90,7 @@ client_process_line(Client &client, char *line)
|
||||
std::move(cmd_list));
|
||||
FormatDebug(client_domain,
|
||||
"[%u] process command "
|
||||
"list returned %i", client.num, ret);
|
||||
"list returned %i", client.num, int(ret));
|
||||
|
||||
if (ret == CommandResult::CLOSE ||
|
||||
client.IsExpired())
|
||||
@@ -126,7 +126,7 @@ client_process_line(Client &client, char *line)
|
||||
ret = command_process(client, 0, line);
|
||||
FormatDebug(client_domain,
|
||||
"[%u] command returned %i",
|
||||
client.num, ret);
|
||||
client.num, int(ret));
|
||||
|
||||
if (ret == CommandResult::CLOSE ||
|
||||
client.IsExpired())
|
||||
|
@@ -61,7 +61,16 @@ translate_uri(Client &client, const char *uri)
|
||||
CommandResult
|
||||
handle_add(Client &client, gcc_unused unsigned argc, char *argv[])
|
||||
{
|
||||
const char *const uri = translate_uri(client, argv[1]);
|
||||
const char *uri = argv[1];
|
||||
if (memcmp(uri, "/", 2) == 0)
|
||||
/* this URI is malformed, but some clients are buggy
|
||||
and use "add /" to add the whole database, which
|
||||
was never intended to work, but once did; in order
|
||||
to retain backwards compatibility, work around this
|
||||
here */
|
||||
uri = "";
|
||||
|
||||
uri = translate_uri(client, uri);
|
||||
if (uri == nullptr)
|
||||
return CommandResult::ERROR;
|
||||
|
||||
|
@@ -23,7 +23,7 @@
|
||||
#include "Interface.hxx"
|
||||
#include "client/Client.hxx"
|
||||
#include "LightSong.hxx"
|
||||
#include "tag/Set.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
|
||||
#include <functional>
|
||||
#include <map>
|
||||
|
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
virtual const LightSong *GetSong(const char *uri_utf8,
|
||||
Error &error) const override;
|
||||
virtual void ReturnSong(const LightSong *song) const;
|
||||
void ReturnSong(const LightSong *song) const override;
|
||||
|
||||
virtual bool Visit(const DatabaseSelection &selection,
|
||||
VisitDirectory visit_directory,
|
||||
|
@@ -103,7 +103,7 @@ public:
|
||||
virtual void Close() override;
|
||||
virtual const LightSong *GetSong(const char *uri_utf8,
|
||||
Error &error) const override;
|
||||
virtual void ReturnSong(const LightSong *song) const;
|
||||
void ReturnSong(const LightSong *song) const override;
|
||||
|
||||
virtual bool Visit(const DatabaseSelection &selection,
|
||||
VisitDirectory visit_directory,
|
||||
@@ -731,7 +731,7 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
|
||||
{
|
||||
// TODO: eliminate the const_cast
|
||||
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
|
||||
return nullptr;
|
||||
return false;
|
||||
|
||||
if (!visit_directory && !visit_playlist && selection.recursive &&
|
||||
(ServerSupportsSearchBase(connection)
|
||||
@@ -757,7 +757,7 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
|
||||
{
|
||||
// TODO: eliminate the const_cast
|
||||
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
|
||||
return nullptr;
|
||||
return false;
|
||||
|
||||
enum mpd_tag_type tag_type2 = Convert(tag_type);
|
||||
if (tag_type2 == MPD_TAG_COUNT) {
|
||||
@@ -810,7 +810,7 @@ ProxyDatabase::GetStats(const DatabaseSelection &selection,
|
||||
|
||||
// TODO: eliminate the const_cast
|
||||
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
|
||||
return nullptr;
|
||||
return false;
|
||||
|
||||
struct mpd_stats *stats2 =
|
||||
mpd_run_stats(connection);
|
||||
|
@@ -435,9 +435,12 @@ SimpleDatabase::Save(Error &error)
|
||||
bool
|
||||
SimpleDatabase::Mount(const char *uri, Database *db, Error &error)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(uri != nullptr);
|
||||
assert(*uri != 0);
|
||||
assert(db != nullptr);
|
||||
#endif
|
||||
assert(*uri != 0);
|
||||
|
||||
ScopeDatabaseLock protect;
|
||||
|
||||
@@ -445,13 +448,13 @@ SimpleDatabase::Mount(const char *uri, Database *db, Error &error)
|
||||
if (r.uri == nullptr) {
|
||||
error.Format(db_domain, DB_CONFLICT,
|
||||
"Already exists: %s", uri);
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strchr(r.uri, '/') != nullptr) {
|
||||
error.Format(db_domain, DB_NOT_FOUND,
|
||||
"Parent not found: %s", uri);
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
Directory *mnt = r.directory->CreateChild(r.uri);
|
||||
@@ -478,7 +481,7 @@ SimpleDatabase::Mount(const char *local_uri, const char *storage_uri,
|
||||
if (cache_path.IsNull()) {
|
||||
error.Format(db_domain, DB_NOT_FOUND,
|
||||
"No 'cache_directory' configured");
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string name(storage_uri);
|
||||
|
@@ -110,9 +110,9 @@ public:
|
||||
virtual bool Open(Error &error) override;
|
||||
virtual void Close() override;
|
||||
|
||||
virtual const LightSong *GetSong(const char *uri_utf8,
|
||||
Error &error) const override;
|
||||
virtual void ReturnSong(const LightSong *song) const;
|
||||
const LightSong *GetSong(const char *uri_utf8,
|
||||
Error &error) const override;
|
||||
void ReturnSong(const LightSong *song) const override;
|
||||
|
||||
virtual bool Visit(const DatabaseSelection &selection,
|
||||
VisitDirectory visit_directory,
|
||||
|
@@ -129,6 +129,7 @@ public:
|
||||
state(NONE),
|
||||
tag_type(TAG_NUM_OF_ITEM_TYPES)
|
||||
{
|
||||
m_tobj.clear();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@@ -85,7 +85,7 @@ public:
|
||||
virtual void Close() override;
|
||||
virtual const LightSong *GetSong(const char *uri_utf8,
|
||||
Error &error) const override;
|
||||
virtual void ReturnSong(const LightSong *song) const;
|
||||
void ReturnSong(const LightSong *song) const override;
|
||||
|
||||
virtual bool Visit(const DatabaseSelection &selection,
|
||||
VisitDirectory visit_directory,
|
||||
@@ -101,7 +101,9 @@ public:
|
||||
virtual bool GetStats(const DatabaseSelection &selection,
|
||||
DatabaseStats &stats,
|
||||
Error &error) const override;
|
||||
virtual time_t GetUpdateStamp() const {return 0;}
|
||||
time_t GetUpdateStamp() const override {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
|
@@ -334,7 +334,7 @@ UpdateWalk::UpdateDirectory(Directory &directory, const FileInfo &info)
|
||||
directory_set_stat(directory, info);
|
||||
|
||||
Error error;
|
||||
const std::auto_ptr<StorageDirectoryReader> reader(storage.OpenDirectory(directory.GetPath(), error));
|
||||
const std::unique_ptr<StorageDirectoryReader> reader(storage.OpenDirectory(directory.GetPath(), error));
|
||||
if (reader.get() == nullptr) {
|
||||
LogError(error);
|
||||
return false;
|
||||
|
@@ -433,8 +433,11 @@ update_stream_tag(Decoder &decoder, InputStream *is)
|
||||
|
||||
/* no stream tag present - submit the song tag
|
||||
instead */
|
||||
decoder.song_tag = nullptr;
|
||||
}
|
||||
} else
|
||||
/* discard the song tag; we don't need it */
|
||||
delete decoder.song_tag;
|
||||
|
||||
decoder.song_tag = nullptr;
|
||||
|
||||
delete decoder.stream_tag;
|
||||
decoder.stream_tag = tag;
|
||||
@@ -566,7 +569,7 @@ decoder_tag(Decoder &decoder, InputStream *is,
|
||||
/* save the tag */
|
||||
|
||||
delete decoder.decoder_tag;
|
||||
decoder.decoder_tag = new Tag(tag);
|
||||
decoder.decoder_tag = new Tag(std::move(tag));
|
||||
|
||||
/* check for a new stream tag */
|
||||
|
||||
|
@@ -37,7 +37,6 @@
|
||||
#include "plugins/MadDecoderPlugin.hxx"
|
||||
#include "plugins/SndfileDecoderPlugin.hxx"
|
||||
#include "plugins/Mpg123DecoderPlugin.hxx"
|
||||
#include "plugins/Mp4v2DecoderPlugin.hxx"
|
||||
#include "plugins/WildmidiDecoderPlugin.hxx"
|
||||
#include "plugins/MikmodDecoderPlugin.hxx"
|
||||
#include "plugins/ModplugDecoderPlugin.hxx"
|
||||
@@ -55,9 +54,6 @@ const struct DecoderPlugin *const decoder_plugins[] = {
|
||||
#ifdef HAVE_MPG123
|
||||
&mpg123_decoder_plugin,
|
||||
#endif
|
||||
#ifdef HAVE_MP4V2
|
||||
&mp4v2_decoder_plugin,
|
||||
#endif
|
||||
#ifdef ENABLE_VORBIS_DECODER
|
||||
&vorbis_decoder_plugin,
|
||||
#endif
|
||||
|
@@ -26,7 +26,10 @@
|
||||
bool
|
||||
DecoderPlugin::SupportsSuffix(const char *suffix) const
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(suffix != nullptr);
|
||||
#endif
|
||||
|
||||
return suffixes != nullptr && string_array_contains(suffixes, suffix);
|
||||
|
||||
@@ -35,7 +38,10 @@ DecoderPlugin::SupportsSuffix(const char *suffix) const
|
||||
bool
|
||||
DecoderPlugin::SupportsMimeType(const char *mime_type) const
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(mime_type != nullptr);
|
||||
#endif
|
||||
|
||||
return mime_types != nullptr &&
|
||||
string_array_contains(mime_types, mime_type);
|
||||
|
@@ -237,7 +237,8 @@ static bool
|
||||
decoder_run_stream_locked(Decoder &decoder, InputStream &is,
|
||||
const char *uri, bool &tried_r)
|
||||
{
|
||||
const char *const suffix = uri_get_suffix(uri);
|
||||
UriSuffixBuffer suffix_buffer;
|
||||
const char *const suffix = uri_get_suffix(uri, suffix_buffer);
|
||||
|
||||
using namespace std::placeholders;
|
||||
const auto f = std::bind(decoder_run_stream_plugin,
|
||||
@@ -379,7 +380,11 @@ decoder_run_song(DecoderControl &dc,
|
||||
const DetachedSong &song, const char *uri, Path path_fs)
|
||||
{
|
||||
Decoder decoder(dc, dc.start_time.IsPositive(),
|
||||
new Tag(song.GetTag()));
|
||||
/* pass the song tag only if it's
|
||||
authoritative, i.e. if it's a local file -
|
||||
tags on "stream" songs are just remembered
|
||||
from the last time we played it*/
|
||||
song.IsFile() ? new Tag(song.GetTag()) : nullptr);
|
||||
int ret;
|
||||
|
||||
dc.state = DecoderState::START;
|
||||
|
@@ -209,7 +209,7 @@ audiofile_stream_decode(Decoder &decoder, InputStream &is)
|
||||
const auto total_time = audiofile_get_duration(fh);
|
||||
|
||||
const uint16_t kbit_rate = (uint16_t)
|
||||
(is.GetSize() * uint64_t(8000) / total_time.ToMS());
|
||||
(is.GetSize() * uint64_t(8) / total_time.ToMS());
|
||||
|
||||
const unsigned frame_size = (unsigned)
|
||||
afGetVirtualFrameSize(fh, AF_DEFAULT_TRACK, true);
|
||||
|
@@ -29,8 +29,10 @@
|
||||
#include "input/InputStream.hxx"
|
||||
#include "tag/TagId3.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Alloc.hxx"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef HAVE_ID3TAG
|
||||
#include <id3tag.h>
|
||||
@@ -53,7 +55,7 @@ dsdlib_skip_to(Decoder *decoder, InputStream &is,
|
||||
offset_type offset)
|
||||
{
|
||||
if (is.IsSeekable())
|
||||
return is.Seek(offset, IgnoreError());
|
||||
return is.LockSeek(offset, IgnoreError());
|
||||
|
||||
if (is.GetOffset() > offset)
|
||||
return false;
|
||||
@@ -72,7 +74,7 @@ dsdlib_skip(Decoder *decoder, InputStream &is,
|
||||
return true;
|
||||
|
||||
if (is.IsSeekable())
|
||||
return is.Seek(is.GetOffset() + delta, IgnoreError());
|
||||
return is.LockSeek(is.GetOffset() + delta, IgnoreError());
|
||||
|
||||
if (delta > 1024 * 1024)
|
||||
/* don't skip more than one megabyte; it would be too
|
||||
@@ -123,22 +125,26 @@ dsdlib_tag_id3(InputStream &is,
|
||||
|
||||
const id3_length_t count = size - offset;
|
||||
|
||||
/* Check and limit id3 tag size to prevent a stack overflow */
|
||||
id3_byte_t dsdid3[4096];
|
||||
if (count == 0 || count > sizeof(dsdid3))
|
||||
if (count < 10 || count > 1024 * 1024)
|
||||
return;
|
||||
|
||||
if (!decoder_read_full(nullptr, is, dsdid3, count))
|
||||
id3_byte_t *const id3_buf = new id3_byte_t[count];
|
||||
if (id3_buf == nullptr)
|
||||
return;
|
||||
|
||||
struct id3_tag *id3_tag = id3_tag_parse(dsdid3, count);
|
||||
if (!decoder_read_full(nullptr, is, id3_buf, count)) {
|
||||
delete[] id3_buf;
|
||||
return;
|
||||
}
|
||||
|
||||
struct id3_tag *id3_tag = id3_tag_parse(id3_buf, count);
|
||||
delete[] id3_buf;
|
||||
if (id3_tag == nullptr)
|
||||
return;
|
||||
|
||||
scan_id3_tag(id3_tag, handler, handler_ctx);
|
||||
|
||||
id3_tag_delete(id3_tag);
|
||||
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
@@ -255,20 +255,12 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer &buffer,
|
||||
}
|
||||
|
||||
uint8_t channels;
|
||||
uint32_t sample_rate;
|
||||
#ifdef HAVE_FAAD_LONG
|
||||
/* neaacdec.h declares all arguments as "unsigned long", but
|
||||
internally expects uint32_t pointers. To avoid gcc
|
||||
warnings, use this workaround. */
|
||||
unsigned long *sample_rate_p = (unsigned long *)(void *)&sample_rate;
|
||||
#else
|
||||
uint32_t *sample_rate_p = &sample_rate;
|
||||
#endif
|
||||
unsigned long sample_rate;
|
||||
long nbytes = NeAACDecInit(decoder,
|
||||
/* deconst hack, libfaad requires this */
|
||||
const_cast<unsigned char *>(data.data),
|
||||
data.size,
|
||||
sample_rate_p, &channels);
|
||||
&sample_rate, &channels);
|
||||
if (nbytes < 0) {
|
||||
error.Set(faad_decoder_domain, "Not an AAC stream");
|
||||
return false;
|
||||
|
@@ -92,14 +92,14 @@ struct AvioStream {
|
||||
|
||||
AVIOContext *io;
|
||||
|
||||
unsigned char buffer[8192];
|
||||
|
||||
AvioStream(Decoder *_decoder, InputStream &_input)
|
||||
:decoder(_decoder), input(_input), io(nullptr) {}
|
||||
|
||||
~AvioStream() {
|
||||
if (io != nullptr)
|
||||
if (io != nullptr) {
|
||||
av_free(io->buffer);
|
||||
av_free(io);
|
||||
}
|
||||
}
|
||||
|
||||
bool Open();
|
||||
@@ -153,11 +153,20 @@ mpd_ffmpeg_stream_seek(void *opaque, int64_t pos, int whence)
|
||||
bool
|
||||
AvioStream::Open()
|
||||
{
|
||||
io = avio_alloc_context(buffer, sizeof(buffer),
|
||||
constexpr size_t BUFFER_SIZE = 8192;
|
||||
auto buffer = (unsigned char *)av_malloc(BUFFER_SIZE);
|
||||
if (buffer == nullptr)
|
||||
return false;
|
||||
|
||||
io = avio_alloc_context(buffer, BUFFER_SIZE,
|
||||
false, this,
|
||||
mpd_ffmpeg_stream_read, nullptr,
|
||||
input.IsSeekable()
|
||||
? mpd_ffmpeg_stream_seek : nullptr);
|
||||
/* If avio_alloc_context() fails, who frees the buffer? The
|
||||
libavformat API documentation does not specify this, it
|
||||
only says that AVIOContext.buffer must be freed in the end,
|
||||
however no AVIOContext exists in that failure code path. */
|
||||
return io != nullptr;
|
||||
}
|
||||
|
||||
@@ -305,18 +314,61 @@ copy_interleave_frame(const AVCodecContext *codec_context,
|
||||
return data_size;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert AVPacket::pts to a stream-relative time stamp (still in
|
||||
* AVStream::time_base units). Returns a negative value on error.
|
||||
*/
|
||||
gcc_pure
|
||||
static int64_t
|
||||
StreamRelativePts(const AVPacket &packet, const AVStream &stream)
|
||||
{
|
||||
auto pts = packet.pts;
|
||||
if (pts < 0 || pts == int64_t(AV_NOPTS_VALUE))
|
||||
return -1;
|
||||
|
||||
auto start = start_time_fallback(stream);
|
||||
return pts - start;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a non-negative stream-relative time stamp in
|
||||
* AVStream::time_base units to a PCM frame number.
|
||||
*/
|
||||
gcc_pure
|
||||
static uint64_t
|
||||
PtsToPcmFrame(uint64_t pts, const AVStream &stream,
|
||||
const AVCodecContext &codec_context)
|
||||
{
|
||||
return av_rescale_q(pts, stream.time_base, codec_context.time_base);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param min_frame skip all data before this PCM frame number; this
|
||||
* is used after seeking to skip data in an AVPacket until the exact
|
||||
* desired time stamp has been reached
|
||||
*/
|
||||
static DecoderCommand
|
||||
ffmpeg_send_packet(Decoder &decoder, InputStream &is,
|
||||
const AVPacket *packet,
|
||||
AVCodecContext *codec_context,
|
||||
const AVStream *stream,
|
||||
AVFrame *frame,
|
||||
uint64_t min_frame, size_t pcm_frame_size,
|
||||
uint8_t **buffer, int *buffer_size)
|
||||
{
|
||||
if (packet->pts >= 0 && packet->pts != (int64_t)AV_NOPTS_VALUE)
|
||||
decoder_timestamp(decoder,
|
||||
time_from_ffmpeg(packet->pts - start_time_fallback(*stream),
|
||||
stream->time_base));
|
||||
size_t skip_bytes = 0;
|
||||
|
||||
const auto pts = StreamRelativePts(*packet, *stream);
|
||||
if (pts >= 0) {
|
||||
if (min_frame > 0) {
|
||||
auto cur_frame = PtsToPcmFrame(pts, *stream,
|
||||
*codec_context);
|
||||
if (cur_frame < min_frame)
|
||||
skip_bytes = pcm_frame_size * (min_frame - cur_frame);
|
||||
} else
|
||||
decoder_timestamp(decoder,
|
||||
time_from_ffmpeg(pts, stream->time_base));
|
||||
}
|
||||
|
||||
AVPacket packet2 = *packet;
|
||||
|
||||
@@ -351,8 +403,20 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
|
||||
if (audio_size <= 0)
|
||||
continue;
|
||||
|
||||
const uint8_t *data = output_buffer;
|
||||
if (skip_bytes > 0) {
|
||||
if (skip_bytes >= size_t(audio_size)) {
|
||||
skip_bytes -= audio_size;
|
||||
continue;
|
||||
}
|
||||
|
||||
data += skip_bytes;
|
||||
audio_size -= skip_bytes;
|
||||
skip_bytes = 0;
|
||||
}
|
||||
|
||||
cmd = decoder_data(decoder, is,
|
||||
output_buffer, audio_size,
|
||||
data, audio_size,
|
||||
codec_context->bit_rate / 1000);
|
||||
}
|
||||
return cmd;
|
||||
@@ -371,6 +435,7 @@ ffmpeg_sample_format(enum AVSampleFormat sample_fmt)
|
||||
case AV_SAMPLE_FMT_S32P:
|
||||
return SampleFormat::S32;
|
||||
|
||||
case AV_SAMPLE_FMT_FLT:
|
||||
case AV_SAMPLE_FMT_FLTP:
|
||||
return SampleFormat::FLOAT;
|
||||
|
||||
@@ -423,10 +488,15 @@ ffmpeg_probe(Decoder *decoder, InputStream &is)
|
||||
avpd.filename = is.GetURI();
|
||||
|
||||
#ifdef AVPROBE_SCORE_MIME
|
||||
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(56, 5, 1)
|
||||
/* this attribute was added in libav/ffmpeg version 11, but
|
||||
unfortunately it's "uint8_t" instead of "char", and it's
|
||||
not "const" - wtf? */
|
||||
avpd.mime_type = (uint8_t *)const_cast<char *>(is.GetMimeType());
|
||||
#else
|
||||
/* API problem fixed in FFmpeg 2.5 */
|
||||
avpd.mime_type = is.GetMimeType();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return av_probe_input_format(&avpd, true);
|
||||
@@ -550,6 +620,8 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
|
||||
uint8_t *interleaved_buffer = nullptr;
|
||||
int interleaved_buffer_size = 0;
|
||||
|
||||
uint64_t min_frame = 0;
|
||||
|
||||
DecoderCommand cmd;
|
||||
do {
|
||||
AVPacket packet;
|
||||
@@ -557,13 +629,15 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
|
||||
/* end of file */
|
||||
break;
|
||||
|
||||
if (packet.stream_index == audio_stream)
|
||||
if (packet.stream_index == audio_stream) {
|
||||
cmd = ffmpeg_send_packet(decoder, input,
|
||||
&packet, codec_context,
|
||||
av_stream,
|
||||
frame,
|
||||
min_frame, audio_format.GetFrameSize(),
|
||||
&interleaved_buffer, &interleaved_buffer_size);
|
||||
else
|
||||
min_frame = 0;
|
||||
} else
|
||||
cmd = decoder_get_command(decoder);
|
||||
|
||||
av_free_packet(&packet);
|
||||
@@ -574,11 +648,16 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
|
||||
av_stream->time_base) +
|
||||
start_time_fallback(*av_stream);
|
||||
|
||||
/* AVSEEK_FLAG_BACKWARD asks FFmpeg to seek to
|
||||
the packet boundary before the seek time
|
||||
stamp, not after */
|
||||
|
||||
if (av_seek_frame(format_context, audio_stream, where,
|
||||
AVSEEK_FLAG_ANY) < 0)
|
||||
AVSEEK_FLAG_ANY|AVSEEK_FLAG_BACKWARD) < 0)
|
||||
decoder_seek_error(decoder);
|
||||
else {
|
||||
avcodec_flush_buffers(codec_context);
|
||||
min_frame = decoder_seek_where_frame(decoder);
|
||||
decoder_command_finished(decoder);
|
||||
}
|
||||
}
|
||||
@@ -657,7 +736,7 @@ static const char *const ffmpeg_suffixes[] = {
|
||||
"mj2", "mjpeg", "mjpg", "mka", "mkv", "mlp", "mm", "mmf", "mov", "mp+",
|
||||
"mp1", "mp2", "mp3", "mp4", "mpc", "mpeg", "mpg", "mpga", "mpp", "mpu",
|
||||
"mve", "mvi", "mxf", "nc", "nsv", "nut", "nuv", "oga", "ogm", "ogv",
|
||||
"ogx", "oma", "ogg", "omg", "psp", "pva", "qcp", "qt", "r3d", "ra",
|
||||
"ogx", "oma", "ogg", "omg", "opus", "psp", "pva", "qcp", "qt", "r3d", "ra",
|
||||
"ram", "rl2", "rm", "rmvb", "roq", "rpl", "rvc", "shn", "smk", "snd",
|
||||
"sol", "son", "spx", "str", "swf", "tgi", "tgq", "tgv", "thp", "ts",
|
||||
"tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc",
|
||||
@@ -680,6 +759,7 @@ static const char *const ffmpeg_mime_types[] = {
|
||||
"audio/8svx",
|
||||
"audio/16sv",
|
||||
"audio/aac",
|
||||
"audio/aacp",
|
||||
"audio/ac3",
|
||||
"audio/aiff"
|
||||
"audio/amr",
|
||||
@@ -690,6 +770,7 @@ static const char *const ffmpeg_mime_types[] = {
|
||||
"audio/mpeg",
|
||||
"audio/musepack",
|
||||
"audio/ogg",
|
||||
"audio/opus",
|
||||
"audio/qcelp",
|
||||
"audio/vorbis",
|
||||
"audio/vorbis+ogg",
|
||||
|
@@ -156,8 +156,11 @@ gme_file_decode(Decoder &decoder, Path path_fs)
|
||||
return;
|
||||
}
|
||||
|
||||
const SignedSongTime song_len = ti->length > 0
|
||||
? SignedSongTime::FromMS(ti->length)
|
||||
const int length = ti->play_length;
|
||||
gme_free_info(ti);
|
||||
|
||||
const SignedSongTime song_len = length > 0
|
||||
? SignedSongTime::FromMS(length)
|
||||
: SignedSongTime::Negative();
|
||||
|
||||
/* initialize the MPD decoder */
|
||||
@@ -168,7 +171,6 @@ gme_file_decode(Decoder &decoder, Path path_fs)
|
||||
SampleFormat::S16, GME_CHANNELS,
|
||||
error)) {
|
||||
LogError(error);
|
||||
gme_free_info(ti);
|
||||
gme_delete(emu);
|
||||
return;
|
||||
}
|
||||
@@ -179,8 +181,8 @@ gme_file_decode(Decoder &decoder, Path path_fs)
|
||||
if (gme_err != nullptr)
|
||||
LogWarning(gme_domain, gme_err);
|
||||
|
||||
if (ti->length > 0)
|
||||
gme_set_fade(emu, ti->length);
|
||||
if (length > 0)
|
||||
gme_set_fade(emu, length);
|
||||
|
||||
/* play */
|
||||
DecoderCommand cmd;
|
||||
@@ -196,16 +198,17 @@ gme_file_decode(Decoder &decoder, Path path_fs)
|
||||
if (cmd == DecoderCommand::SEEK) {
|
||||
unsigned where = decoder_seek_time(decoder).ToMS();
|
||||
gme_err = gme_seek(emu, where);
|
||||
if (gme_err != nullptr)
|
||||
if (gme_err != nullptr) {
|
||||
LogWarning(gme_domain, gme_err);
|
||||
decoder_command_finished(decoder);
|
||||
decoder_seek_error(decoder);
|
||||
} else
|
||||
decoder_command_finished(decoder);
|
||||
}
|
||||
|
||||
if (gme_track_ended(emu))
|
||||
break;
|
||||
} while (cmd != DecoderCommand::STOP);
|
||||
|
||||
gme_free_info(ti);
|
||||
gme_delete(emu);
|
||||
}
|
||||
|
||||
@@ -236,9 +239,9 @@ gme_scan_file(Path path_fs,
|
||||
|
||||
assert(ti != nullptr);
|
||||
|
||||
if (ti->length > 0)
|
||||
if (ti->play_length > 0)
|
||||
tag_handler_invoke_duration(handler, handler_ctx,
|
||||
SongTime::FromMS(ti->length));
|
||||
SongTime::FromMS(ti->play_length));
|
||||
|
||||
if (ti->song != nullptr) {
|
||||
if (gme_track_count(emu) > 1) {
|
||||
|
@@ -657,7 +657,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen)
|
||||
unsigned name = mad_bit_read(ptr, 3); /* gain name */
|
||||
unsigned orig = mad_bit_read(ptr, 3); /* gain originator */
|
||||
unsigned sign = mad_bit_read(ptr, 1); /* sign bit */
|
||||
unsigned gain = mad_bit_read(ptr, 9); /* gain*10 */
|
||||
int gain = mad_bit_read(ptr, 9); /* gain*10 */
|
||||
if (gain && name == 1 && orig != 0) {
|
||||
lame->track_gain = ((sign ? -gain : gain) / 10.0) + adj;
|
||||
FormatDebug(mad_domain, "LAME track gain found: %f",
|
||||
|
@@ -1,338 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "config.h" /* must be first for large file support */
|
||||
#include "Mp4v2DecoderPlugin.hxx"
|
||||
#include "../DecoderAPI.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <mp4v2/mp4v2.h>
|
||||
#include <neaacdec.h>
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
|
||||
static constexpr Domain mp4v2_decoder_domain("mp4v2");
|
||||
|
||||
static MP4TrackId
|
||||
mp4_get_aac_track(MP4FileHandle handle, NeAACDecHandle decoder,
|
||||
AudioFormat &audio_format, Error &error)
|
||||
{
|
||||
uint32_t sample_rate;
|
||||
#ifdef HAVE_FAAD_LONG
|
||||
/* neaacdec.h declares all arguments as "unsigned long", but
|
||||
internally expects uint32_t pointers. To avoid gcc
|
||||
warnings, use this workaround. */
|
||||
unsigned long *sample_rate_r = (unsigned long*)&sample_rate;
|
||||
#else
|
||||
uint32_t *sample_rate_r = sample_rate;
|
||||
#endif
|
||||
|
||||
const MP4TrackId tracks = MP4GetNumberOfTracks(handle);
|
||||
|
||||
for (MP4TrackId id = 1; id <= tracks; id++) {
|
||||
const char* track_type = MP4GetTrackType(handle, id);
|
||||
|
||||
if (track_type == 0)
|
||||
continue;
|
||||
|
||||
const auto obj_type = MP4GetTrackEsdsObjectTypeId(handle, id);
|
||||
|
||||
if (obj_type == MP4_INVALID_AUDIO_TYPE)
|
||||
continue;
|
||||
if (obj_type == MP4_MPEG4_AUDIO_TYPE) {
|
||||
const auto mpeg_type = MP4GetTrackAudioMpeg4Type(handle, id);
|
||||
if (!MP4_IS_MPEG4_AAC_AUDIO_TYPE(mpeg_type))
|
||||
continue;
|
||||
} else if (!MP4_IS_AAC_AUDIO_TYPE(obj_type))
|
||||
continue;
|
||||
|
||||
if (decoder == nullptr)
|
||||
/* found audio track, no decoder */
|
||||
return id;
|
||||
|
||||
unsigned char *buff = nullptr;
|
||||
unsigned buff_size = 0;
|
||||
|
||||
if (!MP4GetTrackESConfiguration(handle, id, &buff, &buff_size))
|
||||
continue;
|
||||
|
||||
uint8_t channels;
|
||||
int32_t nbytes = NeAACDecInit(decoder, buff, buff_size,
|
||||
sample_rate_r, &channels);
|
||||
|
||||
free(buff);
|
||||
|
||||
if (nbytes < 0)
|
||||
/* invalid stream */
|
||||
continue;
|
||||
|
||||
if (!audio_format_init_checked(audio_format, sample_rate,
|
||||
SampleFormat::S16,
|
||||
channels,
|
||||
error))
|
||||
continue;
|
||||
|
||||
return id;
|
||||
}
|
||||
|
||||
error.Set(mp4v2_decoder_domain, "no valid aac track found");
|
||||
|
||||
return MP4_INVALID_TRACK_ID;
|
||||
}
|
||||
|
||||
static NeAACDecHandle
|
||||
mp4_faad_new(MP4FileHandle handle, AudioFormat &audio_format, Error &error)
|
||||
{
|
||||
const NeAACDecHandle decoder = NeAACDecOpen();
|
||||
const NeAACDecConfigurationPtr config =
|
||||
NeAACDecGetCurrentConfiguration(decoder);
|
||||
config->outputFormat = FAAD_FMT_16BIT;
|
||||
config->downMatrix = 1;
|
||||
config->dontUpSampleImplicitSBR = 0;
|
||||
NeAACDecSetConfiguration(decoder, config);
|
||||
|
||||
const auto track = mp4_get_aac_track(handle, decoder, audio_format, error);
|
||||
|
||||
if (track == MP4_INVALID_TRACK_ID) {
|
||||
NeAACDecClose(decoder);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return decoder;
|
||||
}
|
||||
|
||||
static void
|
||||
mp4_file_decode(Decoder &mpd_decoder, Path path_fs)
|
||||
{
|
||||
const MP4FileHandle handle = MP4Read(path_fs.c_str());
|
||||
|
||||
if (handle == MP4_INVALID_FILE_HANDLE) {
|
||||
FormatError(mp4v2_decoder_domain,
|
||||
"unable to open file");
|
||||
return;
|
||||
}
|
||||
|
||||
AudioFormat audio_format;
|
||||
Error error;
|
||||
const NeAACDecHandle decoder = mp4_faad_new(handle, audio_format, error);
|
||||
|
||||
if (decoder == nullptr) {
|
||||
LogError(error);
|
||||
MP4Close(handle);
|
||||
return;
|
||||
}
|
||||
|
||||
const MP4TrackId track = mp4_get_aac_track(handle, nullptr, audio_format, error);
|
||||
|
||||
/* initialize the MPD core */
|
||||
|
||||
const MP4Timestamp scale = MP4GetTrackTimeScale(handle, track);
|
||||
const SongTime duration = SongTime::FromScale<uint64_t>(MP4GetTrackDuration(handle, track),
|
||||
scale);
|
||||
const MP4SampleId num_samples = MP4GetTrackNumberOfSamples(handle, track);
|
||||
|
||||
decoder_initialized(mpd_decoder, audio_format, true, duration);
|
||||
|
||||
/* the decoder loop */
|
||||
|
||||
DecoderCommand cmd = DecoderCommand::NONE;
|
||||
|
||||
for (MP4SampleId sample = 1;
|
||||
sample < num_samples && cmd != DecoderCommand::STOP;
|
||||
sample++) {
|
||||
unsigned char *data = nullptr;
|
||||
unsigned int data_length = 0;
|
||||
|
||||
if (cmd == DecoderCommand::SEEK) {
|
||||
const MP4Timestamp offset =
|
||||
decoder_seek_time(mpd_decoder).ToScale(scale);
|
||||
|
||||
sample = MP4GetSampleIdFromTime(handle, track, offset,
|
||||
false);
|
||||
decoder_command_finished(mpd_decoder);
|
||||
}
|
||||
|
||||
/* read */
|
||||
if (MP4ReadSample(handle, track, sample, &data, &data_length) == 0) {
|
||||
FormatError(mp4v2_decoder_domain, "unable to read sample");
|
||||
break;
|
||||
}
|
||||
|
||||
/* decode it */
|
||||
NeAACDecFrameInfo frame_info;
|
||||
const void *const decoded = NeAACDecDecode(decoder, &frame_info, data, data_length);
|
||||
|
||||
if (frame_info.error > 0) {
|
||||
FormatWarning(mp4v2_decoder_domain,
|
||||
"error decoding AAC stream: %s",
|
||||
NeAACDecGetErrorMessage(frame_info.error));
|
||||
break;
|
||||
}
|
||||
|
||||
if (frame_info.channels != audio_format.channels) {
|
||||
FormatDefault(mp4v2_decoder_domain,
|
||||
"channel count changed from %u to %u",
|
||||
audio_format.channels, frame_info.channels);
|
||||
break;
|
||||
}
|
||||
|
||||
if (frame_info.samplerate != audio_format.sample_rate) {
|
||||
FormatDefault(mp4v2_decoder_domain,
|
||||
"sample rate changed from %u to %lu",
|
||||
audio_format.sample_rate,
|
||||
(unsigned long)frame_info.samplerate);
|
||||
break;
|
||||
}
|
||||
|
||||
/* update bit rate and position */
|
||||
unsigned bit_rate = 0;
|
||||
|
||||
if (frame_info.samples > 0) {
|
||||
bit_rate = frame_info.bytesconsumed * 8.0 *
|
||||
frame_info.channels * audio_format.sample_rate /
|
||||
frame_info.samples / 1000 + 0.5;
|
||||
}
|
||||
|
||||
/* send PCM samples to MPD */
|
||||
|
||||
cmd = decoder_data(mpd_decoder, nullptr, decoded,
|
||||
(size_t)frame_info.samples * 2,
|
||||
bit_rate);
|
||||
|
||||
free(data);
|
||||
}
|
||||
|
||||
/* cleanup */
|
||||
NeAACDecClose(decoder);
|
||||
MP4Close(handle);
|
||||
}
|
||||
|
||||
static inline void
|
||||
mp4_safe_invoke_tag(const struct tag_handler *handler, void *handler_ctx,
|
||||
TagType tag, const char *value)
|
||||
{
|
||||
if (value != nullptr)
|
||||
tag_handler_invoke_tag(handler, handler_ctx, tag, value);
|
||||
}
|
||||
|
||||
static bool
|
||||
mp4_scan_file(Path path_fs,
|
||||
const struct tag_handler *handler, void *handler_ctx)
|
||||
{
|
||||
const MP4FileHandle handle = MP4Read(path_fs.c_str());
|
||||
|
||||
if (handle == MP4_INVALID_FILE_HANDLE)
|
||||
return false;
|
||||
|
||||
AudioFormat tmp_audio_format;
|
||||
Error error;
|
||||
const MP4TrackId id = mp4_get_aac_track(handle, nullptr, tmp_audio_format, error);
|
||||
|
||||
if (id == MP4_INVALID_TRACK_ID) {
|
||||
LogError(error);
|
||||
MP4Close(handle);
|
||||
return false;
|
||||
}
|
||||
|
||||
const MP4Timestamp scale = MP4GetTrackTimeScale(handle, id);
|
||||
const SongTime dur =
|
||||
SongTime::FromScale<uint64_t>(MP4GetTrackDuration(handle, id),
|
||||
scale);
|
||||
tag_handler_invoke_duration(handler, handler_ctx, dur);
|
||||
|
||||
const MP4Tags* tags = MP4TagsAlloc();
|
||||
MP4TagsFetch(tags, handle);
|
||||
|
||||
static constexpr struct {
|
||||
const char *MP4Tags::*p;
|
||||
TagType tag_type;
|
||||
} mp4v2_tags[] = {
|
||||
{ &MP4Tags::name, TAG_NAME },
|
||||
{ &MP4Tags::artist, TAG_ARTIST },
|
||||
{ &MP4Tags::albumArtist, TAG_ALBUM_ARTIST },
|
||||
{ &MP4Tags::album, TAG_ALBUM },
|
||||
{ &MP4Tags::composer, TAG_COMPOSER },
|
||||
{ &MP4Tags::comments, TAG_COMMENT },
|
||||
{ &MP4Tags::genre, TAG_GENRE },
|
||||
{ &MP4Tags::releaseDate, TAG_DATE },
|
||||
{ &MP4Tags::sortArtist, TAG_ARTIST_SORT },
|
||||
{ &MP4Tags::sortAlbumArtist, TAG_ALBUM_ARTIST_SORT },
|
||||
};
|
||||
|
||||
for (const auto &i : mp4v2_tags)
|
||||
mp4_safe_invoke_tag(handler, handler_ctx,
|
||||
i.tag_type, tags->*i.p);
|
||||
|
||||
char buff[8]; /* tmp buffer for index to string. */
|
||||
if (tags->track != nullptr) {
|
||||
sprintf(buff, "%d", tags->track->index);
|
||||
tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, buff);
|
||||
}
|
||||
|
||||
if (tags->disk != nullptr) {
|
||||
sprintf(buff, "%d", tags->disk->index);
|
||||
tag_handler_invoke_tag(handler, handler_ctx, TAG_DISC, buff);
|
||||
}
|
||||
|
||||
MP4TagsFree(tags);
|
||||
MP4Close(handle);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static const char *const mp4_suffixes[] = {
|
||||
"mp4",
|
||||
"m4a",
|
||||
/* "m4p", encrypted */
|
||||
/* "m4b", audio book */
|
||||
/* "m4r", ring tones */
|
||||
/* "m4v", video */
|
||||
nullptr
|
||||
};
|
||||
|
||||
static const char *const mp4_mime_types[] = {
|
||||
"application/mp4",
|
||||
"application/m4a",
|
||||
"audio/mp4",
|
||||
"audio/m4a",
|
||||
/* "audio/m4p", */
|
||||
/* "audio/m4b", */
|
||||
/* "audio/m4r", */
|
||||
/* "audio/m4v", */
|
||||
nullptr
|
||||
};
|
||||
|
||||
const struct DecoderPlugin mp4v2_decoder_plugin = {
|
||||
"mp4v2",
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
mp4_file_decode,
|
||||
mp4_scan_file,
|
||||
nullptr,
|
||||
nullptr,
|
||||
mp4_suffixes,
|
||||
mp4_mime_types
|
||||
};
|
@@ -22,10 +22,12 @@
|
||||
#include "../DecoderAPI.hxx"
|
||||
#include "input/InputStream.hxx"
|
||||
#include "CheckAudioFormat.hxx"
|
||||
#include "pcm/Traits.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "util/Macros.hxx"
|
||||
#include "util/Clamp.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <mpc/mpcdec.h>
|
||||
@@ -42,6 +44,9 @@ struct mpc_decoder_data {
|
||||
|
||||
static constexpr Domain mpcdec_domain("mpcdec");
|
||||
|
||||
static constexpr SampleFormat mpcdec_sample_format = SampleFormat::S24_P32;
|
||||
typedef SampleTraits<mpcdec_sample_format> MpcdecSampleTraits;
|
||||
|
||||
static mpc_int32_t
|
||||
mpc_read_cb(mpc_reader *reader, void *ptr, mpc_int32_t size)
|
||||
{
|
||||
@@ -91,18 +96,15 @@ mpc_getsize_cb(mpc_reader *reader)
|
||||
}
|
||||
|
||||
/* this _looks_ performance-critical, don't de-inline -- eric */
|
||||
static inline int32_t
|
||||
static inline MpcdecSampleTraits::value_type
|
||||
mpc_to_mpd_sample(MPC_SAMPLE_FORMAT sample)
|
||||
{
|
||||
/* only doing 16-bit audio for now */
|
||||
int32_t val;
|
||||
MpcdecSampleTraits::value_type val;
|
||||
|
||||
enum {
|
||||
bits = 24,
|
||||
};
|
||||
|
||||
const int clip_min = -1 << (bits - 1);
|
||||
const int clip_max = (1 << (bits - 1)) - 1;
|
||||
constexpr int bits = MpcdecSampleTraits::BITS;
|
||||
constexpr auto clip_min = MpcdecSampleTraits::MIN;
|
||||
constexpr auto clip_max = MpcdecSampleTraits::MAX;
|
||||
|
||||
#ifdef MPC_FIXED_POINT
|
||||
const int shift = bits - MPC_FIXED_POINT_SCALE_SHIFT;
|
||||
@@ -117,16 +119,12 @@ mpc_to_mpd_sample(MPC_SAMPLE_FORMAT sample)
|
||||
val = sample * float_scale;
|
||||
#endif
|
||||
|
||||
if (val < clip_min)
|
||||
val = clip_min;
|
||||
else if (val > clip_max)
|
||||
val = clip_max;
|
||||
|
||||
return val;
|
||||
return Clamp(val, clip_min, clip_max);
|
||||
}
|
||||
|
||||
static void
|
||||
mpc_to_mpd_buffer(int32_t *dest, const MPC_SAMPLE_FORMAT *src,
|
||||
mpc_to_mpd_buffer(MpcdecSampleTraits::pointer_type dest,
|
||||
const MPC_SAMPLE_FORMAT *src,
|
||||
unsigned num_samples)
|
||||
{
|
||||
while (num_samples-- > 0)
|
||||
@@ -162,7 +160,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
|
||||
Error error;
|
||||
AudioFormat audio_format;
|
||||
if (!audio_format_init_checked(audio_format, info.sample_freq,
|
||||
SampleFormat::S24_P32,
|
||||
mpcdec_sample_format,
|
||||
info.channels, error)) {
|
||||
LogError(error);
|
||||
mpc_demux_exit(demux);
|
||||
@@ -214,7 +212,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
|
||||
mpc_uint32_t ret = frame.samples;
|
||||
ret *= info.channels;
|
||||
|
||||
int32_t chunk[ARRAY_SIZE(sample_buffer)];
|
||||
MpcdecSampleTraits::value_type chunk[ARRAY_SIZE(sample_buffer)];
|
||||
mpc_to_mpd_buffer(chunk, sample_buffer, ret);
|
||||
|
||||
long bit_rate = vbr_update_bits * audio_format.sample_rate
|
||||
|
@@ -40,6 +40,12 @@
|
||||
|
||||
static constexpr opus_int32 opus_sample_rate = 48000;
|
||||
|
||||
/**
|
||||
* Allocate an output buffer for 16 bit PCM samples big enough to hold
|
||||
* a quarter second, larger than 120ms required by libopus.
|
||||
*/
|
||||
static constexpr unsigned opus_output_buffer_frames = opus_sample_rate / 4;
|
||||
|
||||
gcc_pure
|
||||
static bool
|
||||
IsOpusHead(const ogg_packet &packet)
|
||||
@@ -70,10 +76,16 @@ class MPDOpusDecoder {
|
||||
|
||||
OpusDecoder *opus_decoder;
|
||||
opus_int16 *output_buffer;
|
||||
unsigned output_size;
|
||||
|
||||
/**
|
||||
* If non-zero, then a previous Opus stream has been found
|
||||
* already with this number of channels. If opus_decoder is
|
||||
* nullptr, then its end-of-stream packet has been found
|
||||
* already.
|
||||
*/
|
||||
unsigned previous_channels;
|
||||
|
||||
bool os_initialized;
|
||||
bool found_opus;
|
||||
|
||||
int opus_serialno;
|
||||
|
||||
@@ -86,8 +98,9 @@ public:
|
||||
InputStream &_input_stream)
|
||||
:decoder(_decoder), input_stream(_input_stream),
|
||||
opus_decoder(nullptr),
|
||||
output_buffer(nullptr), output_size(0),
|
||||
os_initialized(false), found_opus(false) {}
|
||||
output_buffer(nullptr),
|
||||
previous_channels(0),
|
||||
os_initialized(false) {}
|
||||
~MPDOpusDecoder();
|
||||
|
||||
bool ReadFirstPage(OggSyncState &oy);
|
||||
@@ -96,6 +109,7 @@ public:
|
||||
DecoderCommand HandlePackets();
|
||||
DecoderCommand HandlePacket(const ogg_packet &packet);
|
||||
DecoderCommand HandleBOS(const ogg_packet &packet);
|
||||
DecoderCommand HandleEOS();
|
||||
DecoderCommand HandleTags(const ogg_packet &packet);
|
||||
DecoderCommand HandleAudio(const ogg_packet &packet);
|
||||
|
||||
@@ -159,12 +173,14 @@ inline DecoderCommand
|
||||
MPDOpusDecoder::HandlePacket(const ogg_packet &packet)
|
||||
{
|
||||
if (packet.e_o_s)
|
||||
return DecoderCommand::STOP;
|
||||
return HandleEOS();
|
||||
|
||||
if (packet.b_o_s)
|
||||
return HandleBOS(packet);
|
||||
else if (!found_opus)
|
||||
else if (opus_decoder == nullptr) {
|
||||
LogDebug(opus_domain, "BOS packet expected");
|
||||
return DecoderCommand::STOP;
|
||||
}
|
||||
|
||||
if (IsOpusTags(packet))
|
||||
return HandleTags(packet);
|
||||
@@ -184,7 +200,7 @@ LoadEOSPacket(InputStream &is, Decoder *decoder, int serialno,
|
||||
/* we do this for local files only, because seeking
|
||||
around remote files is expensive and not worth the
|
||||
troubl */
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
const auto old_offset = is.GetOffset();
|
||||
|
||||
@@ -198,7 +214,7 @@ LoadEOSPacket(InputStream &is, Decoder *decoder, int serialno,
|
||||
ogg_stream_clear(&os);
|
||||
|
||||
/* restore the previous file position */
|
||||
is.Seek(old_offset, IgnoreError());
|
||||
is.LockSeek(old_offset, IgnoreError());
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -225,19 +241,29 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
|
||||
{
|
||||
assert(packet.b_o_s);
|
||||
|
||||
if (found_opus || !IsOpusHead(packet))
|
||||
if (opus_decoder != nullptr || !IsOpusHead(packet)) {
|
||||
LogDebug(opus_domain, "BOS packet must be OpusHead");
|
||||
return DecoderCommand::STOP;
|
||||
}
|
||||
|
||||
unsigned channels;
|
||||
if (!ScanOpusHeader(packet.packet, packet.bytes, channels) ||
|
||||
!audio_valid_channel_count(channels))
|
||||
!audio_valid_channel_count(channels)) {
|
||||
LogDebug(opus_domain, "Malformed BOS packet");
|
||||
return DecoderCommand::STOP;
|
||||
}
|
||||
|
||||
assert(opus_decoder == nullptr);
|
||||
assert(output_buffer == nullptr);
|
||||
assert((previous_channels == 0) == (output_buffer == nullptr));
|
||||
|
||||
if (previous_channels != 0 && channels != previous_channels) {
|
||||
FormatWarning(opus_domain,
|
||||
"Next stream has different channels (%u -> %u)",
|
||||
previous_channels, channels);
|
||||
return DecoderCommand::STOP;
|
||||
}
|
||||
|
||||
opus_serialno = os.serialno;
|
||||
found_opus = true;
|
||||
|
||||
/* TODO: parse attributes from the OpusHead (sample rate,
|
||||
channels, ...) */
|
||||
@@ -251,6 +277,13 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
|
||||
return DecoderCommand::STOP;
|
||||
}
|
||||
|
||||
if (previous_channels != 0) {
|
||||
/* decoder was already initialized by the previous
|
||||
stream; skip the rest of this method */
|
||||
LogDebug(opus_domain, "Found another stream");
|
||||
return decoder_get_command(decoder);
|
||||
}
|
||||
|
||||
eos_granulepos = LoadEOSGranulePos(input_stream, &decoder,
|
||||
opus_serialno);
|
||||
const auto duration = eos_granulepos >= 0
|
||||
@@ -258,21 +291,36 @@ MPDOpusDecoder::HandleBOS(const ogg_packet &packet)
|
||||
opus_sample_rate)
|
||||
: SignedSongTime::Negative();
|
||||
|
||||
previous_channels = channels;
|
||||
const AudioFormat audio_format(opus_sample_rate,
|
||||
SampleFormat::S16, channels);
|
||||
decoder_initialized(decoder, audio_format,
|
||||
eos_granulepos > 0, duration);
|
||||
frame_size = audio_format.GetFrameSize();
|
||||
|
||||
/* allocate an output buffer for 16 bit PCM samples big enough
|
||||
to hold a quarter second, larger than 120ms required by
|
||||
libopus */
|
||||
output_size = audio_format.sample_rate / 4;
|
||||
output_buffer = new opus_int16[output_size * audio_format.channels];
|
||||
output_buffer = new opus_int16[opus_output_buffer_frames
|
||||
* audio_format.channels];
|
||||
|
||||
return decoder_get_command(decoder);
|
||||
}
|
||||
|
||||
inline DecoderCommand
|
||||
MPDOpusDecoder::HandleEOS()
|
||||
{
|
||||
if (eos_granulepos < 0 && previous_channels != 0) {
|
||||
/* allow chaining of (unseekable) streams */
|
||||
assert(opus_decoder != nullptr);
|
||||
assert(output_buffer != nullptr);
|
||||
|
||||
opus_decoder_destroy(opus_decoder);
|
||||
opus_decoder = nullptr;
|
||||
|
||||
return decoder_get_command(decoder);
|
||||
}
|
||||
|
||||
return DecoderCommand::STOP;
|
||||
}
|
||||
|
||||
inline DecoderCommand
|
||||
MPDOpusDecoder::HandleTags(const ogg_packet &packet)
|
||||
{
|
||||
@@ -304,10 +352,11 @@ MPDOpusDecoder::HandleAudio(const ogg_packet &packet)
|
||||
int nframes = opus_decode(opus_decoder,
|
||||
(const unsigned char*)packet.packet,
|
||||
packet.bytes,
|
||||
output_buffer, output_size,
|
||||
output_buffer, opus_output_buffer_frames,
|
||||
0);
|
||||
if (nframes < 0) {
|
||||
LogError(opus_domain, opus_strerror(nframes));
|
||||
FormatError(opus_domain, "libopus error: %s",
|
||||
opus_strerror(nframes));
|
||||
return DecoderCommand::STOP;
|
||||
}
|
||||
|
||||
@@ -461,6 +510,13 @@ static const char *const opus_suffixes[] = {
|
||||
};
|
||||
|
||||
static const char *const opus_mime_types[] = {
|
||||
/* the official MIME type (RFC 5334) */
|
||||
"audio/ogg",
|
||||
|
||||
/* deprecated (RFC 5334) */
|
||||
"application/ogg",
|
||||
|
||||
/* deprecated; from an early draft */
|
||||
"audio/opus",
|
||||
nullptr
|
||||
};
|
||||
|
@@ -157,8 +157,6 @@ flac_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error)
|
||||
struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
|
||||
unsigned bits_per_sample;
|
||||
|
||||
encoder->audio_format = audio_format;
|
||||
|
||||
/* FIXME: flac should support 32bit as well */
|
||||
switch (audio_format.format) {
|
||||
case SampleFormat::S8:
|
||||
@@ -178,6 +176,8 @@ flac_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error)
|
||||
audio_format.format = SampleFormat::S24_P32;
|
||||
}
|
||||
|
||||
encoder->audio_format = audio_format;
|
||||
|
||||
/* allocate the encoder */
|
||||
encoder->fse = FLAC__stream_encoder_new();
|
||||
if (encoder->fse == nullptr) {
|
||||
|
@@ -66,7 +66,7 @@ struct opus_encoder {
|
||||
|
||||
ogg_int64_t granulepos;
|
||||
|
||||
opus_encoder():encoder(opus_encoder_plugin) {}
|
||||
opus_encoder():encoder(opus_encoder_plugin), granulepos(0) {}
|
||||
};
|
||||
|
||||
static constexpr Domain opus_encoder_domain("opus_encoder");
|
||||
|
@@ -26,7 +26,6 @@
|
||||
#include "util/NumberParser.hxx"
|
||||
#include "util/DynamicFifoBuffer.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
extern "C"
|
||||
{
|
||||
@@ -60,8 +59,6 @@ struct ShineEncoder {
|
||||
bool WriteChunk(bool flush);
|
||||
};
|
||||
|
||||
static constexpr Domain shine_encoder_domain("shine_encoder");
|
||||
|
||||
inline bool
|
||||
ShineEncoder::Configure(const config_param ¶m,
|
||||
gcc_unused Error &error)
|
||||
|
@@ -21,9 +21,6 @@
|
||||
#define MPD_SOCKET_DEFERRED_MONITOR_HXX
|
||||
|
||||
#include "check.h"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
class EventLoop;
|
||||
|
||||
|
@@ -179,9 +179,10 @@ EventLoop::Run()
|
||||
mutex.lock();
|
||||
HandleDeferred();
|
||||
busy = false;
|
||||
const bool _again = again;
|
||||
mutex.unlock();
|
||||
|
||||
if (again)
|
||||
if (_again)
|
||||
/* re-evaluate timers because one of the
|
||||
IdleMonitors may have added a new
|
||||
timeout */
|
||||
|
@@ -130,7 +130,7 @@ get_remote_uid(int fd)
|
||||
socklen_t len = sizeof (cred);
|
||||
|
||||
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) < 0)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
return cred.uid;
|
||||
#else
|
||||
|
@@ -53,10 +53,11 @@ public:
|
||||
children.emplace_back(name, filter);
|
||||
}
|
||||
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error);
|
||||
/* virtual methods from class Filter */
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@@ -34,10 +34,11 @@ class NormalizeFilter final : public Filter {
|
||||
PcmBuffer buffer;
|
||||
|
||||
public:
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error) override;
|
||||
/* virtual methods from class Filter */
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error) override;
|
||||
};
|
||||
|
||||
static Filter *
|
||||
|
@@ -112,10 +112,11 @@ public:
|
||||
*/
|
||||
void Update();
|
||||
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error) override;
|
||||
/* virtual methods from class Filter */
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error) override;
|
||||
};
|
||||
|
||||
void
|
||||
|
@@ -120,10 +120,11 @@ public:
|
||||
*/
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error) override;
|
||||
/* virtual methods from class Filter */
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error) override;
|
||||
};
|
||||
|
||||
bool
|
||||
|
@@ -26,7 +26,6 @@
|
||||
#include "AudioFormat.hxx"
|
||||
#include "util/ConstBuffer.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
@@ -43,14 +42,13 @@ public:
|
||||
pv.SetVolume(_volume);
|
||||
}
|
||||
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error) override;
|
||||
/* virtual methods from class Filter */
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
ConstBuffer<void> FilterPCM(ConstBuffer<void> src,
|
||||
Error &error) override;
|
||||
};
|
||||
|
||||
static constexpr Domain volume_domain("pcm_volume");
|
||||
|
||||
static Filter *
|
||||
volume_filter_init(gcc_unused const config_param ¶m,
|
||||
gcc_unused Error &error)
|
||||
|
@@ -46,7 +46,11 @@ AllocatedPath
|
||||
AllocatedPath::FromUTF8(const char *path_utf8)
|
||||
{
|
||||
#ifdef HAVE_GLIB
|
||||
return AllocatedPath(Donate(), ::PathFromUTF8(path_utf8));
|
||||
char *path = ::PathFromUTF8(path_utf8);
|
||||
if (path == nullptr)
|
||||
return AllocatedPath::Null();
|
||||
|
||||
return AllocatedPath(Donate(), path);
|
||||
#else
|
||||
return FromFS(path_utf8);
|
||||
#endif
|
||||
|
@@ -34,6 +34,8 @@
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
|
||||
/**
|
||||
* Maximal number of bytes required to represent path name in UTF-8
|
||||
* (including nul-terminator).
|
||||
@@ -44,7 +46,6 @@
|
||||
*/
|
||||
static constexpr size_t MPD_PATH_MAX_UTF8 = (MPD_PATH_MAX - 1) * 4 + 1;
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
static std::string fs_charset;
|
||||
|
||||
gcc_pure
|
||||
@@ -102,7 +103,10 @@ static inline void FixSeparators(std::string &s)
|
||||
std::string
|
||||
PathToUTF8(const char *path_fs)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(path_fs != nullptr);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
if (fs_charset.empty()) {
|
||||
@@ -143,7 +147,10 @@ PathToUTF8(const char *path_fs)
|
||||
char *
|
||||
PathFromUTF8(const char *path_utf8)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(path_utf8 != nullptr);
|
||||
#endif
|
||||
|
||||
if (fs_charset.empty())
|
||||
return g_strdup(path_utf8);
|
||||
|
@@ -52,7 +52,10 @@ template<typename Traits>
|
||||
typename Traits::const_pointer
|
||||
GetBasePathImpl(typename Traits::const_pointer p)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(p != nullptr);
|
||||
#endif
|
||||
|
||||
typename Traits::const_pointer sep = Traits::FindLastSeparator(p);
|
||||
return sep != nullptr
|
||||
@@ -64,7 +67,10 @@ template<typename Traits>
|
||||
typename Traits::string
|
||||
GetParentPathImpl(typename Traits::const_pointer p)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(p != nullptr);
|
||||
#endif
|
||||
|
||||
typename Traits::const_pointer sep = Traits::FindLastSeparator(p);
|
||||
if (sep == nullptr)
|
||||
|
@@ -57,7 +57,11 @@ struct PathTraitsFS {
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static const_pointer FindLastSeparator(const_pointer p) {
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(p != nullptr);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
const_pointer pos = p + GetLength(p);
|
||||
while (p != pos && !IsSeparator(*pos))
|
||||
@@ -77,7 +81,11 @@ struct PathTraitsFS {
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static bool IsAbsolute(const_pointer p) {
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(p != nullptr);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
if (IsDrive(p) && IsSeparator(p[2]))
|
||||
return true;
|
||||
@@ -147,7 +155,11 @@ struct PathTraitsUTF8 {
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static const_pointer FindLastSeparator(const_pointer p) {
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(p != nullptr);
|
||||
#endif
|
||||
|
||||
return strrchr(p, SEPARATOR);
|
||||
}
|
||||
|
||||
@@ -160,7 +172,11 @@ struct PathTraitsUTF8 {
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static bool IsAbsolute(const_pointer p) {
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(p != nullptr);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
if (IsDrive(p) && IsSeparator(p[2]))
|
||||
return true;
|
||||
|
@@ -62,6 +62,7 @@ FileOutputStream::Commit(gcc_unused Error &error)
|
||||
assert(IsDefined());
|
||||
|
||||
CloseHandle(handle);
|
||||
handle = INVALID_HANDLE_VALUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -71,6 +72,7 @@ FileOutputStream::Cancel()
|
||||
assert(IsDefined());
|
||||
|
||||
CloseHandle(handle);
|
||||
handle = INVALID_HANDLE_VALUE;
|
||||
RemoveFile(path);
|
||||
}
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "config.h"
|
||||
#include "AsyncInputStream.hxx"
|
||||
#include "Domain.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "event/Call.hxx"
|
||||
#include "thread/Cond.hxx"
|
||||
@@ -113,8 +114,10 @@ AsyncInputStream::Seek(offset_type new_offset, Error &error)
|
||||
/* no-op */
|
||||
return true;
|
||||
|
||||
if (!IsSeekable())
|
||||
if (!IsSeekable()) {
|
||||
error.Set(input_domain, "Not seekable");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check if we can fast-forward the buffer */
|
||||
|
||||
@@ -157,6 +160,11 @@ AsyncInputStream::SeekDone()
|
||||
assert(io_thread_inside());
|
||||
assert(IsSeekPending());
|
||||
|
||||
/* we may have reached end-of-file previously, and the
|
||||
connection may have been closed already; however after
|
||||
seeking successfully, the connection must be alive again */
|
||||
open = true;
|
||||
|
||||
seek_state = SeekState::NONE;
|
||||
cond.broadcast();
|
||||
}
|
||||
|
@@ -83,6 +83,10 @@ protected:
|
||||
*/
|
||||
void SetTag(Tag *_tag);
|
||||
|
||||
void ClearTag() {
|
||||
SetTag(nullptr);
|
||||
}
|
||||
|
||||
void Pause();
|
||||
|
||||
bool IsPaused() const {
|
||||
|
@@ -17,9 +17,8 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_DECODER_MP4V2_HXX
|
||||
#define MPD_DECODER_MP4V2_HXX
|
||||
#include "config.h"
|
||||
#include "Domain.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
extern const struct DecoderPlugin mp4v2_decoder_plugin;
|
||||
|
||||
#endif
|
||||
const Domain input_domain("input");
|
@@ -17,9 +17,11 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef INPUT_DESPOTIFY_HXX
|
||||
#define INPUT_DESPOTIFY_HXX
|
||||
#ifndef MPD_INPUT_DOMAIN_HXX
|
||||
#define MPD_INPUT_DOMAIN_HXX
|
||||
|
||||
extern const struct InputPlugin input_plugin_despotify;
|
||||
class Domain;
|
||||
|
||||
extern const Domain input_domain;
|
||||
|
||||
#endif
|
@@ -67,7 +67,7 @@ input_stream_global_init(Error &error)
|
||||
case InputPlugin::InitResult::UNAVAILABLE:
|
||||
if (error.IsDefined()) {
|
||||
FormatError(error,
|
||||
"Input plugin '%s' is unavailable: ",
|
||||
"Input plugin '%s' is unavailable",
|
||||
plugin->name);
|
||||
error.Clear();
|
||||
}
|
||||
|
@@ -122,7 +122,10 @@ InputStream::IsAvailable()
|
||||
size_t
|
||||
InputStream::LockRead(void *ptr, size_t _size, Error &error)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(ptr != nullptr);
|
||||
#endif
|
||||
assert(_size > 0);
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
|
@@ -200,6 +200,10 @@ public:
|
||||
return mime.empty() ? nullptr : mime.c_str();
|
||||
}
|
||||
|
||||
void ClearMimeType() {
|
||||
mime.clear();
|
||||
}
|
||||
|
||||
gcc_nonnull_all
|
||||
void SetMimeType(const char *_mime) {
|
||||
assert(!ready);
|
||||
|
@@ -22,14 +22,13 @@
|
||||
#include "Registry.hxx"
|
||||
#include "InputPlugin.hxx"
|
||||
#include "LocalOpen.hxx"
|
||||
#include "Domain.hxx"
|
||||
#include "plugins/RewindInputPlugin.hxx"
|
||||
#include "fs/Traits.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
|
||||
static constexpr Domain input_domain("input");
|
||||
|
||||
InputStream *
|
||||
InputStream::Open(const char *url,
|
||||
Mutex &mutex, Cond &cond,
|
||||
|
@@ -54,10 +54,6 @@
|
||||
#include "plugins/CdioParanoiaInputPlugin.hxx"
|
||||
#endif
|
||||
|
||||
#ifdef ENABLE_DESPOTIFY
|
||||
#include "plugins/DespotifyInputPlugin.hxx"
|
||||
#endif
|
||||
|
||||
const InputPlugin *const input_plugins[] = {
|
||||
&input_plugin_file,
|
||||
#ifdef HAVE_ALSA
|
||||
@@ -83,9 +79,6 @@ const InputPlugin *const input_plugins[] = {
|
||||
#endif
|
||||
#ifdef ENABLE_CDIO_PARANOIA
|
||||
&input_plugin_cdio_paranoia,
|
||||
#endif
|
||||
#ifdef ENABLE_DESPOTIFY
|
||||
&input_plugin_despotify,
|
||||
#endif
|
||||
nullptr
|
||||
};
|
||||
|
@@ -33,11 +33,13 @@ TextInputStream::ReadLine()
|
||||
if (line != nullptr)
|
||||
return line;
|
||||
|
||||
buffer.Shift();
|
||||
|
||||
while (true) {
|
||||
auto dest = buffer.Write();
|
||||
if (dest.size < 2) {
|
||||
/* end of file (or line too long): terminate
|
||||
the current line */
|
||||
/* line too long: terminate the current
|
||||
line */
|
||||
|
||||
assert(!dest.IsEmpty());
|
||||
dest[0] = 0;
|
||||
@@ -64,7 +66,19 @@ TextInputStream::ReadLine()
|
||||
if (line != nullptr)
|
||||
return line;
|
||||
|
||||
if (nbytes == 0)
|
||||
return nullptr;
|
||||
if (nbytes == 0) {
|
||||
/* end of file: see if there's an unterminated
|
||||
line */
|
||||
|
||||
dest = buffer.Write();
|
||||
assert(!dest.IsEmpty());
|
||||
dest[0] = 0;
|
||||
|
||||
auto r = buffer.Read();
|
||||
buffer.Clear();
|
||||
return r.IsEmpty()
|
||||
? nullptr
|
||||
: r.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -88,7 +88,7 @@ ThreadInputStream::ThreadFunc()
|
||||
Unlock();
|
||||
|
||||
Error error;
|
||||
size_t nbytes = Read(w.data, w.size, error);
|
||||
size_t nbytes = ThreadRead(w.data, w.size, error);
|
||||
|
||||
Lock();
|
||||
cond.broadcast();
|
||||
@@ -118,6 +118,8 @@ ThreadInputStream::ThreadFunc(void *ctx)
|
||||
bool
|
||||
ThreadInputStream::Check(Error &error)
|
||||
{
|
||||
assert(!thread.IsInside());
|
||||
|
||||
if (postponed_error.IsDefined()) {
|
||||
error = std::move(postponed_error);
|
||||
return false;
|
||||
@@ -129,12 +131,16 @@ ThreadInputStream::Check(Error &error)
|
||||
bool
|
||||
ThreadInputStream::IsAvailable()
|
||||
{
|
||||
assert(!thread.IsInside());
|
||||
|
||||
return !buffer->IsEmpty() || eof || postponed_error.IsDefined();
|
||||
}
|
||||
|
||||
inline size_t
|
||||
ThreadInputStream::Read(void *ptr, size_t read_size, Error &error)
|
||||
{
|
||||
assert(!thread.IsInside());
|
||||
|
||||
while (true) {
|
||||
if (postponed_error.IsDefined()) {
|
||||
error = std::move(postponed_error);
|
||||
@@ -161,5 +167,7 @@ ThreadInputStream::Read(void *ptr, size_t read_size, Error &error)
|
||||
bool
|
||||
ThreadInputStream::IsEOF()
|
||||
{
|
||||
assert(!thread.IsInside());
|
||||
|
||||
return eof;
|
||||
}
|
||||
|
@@ -43,6 +43,8 @@
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
|
||||
#include <atomic>
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@@ -109,6 +109,13 @@ struct CurlInputStream final : public AsyncInputStream {
|
||||
*/
|
||||
void FreeEasyIndirect();
|
||||
|
||||
/**
|
||||
* Called when a new response begins. This is used to discard
|
||||
* headers from previous responses (for example authentication
|
||||
* and redirects).
|
||||
*/
|
||||
void ResponseBoundary();
|
||||
|
||||
void HeaderReceived(const char *name, std::string &&value);
|
||||
|
||||
size_t DataReceived(const void *ptr, size_t size);
|
||||
@@ -446,6 +453,8 @@ CurlInputStream::RequestDone(CURLcode result, long status)
|
||||
SeekDone();
|
||||
else if (!IsReady())
|
||||
SetReady();
|
||||
else
|
||||
cond.broadcast();
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -597,6 +606,24 @@ CurlInputStream::~CurlInputStream()
|
||||
FreeEasyIndirect();
|
||||
}
|
||||
|
||||
inline void
|
||||
CurlInputStream::ResponseBoundary()
|
||||
{
|
||||
/* undo all effects of HeaderReceived() because the previous
|
||||
response was not applicable for this stream */
|
||||
|
||||
if (IsSeekPending())
|
||||
/* don't update metadata while seeking */
|
||||
return;
|
||||
|
||||
seekable = false;
|
||||
size = UNKNOWN_SIZE;
|
||||
ClearMimeType();
|
||||
ClearTag();
|
||||
|
||||
// TODO: reset the IcyInputStream?
|
||||
}
|
||||
|
||||
inline void
|
||||
CurlInputStream::HeaderReceived(const char *name, std::string &&value)
|
||||
{
|
||||
@@ -645,6 +672,11 @@ input_curl_headerfunction(void *ptr, size_t size, size_t nmemb, void *stream)
|
||||
size *= nmemb;
|
||||
|
||||
const char *header = (const char *)ptr;
|
||||
if (size > 5 && memcmp(header, "HTTP/", 5) == 0) {
|
||||
c.ResponseBoundary();
|
||||
return size;
|
||||
}
|
||||
|
||||
const char *end = header + size;
|
||||
|
||||
char name[64];
|
||||
@@ -720,10 +752,10 @@ CurlInputStream::InitEasy(Error &error)
|
||||
input_curl_writefunction);
|
||||
curl_easy_setopt(easy, CURLOPT_WRITEDATA, this);
|
||||
curl_easy_setopt(easy, CURLOPT_HTTP200ALIASES, http_200_aliases);
|
||||
curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(easy, CURLOPT_NETRC, 1);
|
||||
curl_easy_setopt(easy, CURLOPT_MAXREDIRS, 5);
|
||||
curl_easy_setopt(easy, CURLOPT_FAILONERROR, true);
|
||||
curl_easy_setopt(easy, CURLOPT_FOLLOWLOCATION, 1l);
|
||||
curl_easy_setopt(easy, CURLOPT_NETRC, 1l);
|
||||
curl_easy_setopt(easy, CURLOPT_MAXREDIRS, 5l);
|
||||
curl_easy_setopt(easy, CURLOPT_FAILONERROR, 1l);
|
||||
curl_easy_setopt(easy, CURLOPT_ERRORBUFFER, error_buffer);
|
||||
curl_easy_setopt(easy, CURLOPT_NOPROGRESS, 1l);
|
||||
curl_easy_setopt(easy, CURLOPT_NOSIGNAL, 1l);
|
||||
|
@@ -1,227 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "DespotifyInputPlugin.hxx"
|
||||
#include "lib/despotify/DespotifyUtils.hxx"
|
||||
#include "../InputStream.hxx"
|
||||
#include "../InputPlugin.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "util/StringUtil.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
extern "C" {
|
||||
#include <despotify.h>
|
||||
}
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
class DespotifyInputStream final : public InputStream {
|
||||
struct despotify_session *session;
|
||||
struct ds_track *track;
|
||||
Tag tag;
|
||||
struct ds_pcm_data pcm;
|
||||
size_t len_available;
|
||||
bool eof;
|
||||
|
||||
DespotifyInputStream(const char *_uri,
|
||||
Mutex &_mutex, Cond &_cond,
|
||||
despotify_session *_session,
|
||||
ds_track *_track)
|
||||
:InputStream(_uri, _mutex, _cond),
|
||||
session(_session), track(_track),
|
||||
tag(mpd_despotify_tag_from_track(*track)),
|
||||
len_available(0), eof(false) {
|
||||
|
||||
memset(&pcm, 0, sizeof(pcm));
|
||||
|
||||
/* Despotify outputs pcm data */
|
||||
SetMimeType("audio/x-mpd-cdda-pcm");
|
||||
SetReady();
|
||||
}
|
||||
|
||||
public:
|
||||
~DespotifyInputStream();
|
||||
|
||||
static InputStream *Open(const char *url, Mutex &mutex, Cond &cond,
|
||||
Error &error);
|
||||
|
||||
void Callback(int sig);
|
||||
|
||||
/* virtual methods from InputStream */
|
||||
|
||||
bool IsEOF() override {
|
||||
return eof;
|
||||
}
|
||||
|
||||
Tag *ReadTag() override {
|
||||
if (tag.IsEmpty())
|
||||
return nullptr;
|
||||
|
||||
Tag *result = new Tag(std::move(tag));
|
||||
tag.Clear();
|
||||
return result;
|
||||
}
|
||||
|
||||
size_t Read(void *ptr, size_t size, Error &error) override;
|
||||
|
||||
private:
|
||||
void FillBuffer();
|
||||
};
|
||||
|
||||
inline void
|
||||
DespotifyInputStream::FillBuffer()
|
||||
{
|
||||
/* Wait until there is data */
|
||||
while (1) {
|
||||
int rc = despotify_get_pcm(session, &pcm);
|
||||
|
||||
if (rc == 0 && pcm.len) {
|
||||
len_available = pcm.len;
|
||||
break;
|
||||
}
|
||||
|
||||
if (eof == true)
|
||||
break;
|
||||
|
||||
if (rc < 0) {
|
||||
LogDebug(despotify_domain, "despotify_get_pcm error");
|
||||
eof = true;
|
||||
break;
|
||||
}
|
||||
|
||||
/* Wait a while until next iteration */
|
||||
usleep(50 * 1000);
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
DespotifyInputStream::Callback(int sig)
|
||||
{
|
||||
switch (sig) {
|
||||
case DESPOTIFY_NEW_TRACK:
|
||||
break;
|
||||
|
||||
case DESPOTIFY_TIME_TELL:
|
||||
break;
|
||||
|
||||
case DESPOTIFY_TRACK_PLAY_ERROR:
|
||||
LogWarning(despotify_domain, "Track play error");
|
||||
eof = true;
|
||||
len_available = 0;
|
||||
break;
|
||||
|
||||
case DESPOTIFY_END_OF_PLAYLIST:
|
||||
eof = true;
|
||||
LogDebug(despotify_domain, "End of playlist");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void callback(gcc_unused struct despotify_session* ds,
|
||||
int sig, gcc_unused void* data, void* callback_data)
|
||||
{
|
||||
DespotifyInputStream *ctx = (DespotifyInputStream *)callback_data;
|
||||
|
||||
ctx->Callback(sig);
|
||||
}
|
||||
|
||||
DespotifyInputStream::~DespotifyInputStream()
|
||||
{
|
||||
mpd_despotify_unregister_callback(callback);
|
||||
despotify_free_track(track);
|
||||
}
|
||||
|
||||
inline InputStream *
|
||||
DespotifyInputStream::Open(const char *url,
|
||||
Mutex &mutex, Cond &cond,
|
||||
gcc_unused Error &error)
|
||||
{
|
||||
if (!StringStartsWith(url, "spt://"))
|
||||
return nullptr;
|
||||
|
||||
despotify_session *session = mpd_despotify_get_session();
|
||||
if (session == nullptr)
|
||||
return nullptr;
|
||||
|
||||
ds_link *ds_link = despotify_link_from_uri(url + 6);
|
||||
if (!ds_link) {
|
||||
FormatDebug(despotify_domain, "Can't find %s", url);
|
||||
return nullptr;
|
||||
}
|
||||
if (ds_link->type != LINK_TYPE_TRACK) {
|
||||
despotify_free_link(ds_link);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
ds_track *track = despotify_link_get_track(session, ds_link);
|
||||
despotify_free_link(ds_link);
|
||||
if (!track)
|
||||
return nullptr;
|
||||
|
||||
DespotifyInputStream *ctx =
|
||||
new DespotifyInputStream(url, mutex, cond,
|
||||
session, track);
|
||||
|
||||
if (!mpd_despotify_register_callback(callback, ctx)) {
|
||||
delete ctx;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (despotify_play(ctx->session, ctx->track, false) == false) {
|
||||
mpd_despotify_unregister_callback(callback);
|
||||
delete ctx;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static InputStream *
|
||||
input_despotify_open(const char *url, Mutex &mutex, Cond &cond, Error &error)
|
||||
{
|
||||
return DespotifyInputStream::Open(url, mutex, cond, error);
|
||||
}
|
||||
|
||||
size_t
|
||||
DespotifyInputStream::Read(void *ptr, size_t read_size,
|
||||
gcc_unused Error &error)
|
||||
{
|
||||
if (len_available == 0)
|
||||
FillBuffer();
|
||||
|
||||
size_t to_cpy = std::min(read_size, len_available);
|
||||
memcpy(ptr, pcm.buf, to_cpy);
|
||||
len_available -= to_cpy;
|
||||
|
||||
offset += to_cpy;
|
||||
|
||||
return to_cpy;
|
||||
}
|
||||
|
||||
const InputPlugin input_plugin_despotify = {
|
||||
"despotify",
|
||||
nullptr,
|
||||
nullptr,
|
||||
input_despotify_open,
|
||||
};
|
@@ -43,7 +43,7 @@ protected:
|
||||
virtual size_t ThreadRead(void *ptr, size_t size,
|
||||
Error &error) override;
|
||||
|
||||
virtual void Close() {
|
||||
void Close() override {
|
||||
mmsx_close(mms);
|
||||
}
|
||||
};
|
||||
@@ -92,6 +92,13 @@ input_mms_open(const char *url,
|
||||
size_t
|
||||
MmsInputStream::ThreadRead(void *ptr, size_t read_size, Error &error)
|
||||
{
|
||||
/* unfortunately, mmsx_read() blocks until the whole buffer
|
||||
has been filled; to avoid big latencies, limit the size of
|
||||
each chunk we read to a reasonable size */
|
||||
constexpr size_t MAX_CHUNK = 16384;
|
||||
if (read_size > MAX_CHUNK)
|
||||
read_size = MAX_CHUNK;
|
||||
|
||||
int nbytes = mmsx_read(nullptr, mms, (char *)ptr, read_size);
|
||||
if (nbytes <= 0) {
|
||||
if (nbytes < 0)
|
||||
|
@@ -132,6 +132,7 @@ SmbclientInputStream::Read(void *ptr, size_t read_size, Error &error)
|
||||
nbytes = 0;
|
||||
}
|
||||
|
||||
offset += nbytes;
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
|
@@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#ifndef JAVA_FILE_HXX
|
||||
#define JAVA_FILE_HPP
|
||||
#define JAVA_FILE_HXX
|
||||
|
||||
#include "Object.hxx"
|
||||
|
||||
|
@@ -1,153 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "DespotifyUtils.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "tag/TagBuilder.hxx"
|
||||
#include "config/ConfigGlobal.hxx"
|
||||
#include "config/ConfigOption.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
extern "C" {
|
||||
#include <despotify.h>
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
const Domain despotify_domain("despotify");
|
||||
|
||||
static struct despotify_session *g_session;
|
||||
static void (*registered_callbacks[8])(struct despotify_session *,
|
||||
int, void *, void *);
|
||||
static void *registered_callback_data[8];
|
||||
|
||||
static void
|
||||
callback(struct despotify_session* ds, int sig,
|
||||
void *data, gcc_unused void *callback_data)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
|
||||
void (*cb)(struct despotify_session *, int, void *, void *) = registered_callbacks[i];
|
||||
void *cb_data = registered_callback_data[i];
|
||||
|
||||
if (cb)
|
||||
cb(ds, sig, data, cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
bool mpd_despotify_register_callback(void (*cb)(struct despotify_session *, int, void *, void *),
|
||||
void *cb_data)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
|
||||
|
||||
if (!registered_callbacks[i]) {
|
||||
registered_callbacks[i] = cb;
|
||||
registered_callback_data[i] = cb_data;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void mpd_despotify_unregister_callback(void (*cb)(struct despotify_session *, int, void *, void *))
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < sizeof(registered_callbacks) / sizeof(registered_callbacks[0]); i++) {
|
||||
|
||||
if (registered_callbacks[i] == cb) {
|
||||
registered_callbacks[i] = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Tag
|
||||
mpd_despotify_tag_from_track(const ds_track &track)
|
||||
{
|
||||
char tracknum[20];
|
||||
char comment[80];
|
||||
char date[20];
|
||||
|
||||
if (!track.has_meta_data)
|
||||
return Tag();
|
||||
|
||||
TagBuilder tag;
|
||||
snprintf(tracknum, sizeof(tracknum), "%d", track.tracknumber);
|
||||
snprintf(date, sizeof(date), "%d", track.year);
|
||||
snprintf(comment, sizeof(comment), "Bitrate %d Kbps, %sgeo restricted",
|
||||
track.file_bitrate / 1000,
|
||||
track.geo_restricted ? "" : "not ");
|
||||
tag.AddItem(TAG_TITLE, track.title);
|
||||
tag.AddItem(TAG_ARTIST, track.artist->name);
|
||||
tag.AddItem(TAG_TRACK, tracknum);
|
||||
tag.AddItem(TAG_ALBUM, track.album);
|
||||
tag.AddItem(TAG_DATE, date);
|
||||
tag.AddItem(TAG_COMMENT, comment);
|
||||
tag.SetDuration(SignedSongTime::FromMS(track.length));
|
||||
|
||||
return tag.Commit();
|
||||
}
|
||||
|
||||
struct despotify_session *mpd_despotify_get_session(void)
|
||||
{
|
||||
const char *user;
|
||||
const char *passwd;
|
||||
bool high_bitrate;
|
||||
|
||||
if (g_session)
|
||||
return g_session;
|
||||
|
||||
user = config_get_string(CONF_DESPOTIFY_USER, nullptr);
|
||||
passwd = config_get_string(CONF_DESPOTIFY_PASSWORD, nullptr);
|
||||
high_bitrate = config_get_bool(CONF_DESPOTIFY_HIGH_BITRATE, true);
|
||||
|
||||
if (user == nullptr || passwd == nullptr) {
|
||||
LogDebug(despotify_domain,
|
||||
"disabling despotify because account is not configured");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!despotify_init()) {
|
||||
LogWarning(despotify_domain, "Can't initialize despotify");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
g_session = despotify_init_client(callback, nullptr,
|
||||
high_bitrate, true);
|
||||
if (!g_session) {
|
||||
LogWarning(despotify_domain,
|
||||
"Can't initialize despotify client");
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!despotify_authenticate(g_session, user, passwd)) {
|
||||
LogWarning(despotify_domain,
|
||||
"Can't authenticate despotify session");
|
||||
despotify_exit(g_session);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return g_session;
|
||||
}
|
@@ -1,71 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef MPD_DESPOTIFY_H
|
||||
#define MPD_DESPOTIFY_H
|
||||
|
||||
struct Tag;
|
||||
struct despotify_session;
|
||||
struct ds_track;
|
||||
|
||||
extern const class Domain despotify_domain;
|
||||
|
||||
/**
|
||||
* Return the current despotify session.
|
||||
*
|
||||
* If the session isn't initialized, this function will initialize
|
||||
* it and connect to Spotify.
|
||||
*
|
||||
* @return a pointer to the despotify session, or nullptr if it can't
|
||||
* be initialized (e.g., if the configuration isn't supplied)
|
||||
*/
|
||||
struct despotify_session *mpd_despotify_get_session(void);
|
||||
|
||||
/**
|
||||
* Create a MPD tags structure from a spotify track
|
||||
*
|
||||
* @param track the track to convert
|
||||
*
|
||||
* @return filled in #Tag structure
|
||||
*/
|
||||
Tag
|
||||
mpd_despotify_tag_from_track(const ds_track &track);
|
||||
|
||||
/**
|
||||
* Register a despotify callback.
|
||||
*
|
||||
* Despotify calls this e.g., when a track ends.
|
||||
*
|
||||
* @param cb the callback
|
||||
* @param cb_data the data to pass to the callback
|
||||
*
|
||||
* @return true if the callback could be registered
|
||||
*/
|
||||
bool mpd_despotify_register_callback(void (*cb)(struct despotify_session *, int, void *, void *),
|
||||
void *cb_data);
|
||||
|
||||
/**
|
||||
* Unregister a despotify callback.
|
||||
*
|
||||
* @param cb the callback to unregister.
|
||||
*/
|
||||
void mpd_despotify_unregister_callback(void (*cb)(struct despotify_session *, int, void *, void *));
|
||||
|
||||
#endif
|
||||
|
@@ -121,8 +121,11 @@ gcc_pure
|
||||
int
|
||||
IcuCollate(const char *a, const char *b)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(a != nullptr);
|
||||
assert(b != nullptr);
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_ICU
|
||||
assert(collator != nullptr);
|
||||
@@ -159,7 +162,10 @@ IcuCaseFold(const char *src)
|
||||
{
|
||||
#ifdef HAVE_ICU
|
||||
assert(collator != nullptr);
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(src != nullptr);
|
||||
#endif
|
||||
|
||||
const auto u = UCharFromUTF8(src);
|
||||
if (u.IsNull())
|
||||
|
@@ -20,7 +20,9 @@
|
||||
#include "config.h"
|
||||
#include "Blocking.hxx"
|
||||
#include "Connection.hxx"
|
||||
#include "Domain.hxx"
|
||||
#include "event/Call.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
bool
|
||||
BlockingNfsOperation::Run(Error &_error)
|
||||
@@ -31,7 +33,10 @@ BlockingNfsOperation::Run(Error &_error)
|
||||
[this](){ connection.AddLease(*this); });
|
||||
|
||||
/* wait for completion */
|
||||
LockWaitFinished();
|
||||
if (!LockWaitFinished()) {
|
||||
_error.Set(nfs_domain, 0, "Timeout");
|
||||
return false;
|
||||
}
|
||||
|
||||
/* check for error */
|
||||
if (error.IsDefined()) {
|
||||
|
@@ -35,6 +35,8 @@ class NfsConnection;
|
||||
* thread, and method Run() waits for completion.
|
||||
*/
|
||||
class BlockingNfsOperation : protected NfsCallback, NfsLease {
|
||||
static constexpr unsigned timeout_ms = 60000;
|
||||
|
||||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
@@ -52,10 +54,13 @@ public:
|
||||
bool Run(Error &error);
|
||||
|
||||
private:
|
||||
void LockWaitFinished() {
|
||||
bool LockWaitFinished() {
|
||||
const ScopeLock protect(mutex);
|
||||
while (!finished)
|
||||
cond.wait(mutex);
|
||||
if (!cond.timed_wait(mutex, timeout_ms))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -157,6 +157,12 @@ public:
|
||||
|
||||
return *i;
|
||||
}
|
||||
|
||||
template<typename F>
|
||||
void ForEach(F &&f) {
|
||||
for (CT &i : list)
|
||||
f(i);
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -34,11 +34,15 @@ extern "C" {
|
||||
|
||||
#include <poll.h> /* for POLLIN, POLLOUT */
|
||||
|
||||
static constexpr unsigned NFS_MOUNT_TIMEOUT = 60;
|
||||
|
||||
inline bool
|
||||
NfsConnection::CancellableCallback::Stat(nfs_context *ctx,
|
||||
const char *path,
|
||||
Error &error)
|
||||
{
|
||||
assert(connection.GetEventLoop().IsInside());
|
||||
|
||||
int result = nfs_stat_async(ctx, path, Callback, this);
|
||||
if (result < 0) {
|
||||
error.Format(nfs_domain, "nfs_stat_async() failed: %s",
|
||||
@@ -54,6 +58,8 @@ NfsConnection::CancellableCallback::OpenDirectory(nfs_context *ctx,
|
||||
const char *path,
|
||||
Error &error)
|
||||
{
|
||||
assert(connection.GetEventLoop().IsInside());
|
||||
|
||||
int result = nfs_opendir_async(ctx, path, Callback, this);
|
||||
if (result < 0) {
|
||||
error.Format(nfs_domain, "nfs_opendir_async() failed: %s",
|
||||
@@ -69,6 +75,8 @@ NfsConnection::CancellableCallback::Open(nfs_context *ctx,
|
||||
const char *path, int flags,
|
||||
Error &error)
|
||||
{
|
||||
assert(connection.GetEventLoop().IsInside());
|
||||
|
||||
int result = nfs_open_async(ctx, path, flags,
|
||||
Callback, this);
|
||||
if (result < 0) {
|
||||
@@ -85,6 +93,8 @@ NfsConnection::CancellableCallback::Stat(nfs_context *ctx,
|
||||
struct nfsfh *fh,
|
||||
Error &error)
|
||||
{
|
||||
assert(connection.GetEventLoop().IsInside());
|
||||
|
||||
int result = nfs_fstat_async(ctx, fh, Callback, this);
|
||||
if (result < 0) {
|
||||
error.Format(nfs_domain, "nfs_fstat_async() failed: %s",
|
||||
@@ -100,6 +110,8 @@ NfsConnection::CancellableCallback::Read(nfs_context *ctx, struct nfsfh *fh,
|
||||
uint64_t offset, size_t size,
|
||||
Error &error)
|
||||
{
|
||||
assert(connection.GetEventLoop().IsInside());
|
||||
|
||||
int result = nfs_pread_async(ctx, fh, offset, size, Callback, this);
|
||||
if (result < 0) {
|
||||
error.Format(nfs_domain, "nfs_pread_async() failed: %s",
|
||||
@@ -113,6 +125,7 @@ NfsConnection::CancellableCallback::Read(nfs_context *ctx, struct nfsfh *fh,
|
||||
inline void
|
||||
NfsConnection::CancellableCallback::CancelAndScheduleClose(struct nfsfh *fh)
|
||||
{
|
||||
assert(connection.GetEventLoop().IsInside());
|
||||
assert(!open);
|
||||
assert(close_fh == nullptr);
|
||||
assert(fh != nullptr);
|
||||
@@ -121,9 +134,22 @@ NfsConnection::CancellableCallback::CancelAndScheduleClose(struct nfsfh *fh)
|
||||
Cancel();
|
||||
}
|
||||
|
||||
inline void
|
||||
NfsConnection::CancellableCallback::PrepareDestroyContext()
|
||||
{
|
||||
assert(IsCancelled());
|
||||
|
||||
if (close_fh != nullptr) {
|
||||
connection.InternalClose(close_fh);
|
||||
close_fh = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
inline void
|
||||
NfsConnection::CancellableCallback::Callback(int err, void *data)
|
||||
{
|
||||
assert(connection.GetEventLoop().IsInside());
|
||||
|
||||
if (!IsCancelled()) {
|
||||
assert(close_fh == nullptr);
|
||||
|
||||
@@ -143,8 +169,10 @@ NfsConnection::CancellableCallback::Callback(int err, void *data)
|
||||
allocated file handle immediately */
|
||||
assert(close_fh == nullptr);
|
||||
|
||||
struct nfsfh *fh = (struct nfsfh *)data;
|
||||
connection.Close(fh);
|
||||
if (err >= 0) {
|
||||
struct nfsfh *fh = (struct nfsfh *)data;
|
||||
connection.Close(fh);
|
||||
}
|
||||
} else if (close_fh != nullptr)
|
||||
connection.DeferClose(close_fh);
|
||||
|
||||
@@ -209,6 +237,7 @@ NfsConnection::RemoveLease(NfsLease &lease)
|
||||
bool
|
||||
NfsConnection::Stat(const char *path, NfsCallback &callback, Error &error)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(!callbacks.Contains(callback));
|
||||
|
||||
auto &c = callbacks.Add(callback, *this, false);
|
||||
@@ -225,6 +254,7 @@ bool
|
||||
NfsConnection::OpenDirectory(const char *path, NfsCallback &callback,
|
||||
Error &error)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(!callbacks.Contains(callback));
|
||||
|
||||
auto &c = callbacks.Add(callback, *this, true);
|
||||
@@ -240,12 +270,16 @@ NfsConnection::OpenDirectory(const char *path, NfsCallback &callback,
|
||||
const struct nfsdirent *
|
||||
NfsConnection::ReadDirectory(struct nfsdir *dir)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
return nfs_readdir(context, dir);
|
||||
}
|
||||
|
||||
void
|
||||
NfsConnection::CloseDirectory(struct nfsdir *dir)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
return nfs_closedir(context, dir);
|
||||
}
|
||||
|
||||
@@ -253,6 +287,7 @@ bool
|
||||
NfsConnection::Open(const char *path, int flags, NfsCallback &callback,
|
||||
Error &error)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(!callbacks.Contains(callback));
|
||||
|
||||
auto &c = callbacks.Add(callback, *this, true);
|
||||
@@ -268,6 +303,7 @@ NfsConnection::Open(const char *path, int flags, NfsCallback &callback,
|
||||
bool
|
||||
NfsConnection::Stat(struct nfsfh *fh, NfsCallback &callback, Error &error)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(!callbacks.Contains(callback));
|
||||
|
||||
auto &c = callbacks.Add(callback, *this, false);
|
||||
@@ -284,6 +320,7 @@ bool
|
||||
NfsConnection::Read(struct nfsfh *fh, uint64_t offset, size_t size,
|
||||
NfsCallback &callback, Error &error)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(!callbacks.Contains(callback));
|
||||
|
||||
auto &c = callbacks.Add(callback, *this, false);
|
||||
@@ -307,10 +344,22 @@ DummyCallback(int, struct nfs_context *, void *, void *)
|
||||
{
|
||||
}
|
||||
|
||||
inline void
|
||||
NfsConnection::InternalClose(struct nfsfh *fh)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(context != nullptr);
|
||||
assert(fh != nullptr);
|
||||
|
||||
nfs_close_async(context, fh, DummyCallback, nullptr);
|
||||
}
|
||||
|
||||
void
|
||||
NfsConnection::Close(struct nfsfh *fh)
|
||||
{
|
||||
nfs_close_async(context, fh, DummyCallback, nullptr);
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
InternalClose(fh);
|
||||
ScheduleSocket();
|
||||
}
|
||||
|
||||
@@ -327,8 +376,26 @@ NfsConnection::DestroyContext()
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(context != nullptr);
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert(!in_destroy);
|
||||
in_destroy = true;
|
||||
#endif
|
||||
|
||||
if (!mount_finished) {
|
||||
assert(TimeoutMonitor::IsActive());
|
||||
TimeoutMonitor::Cancel();
|
||||
}
|
||||
|
||||
/* cancel pending DeferredMonitor that was scheduled to notify
|
||||
new leases */
|
||||
DeferredMonitor::Cancel();
|
||||
|
||||
if (SocketMonitor::IsDefined())
|
||||
SocketMonitor::Cancel();
|
||||
SocketMonitor::Steal();
|
||||
|
||||
callbacks.ForEach([](CancellableCallback &c){
|
||||
c.PrepareDestroyContext();
|
||||
});
|
||||
|
||||
nfs_destroy_context(context);
|
||||
context = nullptr;
|
||||
@@ -337,8 +404,11 @@ NfsConnection::DestroyContext()
|
||||
inline void
|
||||
NfsConnection::DeferClose(struct nfsfh *fh)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(in_event);
|
||||
assert(in_service);
|
||||
assert(context != nullptr);
|
||||
assert(fh != nullptr);
|
||||
|
||||
deferred_close.push_front(fh);
|
||||
}
|
||||
@@ -346,6 +416,7 @@ NfsConnection::DeferClose(struct nfsfh *fh)
|
||||
void
|
||||
NfsConnection::ScheduleSocket()
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(context != nullptr);
|
||||
|
||||
if (!SocketMonitor::IsDefined()) {
|
||||
@@ -360,9 +431,35 @@ NfsConnection::ScheduleSocket()
|
||||
SocketMonitor::Schedule(libnfs_to_events(nfs_which_events(context)));
|
||||
}
|
||||
|
||||
inline int
|
||||
NfsConnection::Service(unsigned flags)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(context != nullptr);
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert(!in_event);
|
||||
in_event = true;
|
||||
|
||||
assert(!in_service);
|
||||
in_service = true;
|
||||
#endif
|
||||
|
||||
int result = nfs_service(context, events_to_libnfs(flags));
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert(context != nullptr);
|
||||
assert(in_service);
|
||||
in_service = false;
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
NfsConnection::OnSocketReady(unsigned flags)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(deferred_close.empty());
|
||||
|
||||
bool closed = false;
|
||||
@@ -374,21 +471,10 @@ NfsConnection::OnSocketReady(unsigned flags)
|
||||
re-register it each time */
|
||||
SocketMonitor::Steal();
|
||||
|
||||
assert(!in_event);
|
||||
in_event = true;
|
||||
|
||||
assert(!in_service);
|
||||
in_service = true;
|
||||
|
||||
int result = nfs_service(context, events_to_libnfs(flags));
|
||||
|
||||
assert(context != nullptr);
|
||||
assert(in_service);
|
||||
in_service = false;
|
||||
const int result = Service(flags);
|
||||
|
||||
while (!deferred_close.empty()) {
|
||||
nfs_close_async(context, deferred_close.front(),
|
||||
DummyCallback, nullptr);
|
||||
InternalClose(deferred_close.front());
|
||||
deferred_close.pop_front();
|
||||
}
|
||||
|
||||
@@ -405,13 +491,13 @@ NfsConnection::OnSocketReady(unsigned flags)
|
||||
error.Format(nfs_domain, "NFS connection has failed: %s",
|
||||
nfs_get_error(context));
|
||||
|
||||
BroadcastError(std::move(error));
|
||||
|
||||
DestroyContext();
|
||||
closed = true;
|
||||
|
||||
BroadcastError(std::move(error));
|
||||
} else if (SocketMonitor::IsDefined() && nfs_get_fd(context) < 0) {
|
||||
} else if (nfs_get_fd(context) < 0) {
|
||||
/* this happens when rpc_reconnect_requeue() is called
|
||||
after the connection broke, but autoreconnet was
|
||||
after the connection broke, but autoreconnect was
|
||||
disabled - nfs_service() returns 0 */
|
||||
Error error;
|
||||
const char *msg = nfs_get_error(context);
|
||||
@@ -421,14 +507,18 @@ NfsConnection::OnSocketReady(unsigned flags)
|
||||
error.Format(nfs_domain,
|
||||
"NFS socket disappeared: %s", msg);
|
||||
|
||||
BroadcastError(std::move(error));
|
||||
|
||||
DestroyContext();
|
||||
closed = true;
|
||||
|
||||
BroadcastError(std::move(error));
|
||||
}
|
||||
|
||||
assert(context == nullptr || nfs_get_fd(context) >= 0);
|
||||
|
||||
#ifndef NDEBUG
|
||||
assert(in_event);
|
||||
in_event = false;
|
||||
#endif
|
||||
|
||||
if (context != nullptr)
|
||||
ScheduleSocket();
|
||||
@@ -440,10 +530,14 @@ inline void
|
||||
NfsConnection::MountCallback(int status, gcc_unused nfs_context *nfs,
|
||||
gcc_unused void *data)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(context == nfs);
|
||||
|
||||
mount_finished = true;
|
||||
|
||||
assert(TimeoutMonitor::IsActive() || in_destroy);
|
||||
TimeoutMonitor::Cancel();
|
||||
|
||||
if (status < 0) {
|
||||
postponed_mount_error.Format(nfs_domain, status,
|
||||
"nfs_mount_async() failed: %s",
|
||||
@@ -464,6 +558,7 @@ NfsConnection::MountCallback(int status, nfs_context *nfs, void *data,
|
||||
inline bool
|
||||
NfsConnection::MountInternal(Error &error)
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(context == nullptr);
|
||||
|
||||
context = nfs_init_context();
|
||||
@@ -474,8 +569,14 @@ NfsConnection::MountInternal(Error &error)
|
||||
|
||||
postponed_mount_error.Clear();
|
||||
mount_finished = false;
|
||||
|
||||
TimeoutMonitor::ScheduleSeconds(NFS_MOUNT_TIMEOUT);
|
||||
|
||||
#ifndef NDEBUG
|
||||
in_service = false;
|
||||
in_event = false;
|
||||
in_destroy = false;
|
||||
#endif
|
||||
|
||||
if (nfs_mount_async(context, server.c_str(), export_name.c_str(),
|
||||
MountCallback, this) != 0) {
|
||||
@@ -531,9 +632,23 @@ NfsConnection::BroadcastError(Error &&error)
|
||||
BroadcastMountError(std::move(error));
|
||||
}
|
||||
|
||||
void
|
||||
NfsConnection::OnTimeout()
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(!mount_finished);
|
||||
|
||||
mount_finished = true;
|
||||
DestroyContext();
|
||||
|
||||
BroadcastMountError(Error(nfs_domain, "Mount timeout"));
|
||||
}
|
||||
|
||||
void
|
||||
NfsConnection::RunDeferred()
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
if (context == nullptr) {
|
||||
Error error;
|
||||
if (!MountInternal(error)) {
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#include "Lease.hxx"
|
||||
#include "Cancellable.hxx"
|
||||
#include "event/SocketMonitor.hxx"
|
||||
#include "event/TimeoutMonitor.hxx"
|
||||
#include "event/DeferredMonitor.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
@@ -40,7 +41,7 @@ class NfsCallback;
|
||||
/**
|
||||
* An asynchronous connection to a NFS server.
|
||||
*/
|
||||
class NfsConnection : SocketMonitor, DeferredMonitor {
|
||||
class NfsConnection : SocketMonitor, TimeoutMonitor, DeferredMonitor {
|
||||
class CancellableCallback : public CancellablePointer<NfsCallback> {
|
||||
NfsConnection &connection;
|
||||
|
||||
@@ -84,6 +85,13 @@ class NfsConnection : SocketMonitor, DeferredMonitor {
|
||||
*/
|
||||
void CancelAndScheduleClose(struct nfsfh *fh);
|
||||
|
||||
/**
|
||||
* Called by NfsConnection::DestroyContext() right
|
||||
* before nfs_destroy_context(). This object is given
|
||||
* a chance to prepare for the latter.
|
||||
*/
|
||||
void PrepareDestroyContext();
|
||||
|
||||
private:
|
||||
static void Callback(int err, struct nfs_context *nfs,
|
||||
void *data, void *private_data);
|
||||
@@ -111,6 +119,7 @@ class NfsConnection : SocketMonitor, DeferredMonitor {
|
||||
|
||||
Error postponed_mount_error;
|
||||
|
||||
#ifndef NDEBUG
|
||||
/**
|
||||
* True when nfs_service() is being called.
|
||||
*/
|
||||
@@ -122,13 +131,20 @@ class NfsConnection : SocketMonitor, DeferredMonitor {
|
||||
*/
|
||||
bool in_event;
|
||||
|
||||
/**
|
||||
* True when DestroyContext() is being called.
|
||||
*/
|
||||
bool in_destroy;
|
||||
#endif
|
||||
|
||||
bool mount_finished;
|
||||
|
||||
public:
|
||||
gcc_nonnull_all
|
||||
NfsConnection(EventLoop &_loop,
|
||||
const char *_server, const char *_export_name)
|
||||
:SocketMonitor(_loop), DeferredMonitor(_loop),
|
||||
:SocketMonitor(_loop), TimeoutMonitor(_loop),
|
||||
DeferredMonitor(_loop),
|
||||
server(_server), export_name(_export_name),
|
||||
context(nullptr) {}
|
||||
|
||||
@@ -184,6 +200,11 @@ protected:
|
||||
private:
|
||||
void DestroyContext();
|
||||
|
||||
/**
|
||||
* Wrapper for nfs_close_async().
|
||||
*/
|
||||
void InternalClose(struct nfsfh *fh);
|
||||
|
||||
/**
|
||||
* Invoke nfs_close_async() after nfs_service() returns.
|
||||
*/
|
||||
@@ -200,9 +221,17 @@ private:
|
||||
|
||||
void ScheduleSocket();
|
||||
|
||||
/**
|
||||
* Wrapper for nfs_service().
|
||||
*/
|
||||
int Service(unsigned flags);
|
||||
|
||||
/* virtual methods from SocketMonitor */
|
||||
virtual bool OnSocketReady(unsigned flags) override;
|
||||
|
||||
/* virtual methods from TimeoutMonitor */
|
||||
void OnTimeout() final;
|
||||
|
||||
/* virtual methods from DeferredMonitor */
|
||||
virtual void RunDeferred() override;
|
||||
};
|
||||
|
@@ -56,8 +56,18 @@ NfsFileReader::Close()
|
||||
return;
|
||||
}
|
||||
|
||||
/* this cancels State::MOUNT */
|
||||
connection->RemoveLease(*this);
|
||||
|
||||
CancelOrClose();
|
||||
}
|
||||
|
||||
void
|
||||
NfsFileReader::CancelOrClose()
|
||||
{
|
||||
assert(state != State::INITIAL &&
|
||||
state != State::DEFER);
|
||||
|
||||
if (state == State::IDLE)
|
||||
/* no async operation in progress: can close
|
||||
immediately */
|
||||
@@ -164,6 +174,8 @@ NfsFileReader::OnNfsConnectionFailed(const Error &error)
|
||||
{
|
||||
assert(state == State::MOUNT);
|
||||
|
||||
state = State::INITIAL;
|
||||
|
||||
Error copy;
|
||||
copy.Set(error);
|
||||
OnNfsFileError(std::move(copy));
|
||||
@@ -174,7 +186,7 @@ NfsFileReader::OnNfsConnectionDisconnected(const Error &error)
|
||||
{
|
||||
assert(state > State::MOUNT);
|
||||
|
||||
state = State::INITIAL;
|
||||
CancelOrClose();
|
||||
|
||||
Error copy;
|
||||
copy.Set(error);
|
||||
@@ -246,6 +258,30 @@ NfsFileReader::OnNfsCallback(unsigned status, void *data)
|
||||
void
|
||||
NfsFileReader::OnNfsError(Error &&error)
|
||||
{
|
||||
switch (state) {
|
||||
case State::INITIAL:
|
||||
case State::DEFER:
|
||||
case State::MOUNT:
|
||||
case State::IDLE:
|
||||
assert(false);
|
||||
gcc_unreachable();
|
||||
|
||||
case State::OPEN:
|
||||
connection->RemoveLease(*this);
|
||||
state = State::INITIAL;
|
||||
break;
|
||||
|
||||
case State::STAT:
|
||||
connection->RemoveLease(*this);
|
||||
connection->Close(fh);
|
||||
state = State::INITIAL;
|
||||
break;
|
||||
|
||||
case State::READ:
|
||||
state = State::IDLE;
|
||||
break;
|
||||
}
|
||||
|
||||
OnNfsFileError(std::move(error));
|
||||
}
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include "Lease.hxx"
|
||||
#include "Callback.hxx"
|
||||
#include "event/DeferredMonitor.hxx"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <string>
|
||||
|
||||
@@ -75,6 +76,12 @@ protected:
|
||||
virtual void OnNfsFileError(Error &&error) = 0;
|
||||
|
||||
private:
|
||||
/**
|
||||
* Cancel the current operation, if any. The NfsLease must be
|
||||
* unregistered already.
|
||||
*/
|
||||
void CancelOrClose();
|
||||
|
||||
void OpenCallback(nfsfh *_fh);
|
||||
void StatCallback(const struct stat *st);
|
||||
|
||||
|
@@ -29,8 +29,10 @@ NfsManager::ManagedConnection::OnNfsConnectionError(Error &&error)
|
||||
{
|
||||
FormatError(error, "NFS error on %s:%s", GetServer(), GetExportName());
|
||||
|
||||
manager.connections.erase(manager.connections.iterator_to(*this));
|
||||
delete this;
|
||||
/* defer deletion so the caller
|
||||
(i.e. NfsConnection::OnSocketReady()) can still use this
|
||||
object */
|
||||
manager.ScheduleDelete(*this);
|
||||
}
|
||||
|
||||
inline bool
|
||||
@@ -59,7 +61,9 @@ NfsManager::Compare::operator()(const ManagedConnection &a,
|
||||
|
||||
NfsManager::~NfsManager()
|
||||
{
|
||||
assert(loop.IsInside());
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
CollectGarbage();
|
||||
|
||||
connections.clear_and_dispose([](ManagedConnection *c){
|
||||
delete c;
|
||||
@@ -71,13 +75,13 @@ NfsManager::GetConnection(const char *server, const char *export_name)
|
||||
{
|
||||
assert(server != nullptr);
|
||||
assert(export_name != nullptr);
|
||||
assert(loop.IsInside());
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
Map::insert_commit_data hint;
|
||||
auto result = connections.insert_check(LookupKey{server, export_name},
|
||||
Compare(), hint);
|
||||
if (result.second) {
|
||||
auto c = new ManagedConnection(*this, loop,
|
||||
auto c = new ManagedConnection(*this, GetEventLoop(),
|
||||
server, export_name);
|
||||
connections.insert_commit(*c, hint);
|
||||
return *c;
|
||||
@@ -85,3 +89,19 @@ NfsManager::GetConnection(const char *server, const char *export_name)
|
||||
return *result.first;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
NfsManager::CollectGarbage()
|
||||
{
|
||||
assert(GetEventLoop().IsInside());
|
||||
|
||||
garbage.clear_and_dispose([](ManagedConnection *c){
|
||||
delete c;
|
||||
});
|
||||
}
|
||||
|
||||
void
|
||||
NfsManager::OnIdle()
|
||||
{
|
||||
CollectGarbage();
|
||||
}
|
||||
|
@@ -23,14 +23,16 @@
|
||||
#include "check.h"
|
||||
#include "Connection.hxx"
|
||||
#include "Compiler.h"
|
||||
#include "event/IdleMonitor.hxx"
|
||||
|
||||
#include <boost/intrusive/set.hpp>
|
||||
#include <boost/intrusive/slist.hpp>
|
||||
|
||||
/**
|
||||
* A manager for NFS connections. Handles multiple connections to
|
||||
* multiple NFS servers.
|
||||
*/
|
||||
class NfsManager {
|
||||
class NfsManager final : IdleMonitor {
|
||||
struct LookupKey {
|
||||
const char *server;
|
||||
const char *export_name;
|
||||
@@ -38,6 +40,7 @@ class NfsManager {
|
||||
|
||||
class ManagedConnection final
|
||||
: public NfsConnection,
|
||||
public boost::intrusive::slist_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>>,
|
||||
public boost::intrusive::set_base_hook<boost::intrusive::link_mode<boost::intrusive::normal_link>> {
|
||||
NfsManager &manager;
|
||||
|
||||
@@ -63,8 +66,6 @@ class NfsManager {
|
||||
const LookupKey b) const;
|
||||
};
|
||||
|
||||
EventLoop &loop;
|
||||
|
||||
/**
|
||||
* Maps server and export_name to #ManagedConnection.
|
||||
*/
|
||||
@@ -74,9 +75,18 @@ class NfsManager {
|
||||
|
||||
Map connections;
|
||||
|
||||
typedef boost::intrusive::slist<ManagedConnection> List;
|
||||
|
||||
/**
|
||||
* A list of "garbage" connection objects. Their destruction
|
||||
* is postponed because they were thrown into the garbage list
|
||||
* when callers on the stack were still using them.
|
||||
*/
|
||||
List garbage;
|
||||
|
||||
public:
|
||||
NfsManager(EventLoop &_loop)
|
||||
:loop(_loop) {}
|
||||
:IdleMonitor(_loop) {}
|
||||
|
||||
/**
|
||||
* Must be run from EventLoop's thread.
|
||||
@@ -86,6 +96,21 @@ public:
|
||||
gcc_pure
|
||||
NfsConnection &GetConnection(const char *server,
|
||||
const char *export_name);
|
||||
|
||||
private:
|
||||
void ScheduleDelete(ManagedConnection &c) {
|
||||
connections.erase(connections.iterator_to(c));
|
||||
garbage.push_front(c);
|
||||
IdleMonitor::Schedule();
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete all connections on the #garbage list.
|
||||
*/
|
||||
void CollectGarbage();
|
||||
|
||||
/* virtual methods from IdleMonitor */
|
||||
void OnIdle() override;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -29,7 +29,7 @@
|
||||
|
||||
ContentDirectoryService::ContentDirectoryService(const UPnPDevice &device,
|
||||
const UPnPService &service)
|
||||
:m_actionURL(uri_apply_base(device.URLBase, service.controlURL)),
|
||||
:m_actionURL(uri_apply_base(service.controlURL, device.URLBase)),
|
||||
m_serviceType(service.serviceType),
|
||||
m_deviceId(device.UDN),
|
||||
m_friendlyName(device.friendlyName),
|
||||
|
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <upnp/upnptools.h>
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
// The service type string we are looking for.
|
||||
|
@@ -58,9 +58,6 @@ static const char *remoteUrlPrefixes[] = {
|
||||
#ifdef ENABLE_CDIO_PARANOIA
|
||||
"cdda://",
|
||||
#endif
|
||||
#ifdef ENABLE_DESPOTIFY
|
||||
"spt://",
|
||||
#endif
|
||||
#ifdef HAVE_ALSA
|
||||
"alsa://",
|
||||
#endif
|
||||
|
@@ -25,13 +25,10 @@
|
||||
#include "output/Internal.hxx"
|
||||
#include "pcm/Volume.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "util/Domain.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
static constexpr Domain mixer_domain("mixer");
|
||||
|
||||
static int
|
||||
output_mixer_get_volume(const AudioOutput &ao)
|
||||
{
|
||||
|
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Main.hxx"
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <dispatch/dispatch.h>
|
||||
|
||||
int osx_main(int argc, char *argv[])
|
||||
{
|
||||
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
||||
exit(mpd_main(argc, argv));
|
||||
});
|
||||
dispatch_main();
|
||||
return EXIT_FAILURE; // unreachable, because dispatch_main never returns
|
||||
}
|
||||
|
||||
#endif
|
@@ -48,6 +48,7 @@
|
||||
|
||||
AudioOutput::AudioOutput(const AudioOutputPlugin &_plugin)
|
||||
:plugin(_plugin),
|
||||
mixer(nullptr),
|
||||
enabled(true), really_enabled(false),
|
||||
open(false),
|
||||
pause(false),
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user