Compare commits
102 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
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 |
INSTALLMakefile.amNEWS
android
configure.acdoc
m4
src
Main.cxxMain.hxxPlaylistFile.cxxTagStream.cxx
archive
plugins
client
command
db
decoder
event
fs
input
AsyncInputStream.cxxAsyncInputStream.hxxDomain.cxxDomain.hxxInputStream.hxxOpen.cxxTextInputStream.cxx
plugins
java
lib
nfs
upnp
output
pcm
playlist
tag
util
test
3
INSTALL
3
INSTALL
@@ -119,9 +119,6 @@ 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
|
||||
-----------------------------------
|
||||
|
25
Makefile.am
25
Makefile.am
@@ -130,7 +130,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 \
|
||||
@@ -829,7 +828,6 @@ libdecoder_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||
$(WAVPACK_CFLAGS) \
|
||||
$(MAD_CFLAGS) \
|
||||
$(MPG123_CFLAGS) \
|
||||
$(MP4V2_CFLAGS) \
|
||||
$(OPUS_CFLAGS) \
|
||||
$(FFMPEG_CFLAGS) \
|
||||
$(MPCDEC_CFLAGS) \
|
||||
@@ -849,7 +847,6 @@ DECODER_LIBS = \
|
||||
$(WAVPACK_LIBS) \
|
||||
$(MAD_LIBS) \
|
||||
$(MPG123_LIBS) \
|
||||
$(MP4V2_LIBS) \
|
||||
$(OPUS_LIBS) \
|
||||
$(FFMPEG_LIBS2) \
|
||||
$(MPCDEC_LIBS) \
|
||||
@@ -964,12 +961,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 +1104,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 \
|
||||
@@ -2141,19 +2133,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) $<
|
||||
@@ -2195,4 +2179,11 @@ EXTRA_DIST = $(doc_DATA) autogen.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
|
||||
|
72
NEWS
72
NEWS
@@ -1,3 +1,56 @@
|
||||
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
|
||||
@@ -85,6 +138,25 @@ ver 0.19 (2014/10/10)
|
||||
* install systemd unit for socket activation
|
||||
* Android port
|
||||
|
||||
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="7"
|
||||
android:versionName="0.19.1">
|
||||
android:versionCode="9"
|
||||
android:versionName="0.19.5">
|
||||
|
||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17"/>
|
||||
|
||||
|
@@ -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'
|
||||
|
68
configure.ac
68
configure.ac
@@ -1,10 +1,10 @@
|
||||
AC_PREREQ(2.60)
|
||||
|
||||
AC_INIT(mpd, 0.19.1, musicpd-dev-team@lists.sourceforge.net)
|
||||
AC_INIT(mpd, 0.19.5, musicpd-dev-team@lists.sourceforge.net)
|
||||
|
||||
VERSION_MAJOR=0
|
||||
VERSION_MINOR=19
|
||||
VERSION_REVISION=0
|
||||
VERSION_REVISION=5
|
||||
VERSION_EXTRA=0
|
||||
|
||||
AC_CONFIG_SRCDIR([src/Main.cxx])
|
||||
@@ -293,7 +293,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 +305,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 +327,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 +349,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 +406,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,6 +440,8 @@ 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
|
||||
|
||||
@@ -440,6 +454,8 @@ 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 +496,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 +545,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 +572,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 +614,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 +626,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],
|
||||
@@ -1240,24 +1259,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 +1710,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 +1722,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 +1828,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 +1845,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])
|
||||
|
@@ -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>
|
||||
|
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
|
||||
])
|
29
src/Main.cxx
29
src/Main.cxx
@@ -114,6 +114,10 @@
|
||||
#include <ws2tcpip.h>
|
||||
#endif
|
||||
|
||||
#ifdef __BLOCKS__
|
||||
#include <dispatch/dispatch.h>
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096;
|
||||
@@ -401,8 +405,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 +412,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
#endif
|
||||
|
||||
static int mpd_main_after_fork(struct options);
|
||||
|
||||
#ifdef ANDROID
|
||||
static inline
|
||||
#endif
|
||||
@@ -513,6 +517,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
|
||||
|
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
|
||||
|
@@ -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.
|
||||
|
@@ -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;
|
||||
|
@@ -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>
|
||||
|
@@ -129,6 +129,7 @@ public:
|
||||
state(NONE),
|
||||
tag_type(TAG_NUM_OF_ITEM_TYPES)
|
||||
{
|
||||
m_tobj.clear();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
@@ -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
|
||||
|
@@ -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,
|
||||
|
@@ -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);
|
||||
|
@@ -53,7 +53,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 +72,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
|
||||
|
@@ -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;
|
||||
|
@@ -657,7 +657,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 +680,7 @@ static const char *const ffmpeg_mime_types[] = {
|
||||
"audio/8svx",
|
||||
"audio/16sv",
|
||||
"audio/aac",
|
||||
"audio/aacp",
|
||||
"audio/ac3",
|
||||
"audio/aiff"
|
||||
"audio/amr",
|
||||
@@ -690,6 +691,7 @@ static const char *const ffmpeg_mime_types[] = {
|
||||
"audio/mpeg",
|
||||
"audio/musepack",
|
||||
"audio/ogg",
|
||||
"audio/opus",
|
||||
"audio/qcelp",
|
||||
"audio/vorbis",
|
||||
"audio/vorbis+ogg",
|
||||
|
@@ -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
|
||||
};
|
@@ -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
|
||||
};
|
||||
|
@@ -21,9 +21,6 @@
|
||||
#define MPD_SOCKET_DEFERRED_MONITOR_HXX
|
||||
|
||||
#include "check.h"
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
class EventLoop;
|
||||
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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 */
|
||||
|
||||
|
@@ -83,6 +83,10 @@ protected:
|
||||
*/
|
||||
void SetTag(Tag *_tag);
|
||||
|
||||
void ClearTag() {
|
||||
SetTag(nullptr);
|
||||
}
|
||||
|
||||
void Pause();
|
||||
|
||||
bool IsPaused() const {
|
||||
|
@@ -18,20 +18,7 @@
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
#include "Main.hxx"
|
||||
#include "Domain.hxx"
|
||||
#include "util/Domain.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
|
||||
const Domain input_domain("input");
|
@@ -17,9 +17,11 @@
|
||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*/
|
||||
|
||||
#ifndef MPD_DECODER_MP4V2_HXX
|
||||
#define MPD_DECODER_MP4V2_HXX
|
||||
#ifndef MPD_INPUT_DOMAIN_HXX
|
||||
#define MPD_INPUT_DOMAIN_HXX
|
||||
|
||||
extern const struct DecoderPlugin mp4v2_decoder_plugin;
|
||||
class Domain;
|
||||
|
||||
extern const Domain input_domain;
|
||||
|
||||
#endif
|
@@ -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,
|
||||
|
@@ -38,8 +38,8 @@ TextInputStream::ReadLine()
|
||||
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;
|
||||
@@ -66,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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);
|
||||
@@ -597,6 +604,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 +670,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 +750,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);
|
||||
|
@@ -28,7 +28,7 @@
|
||||
*/
|
||||
|
||||
#ifndef JAVA_FILE_HXX
|
||||
#define JAVA_FILE_HPP
|
||||
#define JAVA_FILE_HXX
|
||||
|
||||
#include "Object.hxx"
|
||||
|
||||
|
@@ -327,6 +327,10 @@ NfsConnection::DestroyContext()
|
||||
assert(GetEventLoop().IsInside());
|
||||
assert(context != nullptr);
|
||||
|
||||
/* cancel pending DeferredMonitor that was scheduled to notify
|
||||
new leases */
|
||||
DeferredMonitor::Cancel();
|
||||
|
||||
if (SocketMonitor::IsDefined())
|
||||
SocketMonitor::Cancel();
|
||||
|
||||
@@ -405,10 +409,10 @@ 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) {
|
||||
/* this happens when rpc_reconnect_requeue() is called
|
||||
after the connection broke, but autoreconnet was
|
||||
@@ -421,10 +425,10 @@ 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(in_event);
|
||||
|
@@ -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.
|
||||
|
@@ -383,7 +383,12 @@ private:
|
||||
void Reopen();
|
||||
|
||||
AudioFormat OpenFilter(AudioFormat &format, Error &error_r);
|
||||
|
||||
/**
|
||||
* Mutex must not be locked.
|
||||
*/
|
||||
void CloseFilter();
|
||||
|
||||
void ReopenFilter();
|
||||
|
||||
/**
|
||||
|
@@ -22,6 +22,7 @@
|
||||
#include "OutputAPI.hxx"
|
||||
#include "Domain.hxx"
|
||||
#include "pcm/PcmMix.hxx"
|
||||
#include "pcm/Domain.hxx"
|
||||
#include "notify.hxx"
|
||||
#include "filter/FilterInternal.hxx"
|
||||
#include "filter/plugins/ConvertFilterPlugin.hxx"
|
||||
@@ -165,6 +166,10 @@ AudioOutput::Open()
|
||||
out_audio_format.ApplyMask(config_audio_format);
|
||||
|
||||
mutex.unlock();
|
||||
|
||||
const AudioFormat retry_audio_format = out_audio_format;
|
||||
|
||||
retry_without_dsd:
|
||||
success = ao_plugin_open(this, out_audio_format, error);
|
||||
mutex.lock();
|
||||
|
||||
@@ -174,7 +179,10 @@ AudioOutput::Open()
|
||||
FormatError(error, "Failed to open \"%s\" [%s]",
|
||||
name, plugin.name);
|
||||
|
||||
mutex.unlock();
|
||||
CloseFilter();
|
||||
mutex.lock();
|
||||
|
||||
fail_timer.Update();
|
||||
return;
|
||||
}
|
||||
@@ -184,7 +192,36 @@ AudioOutput::Open()
|
||||
FormatError(error, "Failed to convert for \"%s\" [%s]",
|
||||
name, plugin.name);
|
||||
|
||||
mutex.unlock();
|
||||
ao_plugin_close(this);
|
||||
|
||||
if (error.IsDomain(pcm_domain) &&
|
||||
out_audio_format.format == SampleFormat::DSD) {
|
||||
/* if the audio output supports DSD, but not
|
||||
the given sample rate, it asks MPD to
|
||||
resample; resampling DSD however is not
|
||||
implemented; our last resort is to give up
|
||||
DSD and fall back to PCM */
|
||||
|
||||
// TODO: clean up this workaround
|
||||
|
||||
FormatError(output_domain, "Retrying without DSD");
|
||||
|
||||
out_audio_format = retry_audio_format;
|
||||
out_audio_format.format = SampleFormat::FLOAT;
|
||||
|
||||
/* clear the Error to allow reusing it */
|
||||
error.Clear();
|
||||
|
||||
/* sorry for the "goto" - this is a workaround
|
||||
for the stable branch that should be as
|
||||
unintrusive as possible */
|
||||
goto retry_without_dsd;
|
||||
}
|
||||
|
||||
CloseFilter();
|
||||
mutex.lock();
|
||||
|
||||
fail_timer.Update();
|
||||
return;
|
||||
}
|
||||
@@ -233,7 +270,10 @@ AudioOutput::ReopenFilter()
|
||||
{
|
||||
Error error;
|
||||
|
||||
mutex.unlock();
|
||||
CloseFilter();
|
||||
mutex.lock();
|
||||
|
||||
const AudioFormat filter_audio_format =
|
||||
OpenFilter(in_audio_format, error);
|
||||
if (!filter_audio_format.IsDefined() ||
|
||||
|
@@ -46,7 +46,7 @@ class RoarOutput {
|
||||
struct roar_connection con;
|
||||
struct roar_audio_info info;
|
||||
mutable Mutex mutex;
|
||||
volatile bool alive;
|
||||
bool alive;
|
||||
|
||||
public:
|
||||
RoarOutput()
|
||||
|
@@ -43,7 +43,7 @@ PcmChannelsConverter::Open(SampleFormat _format,
|
||||
default:
|
||||
error.Format(pcm_domain,
|
||||
"PCM channel conversion for %s is not implemented",
|
||||
sample_format_to_string(format));
|
||||
sample_format_to_string(_format));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@@ -28,11 +28,31 @@
|
||||
|
||||
bool
|
||||
PcmFormatConverter::Open(SampleFormat _src_format, SampleFormat _dest_format,
|
||||
gcc_unused Error &error)
|
||||
Error &error)
|
||||
{
|
||||
assert(_src_format != SampleFormat::UNDEFINED);
|
||||
assert(_dest_format != SampleFormat::UNDEFINED);
|
||||
|
||||
switch (_dest_format) {
|
||||
case SampleFormat::UNDEFINED:
|
||||
assert(false);
|
||||
gcc_unreachable();
|
||||
|
||||
case SampleFormat::S8:
|
||||
case SampleFormat::DSD:
|
||||
error.Format(pcm_domain,
|
||||
"PCM conversion from %s to %s is not implemented",
|
||||
sample_format_to_string(_src_format),
|
||||
sample_format_to_string(_dest_format));
|
||||
return nullptr;
|
||||
|
||||
case SampleFormat::S16:
|
||||
case SampleFormat::S24_P32:
|
||||
case SampleFormat::S32:
|
||||
case SampleFormat::FLOAT:
|
||||
break;
|
||||
}
|
||||
|
||||
src_format = _src_format;
|
||||
dest_format = _dest_format;
|
||||
return true;
|
||||
@@ -48,20 +68,14 @@ PcmFormatConverter::Close()
|
||||
}
|
||||
|
||||
ConstBuffer<void>
|
||||
PcmFormatConverter::Convert(ConstBuffer<void> src, Error &error)
|
||||
PcmFormatConverter::Convert(ConstBuffer<void> src, gcc_unused Error &error)
|
||||
{
|
||||
switch (dest_format) {
|
||||
case SampleFormat::UNDEFINED:
|
||||
assert(false);
|
||||
gcc_unreachable();
|
||||
|
||||
case SampleFormat::S8:
|
||||
case SampleFormat::DSD:
|
||||
error.Format(pcm_domain,
|
||||
"PCM conversion from %s to %s is not implemented",
|
||||
sample_format_to_string(src_format),
|
||||
sample_format_to_string(dest_format));
|
||||
return nullptr;
|
||||
assert(false);
|
||||
gcc_unreachable();
|
||||
|
||||
case SampleFormat::S16:
|
||||
return pcm_convert_to_16(buffer, dither,
|
||||
|
@@ -51,7 +51,7 @@ PcmConvert::~PcmConvert()
|
||||
}
|
||||
|
||||
bool
|
||||
PcmConvert::Open(AudioFormat _src_format, AudioFormat _dest_format,
|
||||
PcmConvert::Open(const AudioFormat _src_format, const AudioFormat _dest_format,
|
||||
Error &error)
|
||||
{
|
||||
assert(!src_format.IsValid());
|
||||
@@ -59,36 +59,34 @@ PcmConvert::Open(AudioFormat _src_format, AudioFormat _dest_format,
|
||||
assert(_src_format.IsValid());
|
||||
assert(_dest_format.IsValid());
|
||||
|
||||
src_format = _src_format;
|
||||
dest_format = _dest_format;
|
||||
|
||||
AudioFormat format = src_format;
|
||||
AudioFormat format = _src_format;
|
||||
if (format.format == SampleFormat::DSD)
|
||||
format.format = SampleFormat::FLOAT;
|
||||
|
||||
enable_resampler = format.sample_rate != dest_format.sample_rate;
|
||||
enable_resampler = format.sample_rate != _dest_format.sample_rate;
|
||||
if (enable_resampler) {
|
||||
if (!resampler.Open(format, dest_format.sample_rate, error))
|
||||
if (!resampler.Open(format, _dest_format.sample_rate, error))
|
||||
return false;
|
||||
|
||||
format.format = resampler.GetOutputSampleFormat();
|
||||
format.sample_rate = dest_format.sample_rate;
|
||||
format.sample_rate = _dest_format.sample_rate;
|
||||
}
|
||||
|
||||
enable_format = format.format != dest_format.format;
|
||||
enable_format = format.format != _dest_format.format;
|
||||
if (enable_format &&
|
||||
!format_converter.Open(format.format, dest_format.format, error)) {
|
||||
!format_converter.Open(format.format, _dest_format.format,
|
||||
error)) {
|
||||
if (enable_resampler)
|
||||
resampler.Close();
|
||||
return false;
|
||||
}
|
||||
|
||||
format.format = dest_format.format;
|
||||
format.format = _dest_format.format;
|
||||
|
||||
enable_channels = format.channels != dest_format.channels;
|
||||
enable_channels = format.channels != _dest_format.channels;
|
||||
if (enable_channels &&
|
||||
!channels_converter.Open(format.format, format.channels,
|
||||
dest_format.channels, error)) {
|
||||
_dest_format.channels, error)) {
|
||||
if (enable_format)
|
||||
format_converter.Close();
|
||||
if (enable_resampler)
|
||||
@@ -96,6 +94,9 @@ PcmConvert::Open(AudioFormat _src_format, AudioFormat _dest_format,
|
||||
return false;
|
||||
}
|
||||
|
||||
src_format = _src_format;
|
||||
dest_format = _dest_format;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@@ -147,7 +147,8 @@ SoxrPcmResampler::Resample(ConstBuffer<void> src, Error &error)
|
||||
|
||||
const size_t n_frames = src.size / frame_size;
|
||||
|
||||
const size_t o_frames = size_t(n_frames * ratio + 0.5);
|
||||
/* always round up: worst case output buffer size */
|
||||
const size_t o_frames = size_t(n_frames * ratio) + 1;
|
||||
|
||||
float *output_buffer = (float *)buffer.Get(o_frames * frame_size);
|
||||
|
||||
|
@@ -139,12 +139,12 @@ static SongEnumerator *
|
||||
playlist_list_open_uri_suffix(const char *uri, Mutex &mutex, Cond &cond,
|
||||
const bool *tried)
|
||||
{
|
||||
const char *suffix;
|
||||
SongEnumerator *playlist = nullptr;
|
||||
|
||||
assert(uri != nullptr);
|
||||
|
||||
suffix = uri_get_suffix(uri);
|
||||
UriSuffixBuffer suffix_buffer;
|
||||
const char *const suffix = uri_get_suffix(uri, suffix_buffer);
|
||||
if (suffix == nullptr)
|
||||
return nullptr;
|
||||
|
||||
@@ -257,7 +257,10 @@ playlist_list_open_stream(InputStream &is, const char *uri)
|
||||
return playlist;
|
||||
}
|
||||
|
||||
const char *suffix = uri != nullptr ? uri_get_suffix(uri) : nullptr;
|
||||
UriSuffixBuffer suffix_buffer;
|
||||
const char *suffix = uri != nullptr
|
||||
? uri_get_suffix(uri, suffix_buffer)
|
||||
: nullptr;
|
||||
if (suffix != nullptr) {
|
||||
auto playlist = playlist_list_open_stream_suffix(is, suffix);
|
||||
if (playlist != nullptr)
|
||||
|
@@ -130,6 +130,7 @@ ExtM3uPlaylist::NextSong()
|
||||
|
||||
static const char *const extm3u_suffixes[] = {
|
||||
"m3u",
|
||||
"m3u8",
|
||||
nullptr
|
||||
};
|
||||
|
||||
|
@@ -60,6 +60,7 @@ M3uPlaylist::NextSong()
|
||||
|
||||
static const char *const m3u_suffixes[] = {
|
||||
"m3u",
|
||||
"m3u8",
|
||||
nullptr
|
||||
};
|
||||
|
||||
|
@@ -19,6 +19,7 @@
|
||||
|
||||
#include "Set.hxx"
|
||||
#include "TagBuilder.hxx"
|
||||
#include "TagSettings.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
@@ -109,6 +110,7 @@ TagSet::InsertUnique(const Tag &tag,
|
||||
|
||||
if (!CheckUnique(type, tag, type, group_mask) &&
|
||||
(type != TAG_ALBUM_ARTIST ||
|
||||
ignore_tag_items[TAG_ALBUM_ARTIST] ||
|
||||
/* fall back to "Artist" if no "AlbumArtist" was found */
|
||||
!CheckUnique(type, tag, TAG_ARTIST, group_mask)))
|
||||
InsertUnique(tag, type, nullptr, group_mask);
|
||||
|
@@ -54,6 +54,23 @@ uri_get_suffix(const char *uri)
|
||||
return suffix;
|
||||
}
|
||||
|
||||
const char *
|
||||
uri_get_suffix(const char *uri, UriSuffixBuffer &buffer)
|
||||
{
|
||||
const char *suffix = uri_get_suffix(uri);
|
||||
if (suffix == nullptr)
|
||||
return nullptr;
|
||||
|
||||
const char *q = strchr(suffix, '?');
|
||||
if (q != nullptr && size_t(q - suffix) < sizeof(buffer.data)) {
|
||||
memcpy(buffer.data, suffix, q - suffix);
|
||||
buffer.data[q - suffix] = 0;
|
||||
suffix = buffer.data;
|
||||
}
|
||||
|
||||
return suffix;
|
||||
}
|
||||
|
||||
static const char *
|
||||
verify_uri_segment(const char *p)
|
||||
{
|
||||
|
@@ -42,6 +42,17 @@ gcc_pure
|
||||
const char *
|
||||
uri_get_suffix(const char *uri);
|
||||
|
||||
struct UriSuffixBuffer {
|
||||
char data[8];
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the file name suffix, ignoring the query string.
|
||||
*/
|
||||
gcc_pure
|
||||
const char *
|
||||
uri_get_suffix(const char *uri, UriSuffixBuffer &buffer);
|
||||
|
||||
/**
|
||||
* Returns true if this is a safe "local" URI:
|
||||
*
|
||||
|
@@ -33,7 +33,9 @@
|
||||
#include "event/Loop.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#include <glib.h>
|
||||
#endif
|
||||
|
||||
#include <iostream>
|
||||
using std::cout;
|
||||
@@ -107,8 +109,10 @@ main(int argc, char **argv)
|
||||
|
||||
/* initialize GLib */
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#if !GLIB_CHECK_VERSION(2,32,0)
|
||||
g_thread_init(nullptr);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* initialize MPD */
|
||||
|
@@ -132,6 +132,12 @@ decoder_data(gcc_unused Decoder &decoder,
|
||||
const void *data, size_t datalen,
|
||||
gcc_unused uint16_t kbit_rate)
|
||||
{
|
||||
static uint16_t prev_kbit_rate;
|
||||
if (kbit_rate != prev_kbit_rate) {
|
||||
prev_kbit_rate = kbit_rate;
|
||||
fprintf(stderr, "%u kbit/s\n", kbit_rate);
|
||||
}
|
||||
|
||||
gcc_unused ssize_t nbytes = write(1, data, datalen);
|
||||
return DecoderCommand::NONE;
|
||||
}
|
||||
|
@@ -28,7 +28,9 @@
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#include <glib.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
@@ -50,8 +52,10 @@ int main(int argc, gcc_unused char **argv)
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#if !GLIB_CHECK_VERSION(2,32,0)
|
||||
g_thread_init(NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
EventLoop event_loop;
|
||||
|
@@ -54,11 +54,6 @@ tag_save(FILE *file, const Tag &tag)
|
||||
static int
|
||||
dump_input_stream(InputStream *is)
|
||||
{
|
||||
Error error;
|
||||
char buffer[4096];
|
||||
size_t num_read;
|
||||
ssize_t num_written;
|
||||
|
||||
is->Lock();
|
||||
|
||||
/* print meta data */
|
||||
@@ -76,7 +71,9 @@ dump_input_stream(InputStream *is)
|
||||
delete tag;
|
||||
}
|
||||
|
||||
num_read = is->Read(buffer, sizeof(buffer), error);
|
||||
Error error;
|
||||
char buffer[4096];
|
||||
size_t num_read = is->Read(buffer, sizeof(buffer), error);
|
||||
if (num_read == 0) {
|
||||
if (error.IsDefined())
|
||||
LogError(error);
|
||||
@@ -84,11 +81,12 @@ dump_input_stream(InputStream *is)
|
||||
break;
|
||||
}
|
||||
|
||||
num_written = write(1, buffer, num_read);
|
||||
ssize_t num_written = write(1, buffer, num_read);
|
||||
if (num_written <= 0)
|
||||
break;
|
||||
}
|
||||
|
||||
Error error;
|
||||
if (!is->Check(error)) {
|
||||
LogError(error);
|
||||
is->Unlock();
|
||||
@@ -102,10 +100,6 @@ dump_input_stream(InputStream *is)
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Error error;
|
||||
InputStream *is;
|
||||
int ret;
|
||||
|
||||
if (argc != 2) {
|
||||
fprintf(stderr, "Usage: run_input URI\n");
|
||||
return EXIT_FAILURE;
|
||||
@@ -129,6 +123,7 @@ int main(int argc, char **argv)
|
||||
archive_plugin_init_all();
|
||||
#endif
|
||||
|
||||
Error error;
|
||||
if (!input_stream_global_init(error)) {
|
||||
LogError(error);
|
||||
return 2;
|
||||
@@ -139,7 +134,8 @@ int main(int argc, char **argv)
|
||||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
is = InputStream::OpenReady(argv[1], mutex, cond, error);
|
||||
InputStream *is = InputStream::OpenReady(argv[1], mutex, cond, error);
|
||||
int ret;
|
||||
if (is != NULL) {
|
||||
ret = dump_input_stream(is);
|
||||
delete is;
|
||||
|
@@ -7,8 +7,6 @@
|
||||
#include <cppunit/ui/text/TestRunner.h>
|
||||
#include <cppunit/extensions/HelperMacros.h>
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -29,22 +27,22 @@ ArchiveLookupTest::TestArchiveLookup()
|
||||
char *path = strdup("");
|
||||
CPPUNIT_ASSERT_EQUAL(false,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
g_free(path);
|
||||
free(path);
|
||||
|
||||
path = strdup(".");
|
||||
CPPUNIT_ASSERT_EQUAL(false,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
g_free(path);
|
||||
free(path);
|
||||
|
||||
path = strdup("config.h");
|
||||
CPPUNIT_ASSERT_EQUAL(false,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
g_free(path);
|
||||
free(path);
|
||||
|
||||
path = strdup("src/foo/bar");
|
||||
CPPUNIT_ASSERT_EQUAL(false,
|
||||
archive_lookup(path, &archive, &inpath, &suffix));
|
||||
g_free(path);
|
||||
free(path);
|
||||
|
||||
path = strdup("Makefile/foo/bar");
|
||||
CPPUNIT_ASSERT_EQUAL(true,
|
||||
@@ -53,7 +51,7 @@ ArchiveLookupTest::TestArchiveLookup()
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(archive, "Makefile"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(inpath, "foo/bar"));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr, suffix);
|
||||
g_free(path);
|
||||
free(path);
|
||||
|
||||
path = strdup("config.h/foo/bar");
|
||||
CPPUNIT_ASSERT_EQUAL(true,
|
||||
@@ -62,7 +60,7 @@ ArchiveLookupTest::TestArchiveLookup()
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(archive, "config.h"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(inpath, "foo/bar"));
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(suffix, "h"));
|
||||
g_free(path);
|
||||
free(path);
|
||||
}
|
||||
|
||||
CPPUNIT_TEST_SUITE_REGISTRATION(ArchiveLookupTest);
|
||||
|
@@ -34,6 +34,25 @@ public:
|
||||
uri_get_suffix(".jpg"));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
|
||||
uri_get_suffix("/foo/.jpg"));
|
||||
|
||||
/* the first overload does not eliminate the query
|
||||
string */
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo/bar.jpg?query_string"),
|
||||
"jpg?query_string"));
|
||||
|
||||
/* ... but the second one does */
|
||||
UriSuffixBuffer buffer;
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo/bar.jpg?query_string",
|
||||
buffer),
|
||||
"jpg"));
|
||||
|
||||
/* repeat some of the above tests with the second overload */
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
|
||||
uri_get_suffix("/foo/bar", buffer));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
|
||||
uri_get_suffix("/foo.jpg/bar", buffer));
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo/bar.jpg", buffer),
|
||||
"jpg"));
|
||||
}
|
||||
|
||||
void TestRemoveAuth() {
|
||||
|
@@ -30,7 +30,9 @@
|
||||
#include "fs/Path.hxx"
|
||||
#include "util/Error.hxx"
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#include <glib.h>
|
||||
#endif
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
@@ -57,8 +59,10 @@ main(int argc, char **argv)
|
||||
|
||||
/* initialize GLib */
|
||||
|
||||
#ifdef HAVE_GLIB
|
||||
#if !GLIB_CHECK_VERSION(2,32,0)
|
||||
g_thread_init(NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* initialize MPD */
|
||||
|
Reference in New Issue
Block a user