Compare commits
85 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
ff35aa07dc | ||
![]() |
a3afd5178c | ||
![]() |
f1285a6dfd | ||
![]() |
cf7c1afb93 | ||
![]() |
e140a28073 | ||
![]() |
de61c3b962 | ||
![]() |
c46fc4531b | ||
![]() |
065a9ed10f | ||
![]() |
e44c0254f7 | ||
![]() |
13f9f0315f | ||
![]() |
1532ffe215 | ||
![]() |
b24cbc68ba | ||
![]() |
976fdd76c1 | ||
![]() |
bbda335e02 | ||
![]() |
d2dd6f7c70 | ||
![]() |
e9a544fa98 | ||
![]() |
79f2f8cddc | ||
![]() |
39fa949345 | ||
![]() |
e1d7a5cbf5 | ||
![]() |
f3cefaf043 | ||
![]() |
b3460f3f54 | ||
![]() |
1e0ad1f6bf | ||
![]() |
4abcb08cc9 | ||
![]() |
81e7833711 | ||
![]() |
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 |
3
INSTALL
3
INSTALL
@@ -116,9 +116,6 @@ For WavPack playback.
|
|||||||
libadplug - http://adplug.sourceforge.net/
|
libadplug - http://adplug.sourceforge.net/
|
||||||
For AdLib playback.
|
For AdLib playback.
|
||||||
|
|
||||||
despotify - https://github.com/SimonKagstrom/despotify
|
|
||||||
For Spotify playback.
|
|
||||||
|
|
||||||
|
|
||||||
Optional Miscellaneous Dependencies
|
Optional Miscellaneous Dependencies
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
32
Makefile.am
32
Makefile.am
@@ -28,8 +28,6 @@ noinst_LIBRARIES = \
|
|||||||
libmixer_plugins.a \
|
libmixer_plugins.a \
|
||||||
liboutput_plugins.a
|
liboutput_plugins.a
|
||||||
|
|
||||||
libmpd_a_DEPENDENCIES =
|
|
||||||
|
|
||||||
libmpd_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
libmpd_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||||
$(LIBMPDCLIENT_CFLAGS) \
|
$(LIBMPDCLIENT_CFLAGS) \
|
||||||
$(AVAHI_CFLAGS) \
|
$(AVAHI_CFLAGS) \
|
||||||
@@ -283,13 +281,13 @@ android/build/build.xml: android/AndroidManifest.xml
|
|||||||
ln -s $(abs_srcdir)/android/res/values android/build/res
|
ln -s $(abs_srcdir)/android/res/values android/build/res
|
||||||
$(ANDROID_SDK)/tools/android update project --path android/build --target android-17
|
$(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
|
cd android/build && ant compile-jni-classes
|
||||||
|
|
||||||
android/build/include/org_musicpd_Bridge.h: android/build/bin/classes/org/musicpd/Bridge.class
|
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
|
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
|
android/build/libs/armeabi-v7a/libmpd.so: libmpd.so android/build/build.xml
|
||||||
mkdir -p $(@D)
|
mkdir -p $(@D)
|
||||||
@@ -1125,7 +1123,6 @@ libinput_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
|||||||
$(NFS_CFLAGS) \
|
$(NFS_CFLAGS) \
|
||||||
$(CDIO_PARANOIA_CFLAGS) \
|
$(CDIO_PARANOIA_CFLAGS) \
|
||||||
$(FFMPEG_CFLAGS) \
|
$(FFMPEG_CFLAGS) \
|
||||||
$(DESPOTIFY_CFLAGS) \
|
|
||||||
$(MMS_CFLAGS)
|
$(MMS_CFLAGS)
|
||||||
|
|
||||||
INPUT_LIBS = \
|
INPUT_LIBS = \
|
||||||
@@ -1135,7 +1132,6 @@ INPUT_LIBS = \
|
|||||||
$(NFS_LIBS) \
|
$(NFS_LIBS) \
|
||||||
$(CDIO_PARANOIA_LIBS) \
|
$(CDIO_PARANOIA_LIBS) \
|
||||||
$(FFMPEG_LIBS2) \
|
$(FFMPEG_LIBS2) \
|
||||||
$(DESPOTIFY_LIBS) \
|
|
||||||
$(MMS_LIBS)
|
$(MMS_LIBS)
|
||||||
|
|
||||||
if HAVE_ALSA
|
if HAVE_ALSA
|
||||||
@@ -1181,15 +1177,6 @@ libinput_a_SOURCES += \
|
|||||||
src/input/plugins/MmsInputPlugin.cxx src/input/plugins/MmsInputPlugin.hxx
|
src/input/plugins/MmsInputPlugin.cxx src/input/plugins/MmsInputPlugin.hxx
|
||||||
endif
|
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) \
|
liboutput_plugins_a_CPPFLAGS = $(AM_CPPFLAGS) \
|
||||||
$(AO_CFLAGS) \
|
$(AO_CFLAGS) \
|
||||||
$(ALSA_CFLAGS) \
|
$(ALSA_CFLAGS) \
|
||||||
@@ -1232,6 +1219,7 @@ liboutput_plugins_a_SOURCES = \
|
|||||||
|
|
||||||
MIXER_LIBS = \
|
MIXER_LIBS = \
|
||||||
libmixer_plugins.a \
|
libmixer_plugins.a \
|
||||||
|
$(ALSA_LIBS) \
|
||||||
$(PULSE_LIBS)
|
$(PULSE_LIBS)
|
||||||
|
|
||||||
MIXER_API_SRC = \
|
MIXER_API_SRC = \
|
||||||
@@ -1394,14 +1382,6 @@ PLAYLIST_LIBS = \
|
|||||||
$(EXPAT_LIBS) \
|
$(EXPAT_LIBS) \
|
||||||
$(FLAC_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
|
if ENABLE_SOUNDCLOUD
|
||||||
libplaylist_plugins_a_SOURCES += \
|
libplaylist_plugins_a_SOURCES += \
|
||||||
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx \
|
src/playlist/plugins/SoundCloudPlaylistPlugin.cxx \
|
||||||
@@ -1638,12 +1618,6 @@ if HAVE_LIBUPNP
|
|||||||
test_run_neighbor_explorer_SOURCES += src/lib/expat/ExpatParser.cxx
|
test_run_neighbor_explorer_SOURCES += src/lib/expat/ExpatParser.cxx
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ENABLE_DESPOTIFY
|
|
||||||
test_run_neighbor_explorer_SOURCES += \
|
|
||||||
src/lib/despotify/DespotifyUtils.cxx \
|
|
||||||
src/lib/despotify/DespotifyUtils.hxx
|
|
||||||
endif
|
|
||||||
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
if ENABLE_ARCHIVE
|
if ENABLE_ARCHIVE
|
||||||
|
67
NEWS
67
NEWS
@@ -1,3 +1,63 @@
|
|||||||
|
ver 0.19.14 (2016/03/18)
|
||||||
|
* decoder
|
||||||
|
- dsdiff: fix off-by-one buffer overflow
|
||||||
|
- opus: limit tag size to 64 kB
|
||||||
|
* archive
|
||||||
|
- iso9660: fix buffer overflow
|
||||||
|
* fix quadratic runtime bug in the tag pool
|
||||||
|
* fix build failures on non-glibc builds due to constexpr Mutex
|
||||||
|
|
||||||
|
ver 0.19.13 (2016/02/23)
|
||||||
|
* tags
|
||||||
|
- aiff, riff: fix ID3 chunk padding
|
||||||
|
* decoder
|
||||||
|
- ffmpeg: support the TAK codec
|
||||||
|
* fix disappearing duration of remote songs during playback
|
||||||
|
* initialize supplementary groups with glibc 2.19+
|
||||||
|
|
||||||
|
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)
|
ver 0.19.8 (2015/01/14)
|
||||||
* input
|
* input
|
||||||
- curl: fix bug after rewinding from end-of-file
|
- curl: fix bug after rewinding from end-of-file
|
||||||
@@ -171,7 +231,12 @@ ver 0.19 (2014/10/10)
|
|||||||
* install systemd unit for socket activation
|
* install systemd unit for socket activation
|
||||||
* Android port
|
* Android port
|
||||||
|
|
||||||
ver 0.18.22 (2014/01/14)
|
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
|
* fix clang 3.6 warnings
|
||||||
|
|
||||||
ver 0.18.21 (2014/12/17)
|
ver 0.18.21 (2014/12/17)
|
||||||
|
@@ -2,8 +2,8 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
package="org.musicpd"
|
package="org.musicpd"
|
||||||
android:installLocation="auto"
|
android:installLocation="auto"
|
||||||
android:versionCode="12"
|
android:versionCode="13"
|
||||||
android:versionName="0.19.8">
|
android:versionName="0.19.9">
|
||||||
|
|
||||||
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17"/>
|
<uses-sdk android:minSdkVersion="9" android:targetSdkVersion="17"/>
|
||||||
|
|
||||||
|
@@ -23,7 +23,7 @@ if not os.path.isdir(ndk_path):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
# the path to the MPD sources
|
# the path to the MPD sources
|
||||||
mpd_path = os.path.dirname(os.path.dirname(sys.argv[0])) or '.'
|
mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..'))
|
||||||
|
|
||||||
# output directories
|
# output directories
|
||||||
lib_path = os.path.abspath('lib')
|
lib_path = os.path.abspath('lib')
|
||||||
|
20
configure.ac
20
configure.ac
@@ -1,10 +1,10 @@
|
|||||||
AC_PREREQ(2.60)
|
AC_PREREQ(2.60)
|
||||||
|
|
||||||
AC_INIT(mpd, 0.19.8, musicpd-dev-team@lists.sourceforge.net)
|
AC_INIT(mpd, 0.19.14, musicpd-dev-team@lists.sourceforge.net)
|
||||||
|
|
||||||
VERSION_MAJOR=0
|
VERSION_MAJOR=0
|
||||||
VERSION_MINOR=19
|
VERSION_MINOR=19
|
||||||
VERSION_REVISION=8
|
VERSION_REVISION=14
|
||||||
VERSION_EXTRA=0
|
VERSION_EXTRA=0
|
||||||
|
|
||||||
AC_CONFIG_SRCDIR([src/Main.cxx])
|
AC_CONFIG_SRCDIR([src/Main.cxx])
|
||||||
@@ -206,6 +206,8 @@ if test x$host_is_linux = xyes; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
AC_CHECK_FUNCS(getpwnam_r getpwuid_r)
|
AC_CHECK_FUNCS(getpwnam_r getpwuid_r)
|
||||||
|
AC_CHECK_FUNCS(initgroups)
|
||||||
|
AC_CHECK_FUNCS(strndup)
|
||||||
|
|
||||||
if test x$host_is_linux = xyes; then
|
if test x$host_is_linux = xyes; then
|
||||||
MPD_OPTIONAL_FUNC(eventfd, eventfd, USE_EVENTFD)
|
MPD_OPTIONAL_FUNC(eventfd, eventfd, USE_EVENTFD)
|
||||||
@@ -445,11 +447,6 @@ MPD_DEPENDS([enable_jack], [enable_glib],
|
|||||||
|
|
||||||
AC_SYS_LARGEFILE
|
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,
|
AC_ARG_ENABLE(soundcloud,
|
||||||
AS_HELP_STRING([--enable-soundcloud],
|
AS_HELP_STRING([--enable-soundcloud],
|
||||||
[enable support for soundcloud.com]),,
|
[enable support for soundcloud.com]),,
|
||||||
@@ -979,14 +976,6 @@ if test x$enable_nfs = xyes; then
|
|||||||
fi
|
fi
|
||||||
AM_CONDITIONAL(ENABLE_NFS, test x$enable_nfs = xyes)
|
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 ------------------------------
|
dnl --------------------------------- Soundcloud ------------------------------
|
||||||
if test x$enable_soundcloud != xno; then
|
if test x$enable_soundcloud != xno; then
|
||||||
PKG_CHECK_MODULES([YAJL], [yajl >= 2.0],
|
PKG_CHECK_MODULES([YAJL], [yajl >= 2.0],
|
||||||
@@ -1903,7 +1892,6 @@ printf '\nStreaming support:\n\t'
|
|||||||
results(cdio_paranoia, [CDIO_PARANOIA])
|
results(cdio_paranoia, [CDIO_PARANOIA])
|
||||||
results(curl,[CURL])
|
results(curl,[CURL])
|
||||||
results(smbclient,[SMBCLIENT])
|
results(smbclient,[SMBCLIENT])
|
||||||
results(despotify,[Despotify])
|
|
||||||
results(soundcloud,[Soundcloud])
|
results(soundcloud,[Soundcloud])
|
||||||
printf '\n\t'
|
printf '\n\t'
|
||||||
results(mms,[MMS])
|
results(mms,[MMS])
|
||||||
|
@@ -195,16 +195,6 @@ of database.
|
|||||||
Limit the depth of the directories being watched, 0 means only watch
|
Limit the depth of the directories being watched, 0 means only watch
|
||||||
the music directory itself. There is no limit by default.
|
the music directory itself. There is no limit by default.
|
||||||
.TP
|
.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
|
.SH REQUIRED AUDIO OUTPUT PARAMETERS
|
||||||
.TP
|
.TP
|
||||||
.B type <type>
|
.B type <type>
|
||||||
|
@@ -1141,7 +1141,7 @@ OK
|
|||||||
</term>
|
</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<para>
|
<para>
|
||||||
Searches case-sensitively for partial matches in the
|
Searches case-insensitively for partial matches in the
|
||||||
current playlist.
|
current playlist.
|
||||||
</para>
|
</para>
|
||||||
</listitem>
|
</listitem>
|
||||||
|
184
doc/user.xml
184
doc/user.xml
@@ -315,9 +315,8 @@ systemctl start mpd.socket</programlisting>
|
|||||||
</para>
|
</para>
|
||||||
|
|
||||||
<programlisting>input {
|
<programlisting>input {
|
||||||
plugin "despotify"
|
plugin "curl"
|
||||||
user "foo"
|
proxy "proxy.local"
|
||||||
password "bar"
|
|
||||||
}
|
}
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
|
||||||
@@ -1191,6 +1190,58 @@ database {
|
|||||||
plugin).
|
plugin).
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</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>
|
||||||
|
|
||||||
<chapter id="use">
|
<chapter id="use">
|
||||||
@@ -1740,66 +1791,6 @@ buffer_size: 16384</programlisting>
|
|||||||
</informaltable>
|
</informaltable>
|
||||||
</section>
|
</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>
|
<section>
|
||||||
<title><varname>file</varname></title>
|
<title><varname>file</varname></title>
|
||||||
|
|
||||||
@@ -2656,7 +2647,8 @@ buffer_size: 16384</programlisting>
|
|||||||
/ <ulink
|
/ <ulink
|
||||||
url="http://icecast.org/"><application>IceCast</application></ulink>.
|
url="http://icecast.org/"><application>IceCast</application></ulink>.
|
||||||
HTTP streaming clients like
|
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>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
@@ -3286,70 +3278,6 @@ buffer_size: 16384</programlisting>
|
|||||||
playlist files.
|
playlist files.
|
||||||
</para>
|
</para>
|
||||||
</section>
|
</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>
|
</section>
|
||||||
</chapter>
|
</chapter>
|
||||||
</book>
|
</book>
|
||||||
|
@@ -188,6 +188,14 @@ public:
|
|||||||
tag = std::move(other.tag);
|
tag = std::move(other.tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to the MoveTagFrom(), but move only the #TagItem
|
||||||
|
* array.
|
||||||
|
*/
|
||||||
|
void MoveTagItemsFrom(DetachedSong &&other) {
|
||||||
|
tag.MoveItemsFrom(std::move(other.tag));
|
||||||
|
}
|
||||||
|
|
||||||
time_t GetLastModified() const {
|
time_t GetLastModified() const {
|
||||||
return mtime;
|
return mtime;
|
||||||
}
|
}
|
||||||
|
@@ -54,7 +54,6 @@
|
|||||||
#include "system/FatalError.hxx"
|
#include "system/FatalError.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "util/Domain.hxx"
|
|
||||||
#include "thread/Id.hxx"
|
#include "thread/Id.hxx"
|
||||||
#include "thread/Slack.hxx"
|
#include "thread/Slack.hxx"
|
||||||
#include "lib/icu/Init.hxx"
|
#include "lib/icu/Init.hxx"
|
||||||
@@ -123,8 +122,6 @@
|
|||||||
static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096;
|
static constexpr unsigned DEFAULT_BUFFER_SIZE = 4096;
|
||||||
static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
|
static constexpr unsigned DEFAULT_BUFFER_BEFORE_PLAY = 10;
|
||||||
|
|
||||||
static constexpr Domain main_domain("main");
|
|
||||||
|
|
||||||
#ifdef ANDROID
|
#ifdef ANDROID
|
||||||
Context *context;
|
Context *context;
|
||||||
#endif
|
#endif
|
||||||
@@ -633,7 +630,7 @@ static int mpd_main_after_fork(struct options options)
|
|||||||
config_get_unsigned(CONF_AUTO_UPDATE_DEPTH,
|
config_get_unsigned(CONF_AUTO_UPDATE_DEPTH,
|
||||||
INT_MAX));
|
INT_MAX));
|
||||||
#else
|
#else
|
||||||
FormatWarning(main_domain,
|
FormatWarning(config_domain,
|
||||||
"inotify: auto_update was disabled. enable during compilation phase");
|
"inotify: auto_update was disabled. enable during compilation phase");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -612,6 +612,12 @@ Player::ProcessCommand()
|
|||||||
|
|
||||||
queued = true;
|
queued = true;
|
||||||
pc.CommandFinished();
|
pc.CommandFinished();
|
||||||
|
|
||||||
|
pc.Unlock();
|
||||||
|
if (dc.LockIsIdle())
|
||||||
|
StartDecoder(*new MusicPipe());
|
||||||
|
pc.Lock();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PlayerCommand::PAUSE:
|
case PlayerCommand::PAUSE:
|
||||||
|
@@ -66,7 +66,11 @@ public:
|
|||||||
return iso9660_iso_seek_read(iso, ptr, start, i_size);
|
return iso9660_iso_seek_read(iso, ptr, start, i_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Visit(const char *path, ArchiveVisitor &visitor);
|
/**
|
||||||
|
* @param capacity the path buffer size
|
||||||
|
*/
|
||||||
|
void Visit(char *path, size_t length, size_t capacity,
|
||||||
|
ArchiveVisitor &visitor);
|
||||||
|
|
||||||
virtual void Close() override {
|
virtual void Close() override {
|
||||||
Unref();
|
Unref();
|
||||||
@@ -84,32 +88,36 @@ static constexpr Domain iso9660_domain("iso9660");
|
|||||||
/* archive open && listing routine */
|
/* archive open && listing routine */
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
Iso9660ArchiveFile::Visit(const char *psz_path, ArchiveVisitor &visitor)
|
Iso9660ArchiveFile::Visit(char *path, size_t length, size_t capacity,
|
||||||
|
ArchiveVisitor &visitor)
|
||||||
{
|
{
|
||||||
CdioList_t *entlist;
|
auto *entlist = iso9660_ifs_readdir(iso, path);
|
||||||
CdioListNode_t *entnode;
|
|
||||||
iso9660_stat_t *statbuf;
|
|
||||||
char pathname[4096];
|
|
||||||
|
|
||||||
entlist = iso9660_ifs_readdir (iso, psz_path);
|
|
||||||
if (!entlist) {
|
if (!entlist) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
|
/* Iterate over the list of nodes that iso9660_ifs_readdir gives */
|
||||||
|
CdioListNode_t *entnode;
|
||||||
_CDIO_LIST_FOREACH (entnode, entlist) {
|
_CDIO_LIST_FOREACH (entnode, entlist) {
|
||||||
statbuf = (iso9660_stat_t *) _cdio_list_node_data (entnode);
|
auto *statbuf = (iso9660_stat_t *)
|
||||||
|
_cdio_list_node_data(entnode);
|
||||||
|
const char *filename = statbuf->filename;
|
||||||
|
if (strcmp(filename, ".") == 0 || strcmp(filename, "..") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
strcpy(pathname, psz_path);
|
size_t filename_length = strlen(filename);
|
||||||
strcat(pathname, statbuf->filename);
|
if (length + filename_length + 1 >= capacity)
|
||||||
|
/* file name is too long */
|
||||||
|
continue;
|
||||||
|
|
||||||
|
memcpy(path + length, filename, filename_length + 1);
|
||||||
|
size_t new_length = length + filename_length;
|
||||||
|
|
||||||
if (iso9660_stat_s::_STAT_DIR == statbuf->type ) {
|
if (iso9660_stat_s::_STAT_DIR == statbuf->type ) {
|
||||||
if (strcmp(statbuf->filename, ".") && strcmp(statbuf->filename, "..")) {
|
memcpy(path + new_length, "/", 2);
|
||||||
strcat(pathname, "/");
|
Visit(path, new_length + 1, capacity, visitor);
|
||||||
Visit(pathname, visitor);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
//remove leading /
|
//remove leading /
|
||||||
visitor.VisitArchiveEntry(pathname + 1);
|
visitor.VisitArchiveEntry(path + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_cdio_list_free (entlist, true);
|
_cdio_list_free (entlist, true);
|
||||||
@@ -133,7 +141,8 @@ iso9660_archive_open(Path pathname, Error &error)
|
|||||||
void
|
void
|
||||||
Iso9660ArchiveFile::Visit(ArchiveVisitor &visitor)
|
Iso9660ArchiveFile::Visit(ArchiveVisitor &visitor)
|
||||||
{
|
{
|
||||||
Visit("/", visitor);
|
char path[4096] = "/";
|
||||||
|
Visit(path, 1, sizeof(path), visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* single archive handling */
|
/* single archive handling */
|
||||||
|
@@ -41,7 +41,7 @@ client_process_command_list(Client &client, bool list_ok,
|
|||||||
|
|
||||||
FormatDebug(client_domain, "process command \"%s\"", cmd);
|
FormatDebug(client_domain, "process command \"%s\"", cmd);
|
||||||
ret = command_process(client, num++, 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())
|
if (ret != CommandResult::OK || client.IsExpired())
|
||||||
break;
|
break;
|
||||||
else if (list_ok)
|
else if (list_ok)
|
||||||
@@ -90,7 +90,7 @@ client_process_line(Client &client, char *line)
|
|||||||
std::move(cmd_list));
|
std::move(cmd_list));
|
||||||
FormatDebug(client_domain,
|
FormatDebug(client_domain,
|
||||||
"[%u] process command "
|
"[%u] process command "
|
||||||
"list returned %i", client.num, ret);
|
"list returned %i", client.num, int(ret));
|
||||||
|
|
||||||
if (ret == CommandResult::CLOSE ||
|
if (ret == CommandResult::CLOSE ||
|
||||||
client.IsExpired())
|
client.IsExpired())
|
||||||
@@ -126,7 +126,7 @@ client_process_line(Client &client, char *line)
|
|||||||
ret = command_process(client, 0, line);
|
ret = command_process(client, 0, line);
|
||||||
FormatDebug(client_domain,
|
FormatDebug(client_domain,
|
||||||
"[%u] command returned %i",
|
"[%u] command returned %i",
|
||||||
client.num, ret);
|
client.num, int(ret));
|
||||||
|
|
||||||
if (ret == CommandResult::CLOSE ||
|
if (ret == CommandResult::CLOSE ||
|
||||||
client.IsExpired())
|
client.IsExpired())
|
||||||
|
@@ -334,7 +334,7 @@ UpdateWalk::UpdateDirectory(Directory &directory, const FileInfo &info)
|
|||||||
directory_set_stat(directory, info);
|
directory_set_stat(directory, info);
|
||||||
|
|
||||||
Error error;
|
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) {
|
if (reader.get() == nullptr) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
return false;
|
return false;
|
||||||
|
@@ -433,8 +433,11 @@ update_stream_tag(Decoder &decoder, InputStream *is)
|
|||||||
|
|
||||||
/* no stream tag present - submit the song tag
|
/* no stream tag present - submit the song tag
|
||||||
instead */
|
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;
|
delete decoder.stream_tag;
|
||||||
decoder.stream_tag = tag;
|
decoder.stream_tag = tag;
|
||||||
@@ -566,7 +569,7 @@ decoder_tag(Decoder &decoder, InputStream *is,
|
|||||||
/* save the tag */
|
/* save the tag */
|
||||||
|
|
||||||
delete decoder.decoder_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 */
|
/* check for a new stream tag */
|
||||||
|
|
||||||
|
@@ -380,7 +380,11 @@ decoder_run_song(DecoderControl &dc,
|
|||||||
const DetachedSong &song, const char *uri, Path path_fs)
|
const DetachedSong &song, const char *uri, Path path_fs)
|
||||||
{
|
{
|
||||||
Decoder decoder(dc, dc.start_time.IsPositive(),
|
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;
|
int ret;
|
||||||
|
|
||||||
dc.state = DecoderState::START;
|
dc.state = DecoderState::START;
|
||||||
|
@@ -125,27 +125,26 @@ dsdlib_tag_id3(InputStream &is,
|
|||||||
|
|
||||||
const id3_length_t count = size - offset;
|
const id3_length_t count = size - offset;
|
||||||
|
|
||||||
if (count < 10 || count > 256*1024)
|
if (count < 10 || count > 1024 * 1024)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
id3_byte_t *const id3_buf = static_cast<id3_byte_t*>(xalloc(count));
|
id3_byte_t *const id3_buf = new id3_byte_t[count];
|
||||||
|
if (id3_buf == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (!decoder_read_full(nullptr, is, id3_buf, count)) {
|
if (!decoder_read_full(nullptr, is, id3_buf, count)) {
|
||||||
free(id3_buf);
|
delete[] id3_buf;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct id3_tag *id3_tag = id3_tag_parse(id3_buf, count);
|
struct id3_tag *id3_tag = id3_tag_parse(id3_buf, count);
|
||||||
if (id3_tag == nullptr) {
|
delete[] id3_buf;
|
||||||
free(id3_buf);
|
if (id3_tag == nullptr)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
scan_id3_tag(id3_tag, handler, handler_ctx);
|
scan_id3_tag(id3_tag, handler, handler_ctx);
|
||||||
|
|
||||||
id3_tag_delete(id3_tag);
|
id3_tag_delete(id3_tag);
|
||||||
|
|
||||||
free(id3_buf);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@@ -205,7 +205,7 @@ dsdiff_handle_native_tag(InputStream &is,
|
|||||||
if (length == 0 || length > 60)
|
if (length == 0 || length > 60)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
char string[length];
|
char string[length + 1];
|
||||||
char *label;
|
char *label;
|
||||||
label = string;
|
label = string;
|
||||||
|
|
||||||
|
@@ -92,14 +92,14 @@ struct AvioStream {
|
|||||||
|
|
||||||
AVIOContext *io;
|
AVIOContext *io;
|
||||||
|
|
||||||
unsigned char buffer[8192];
|
|
||||||
|
|
||||||
AvioStream(Decoder *_decoder, InputStream &_input)
|
AvioStream(Decoder *_decoder, InputStream &_input)
|
||||||
:decoder(_decoder), input(_input), io(nullptr) {}
|
:decoder(_decoder), input(_input), io(nullptr) {}
|
||||||
|
|
||||||
~AvioStream() {
|
~AvioStream() {
|
||||||
if (io != nullptr)
|
if (io != nullptr) {
|
||||||
|
av_free(io->buffer);
|
||||||
av_free(io);
|
av_free(io);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Open();
|
bool Open();
|
||||||
@@ -153,11 +153,20 @@ mpd_ffmpeg_stream_seek(void *opaque, int64_t pos, int whence)
|
|||||||
bool
|
bool
|
||||||
AvioStream::Open()
|
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,
|
false, this,
|
||||||
mpd_ffmpeg_stream_read, nullptr,
|
mpd_ffmpeg_stream_read, nullptr,
|
||||||
input.IsSeekable()
|
input.IsSeekable()
|
||||||
? mpd_ffmpeg_stream_seek : nullptr);
|
? 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;
|
return io != nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -305,20 +314,60 @@ copy_interleave_frame(const AVCodecContext *codec_context,
|
|||||||
return data_size;
|
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
|
static DecoderCommand
|
||||||
ffmpeg_send_packet(Decoder &decoder, InputStream &is,
|
ffmpeg_send_packet(Decoder &decoder, InputStream &is,
|
||||||
const AVPacket *packet,
|
const AVPacket *packet,
|
||||||
AVCodecContext *codec_context,
|
AVCodecContext *codec_context,
|
||||||
const AVStream *stream,
|
const AVStream *stream,
|
||||||
AVFrame *frame,
|
AVFrame *frame,
|
||||||
|
uint64_t min_frame, size_t pcm_frame_size,
|
||||||
uint8_t **buffer, int *buffer_size)
|
uint8_t **buffer, int *buffer_size)
|
||||||
{
|
{
|
||||||
if (packet->pts >= 0 && packet->pts != (int64_t)AV_NOPTS_VALUE) {
|
size_t skip_bytes = 0;
|
||||||
auto start = start_time_fallback(*stream);
|
|
||||||
if (packet->pts >= start)
|
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,
|
decoder_timestamp(decoder,
|
||||||
time_from_ffmpeg(packet->pts - start,
|
time_from_ffmpeg(pts, stream->time_base));
|
||||||
stream->time_base));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AVPacket packet2 = *packet;
|
AVPacket packet2 = *packet;
|
||||||
@@ -354,8 +403,20 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
|
|||||||
if (audio_size <= 0)
|
if (audio_size <= 0)
|
||||||
continue;
|
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,
|
cmd = decoder_data(decoder, is,
|
||||||
output_buffer, audio_size,
|
data, audio_size,
|
||||||
codec_context->bit_rate / 1000);
|
codec_context->bit_rate / 1000);
|
||||||
}
|
}
|
||||||
return cmd;
|
return cmd;
|
||||||
@@ -559,6 +620,8 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
|
|||||||
uint8_t *interleaved_buffer = nullptr;
|
uint8_t *interleaved_buffer = nullptr;
|
||||||
int interleaved_buffer_size = 0;
|
int interleaved_buffer_size = 0;
|
||||||
|
|
||||||
|
uint64_t min_frame = 0;
|
||||||
|
|
||||||
DecoderCommand cmd;
|
DecoderCommand cmd;
|
||||||
do {
|
do {
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
@@ -566,13 +629,15 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
|
|||||||
/* end of file */
|
/* end of file */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
if (packet.stream_index == audio_stream)
|
if (packet.stream_index == audio_stream) {
|
||||||
cmd = ffmpeg_send_packet(decoder, input,
|
cmd = ffmpeg_send_packet(decoder, input,
|
||||||
&packet, codec_context,
|
&packet, codec_context,
|
||||||
av_stream,
|
av_stream,
|
||||||
frame,
|
frame,
|
||||||
|
min_frame, audio_format.GetFrameSize(),
|
||||||
&interleaved_buffer, &interleaved_buffer_size);
|
&interleaved_buffer, &interleaved_buffer_size);
|
||||||
else
|
min_frame = 0;
|
||||||
|
} else
|
||||||
cmd = decoder_get_command(decoder);
|
cmd = decoder_get_command(decoder);
|
||||||
|
|
||||||
av_free_packet(&packet);
|
av_free_packet(&packet);
|
||||||
@@ -583,11 +648,16 @@ ffmpeg_decode(Decoder &decoder, InputStream &input)
|
|||||||
av_stream->time_base) +
|
av_stream->time_base) +
|
||||||
start_time_fallback(*av_stream);
|
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,
|
if (av_seek_frame(format_context, audio_stream, where,
|
||||||
AVSEEK_FLAG_ANY) < 0)
|
AVSEEK_FLAG_ANY|AVSEEK_FLAG_BACKWARD) < 0)
|
||||||
decoder_seek_error(decoder);
|
decoder_seek_error(decoder);
|
||||||
else {
|
else {
|
||||||
avcodec_flush_buffers(codec_context);
|
avcodec_flush_buffers(codec_context);
|
||||||
|
min_frame = decoder_seek_where_frame(decoder);
|
||||||
decoder_command_finished(decoder);
|
decoder_command_finished(decoder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -668,7 +738,7 @@ static const char *const ffmpeg_suffixes[] = {
|
|||||||
"mve", "mvi", "mxf", "nc", "nsv", "nut", "nuv", "oga", "ogm", "ogv",
|
"mve", "mvi", "mxf", "nc", "nsv", "nut", "nuv", "oga", "ogm", "ogv",
|
||||||
"ogx", "oma", "ogg", "omg", "opus", "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",
|
"ram", "rl2", "rm", "rmvb", "roq", "rpl", "rvc", "shn", "smk", "snd",
|
||||||
"sol", "son", "spx", "str", "swf", "tgi", "tgq", "tgv", "thp", "ts",
|
"sol", "son", "spx", "str", "swf", "tak", "tgi", "tgq", "tgv", "thp", "ts",
|
||||||
"tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc",
|
"tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc",
|
||||||
"vp6", "vmd", "wav", "webm", "wma", "wmv", "wsaud", "wsvga", "wv",
|
"vp6", "vmd", "wav", "webm", "wma", "wmv", "wsaud", "wsvga", "wv",
|
||||||
"wve",
|
"wve",
|
||||||
|
@@ -156,8 +156,11 @@ gme_file_decode(Decoder &decoder, Path path_fs)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const SignedSongTime song_len = ti->length > 0
|
const int length = ti->play_length;
|
||||||
? SignedSongTime::FromMS(ti->length)
|
gme_free_info(ti);
|
||||||
|
|
||||||
|
const SignedSongTime song_len = length > 0
|
||||||
|
? SignedSongTime::FromMS(length)
|
||||||
: SignedSongTime::Negative();
|
: SignedSongTime::Negative();
|
||||||
|
|
||||||
/* initialize the MPD decoder */
|
/* initialize the MPD decoder */
|
||||||
@@ -168,7 +171,6 @@ gme_file_decode(Decoder &decoder, Path path_fs)
|
|||||||
SampleFormat::S16, GME_CHANNELS,
|
SampleFormat::S16, GME_CHANNELS,
|
||||||
error)) {
|
error)) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
gme_free_info(ti);
|
|
||||||
gme_delete(emu);
|
gme_delete(emu);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -179,8 +181,8 @@ gme_file_decode(Decoder &decoder, Path path_fs)
|
|||||||
if (gme_err != nullptr)
|
if (gme_err != nullptr)
|
||||||
LogWarning(gme_domain, gme_err);
|
LogWarning(gme_domain, gme_err);
|
||||||
|
|
||||||
if (ti->length > 0)
|
if (length > 0)
|
||||||
gme_set_fade(emu, ti->length);
|
gme_set_fade(emu, length);
|
||||||
|
|
||||||
/* play */
|
/* play */
|
||||||
DecoderCommand cmd;
|
DecoderCommand cmd;
|
||||||
@@ -196,16 +198,17 @@ gme_file_decode(Decoder &decoder, Path path_fs)
|
|||||||
if (cmd == DecoderCommand::SEEK) {
|
if (cmd == DecoderCommand::SEEK) {
|
||||||
unsigned where = decoder_seek_time(decoder).ToMS();
|
unsigned where = decoder_seek_time(decoder).ToMS();
|
||||||
gme_err = gme_seek(emu, where);
|
gme_err = gme_seek(emu, where);
|
||||||
if (gme_err != nullptr)
|
if (gme_err != nullptr) {
|
||||||
LogWarning(gme_domain, gme_err);
|
LogWarning(gme_domain, gme_err);
|
||||||
decoder_command_finished(decoder);
|
decoder_seek_error(decoder);
|
||||||
|
} else
|
||||||
|
decoder_command_finished(decoder);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gme_track_ended(emu))
|
if (gme_track_ended(emu))
|
||||||
break;
|
break;
|
||||||
} while (cmd != DecoderCommand::STOP);
|
} while (cmd != DecoderCommand::STOP);
|
||||||
|
|
||||||
gme_free_info(ti);
|
|
||||||
gme_delete(emu);
|
gme_delete(emu);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -236,9 +239,9 @@ gme_scan_file(Path path_fs,
|
|||||||
|
|
||||||
assert(ti != nullptr);
|
assert(ti != nullptr);
|
||||||
|
|
||||||
if (ti->length > 0)
|
if (ti->play_length > 0)
|
||||||
tag_handler_invoke_duration(handler, handler_ctx,
|
tag_handler_invoke_duration(handler, handler_ctx,
|
||||||
SongTime::FromMS(ti->length));
|
SongTime::FromMS(ti->play_length));
|
||||||
|
|
||||||
if (ti->song != nullptr) {
|
if (ti->song != nullptr) {
|
||||||
if (gme_track_count(emu) > 1) {
|
if (gme_track_count(emu) > 1) {
|
||||||
|
@@ -22,10 +22,12 @@
|
|||||||
#include "../DecoderAPI.hxx"
|
#include "../DecoderAPI.hxx"
|
||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "CheckAudioFormat.hxx"
|
#include "CheckAudioFormat.hxx"
|
||||||
|
#include "pcm/Traits.hxx"
|
||||||
#include "tag/TagHandler.hxx"
|
#include "tag/TagHandler.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "util/Macros.hxx"
|
#include "util/Macros.hxx"
|
||||||
|
#include "util/Clamp.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <mpc/mpcdec.h>
|
#include <mpc/mpcdec.h>
|
||||||
@@ -42,6 +44,9 @@ struct mpc_decoder_data {
|
|||||||
|
|
||||||
static constexpr Domain mpcdec_domain("mpcdec");
|
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
|
static mpc_int32_t
|
||||||
mpc_read_cb(mpc_reader *reader, void *ptr, mpc_int32_t size)
|
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 */
|
/* 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)
|
mpc_to_mpd_sample(MPC_SAMPLE_FORMAT sample)
|
||||||
{
|
{
|
||||||
/* only doing 16-bit audio for now */
|
/* only doing 16-bit audio for now */
|
||||||
int32_t val;
|
MpcdecSampleTraits::value_type val;
|
||||||
|
|
||||||
enum {
|
constexpr int bits = MpcdecSampleTraits::BITS;
|
||||||
bits = 24,
|
constexpr auto clip_min = MpcdecSampleTraits::MIN;
|
||||||
};
|
constexpr auto clip_max = MpcdecSampleTraits::MAX;
|
||||||
|
|
||||||
const int clip_min = -1 << (bits - 1);
|
|
||||||
const int clip_max = (1 << (bits - 1)) - 1;
|
|
||||||
|
|
||||||
#ifdef MPC_FIXED_POINT
|
#ifdef MPC_FIXED_POINT
|
||||||
const int shift = bits - MPC_FIXED_POINT_SCALE_SHIFT;
|
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;
|
val = sample * float_scale;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (val < clip_min)
|
return Clamp(val, clip_min, clip_max);
|
||||||
val = clip_min;
|
|
||||||
else if (val > clip_max)
|
|
||||||
val = clip_max;
|
|
||||||
|
|
||||||
return val;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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)
|
unsigned num_samples)
|
||||||
{
|
{
|
||||||
while (num_samples-- > 0)
|
while (num_samples-- > 0)
|
||||||
@@ -162,7 +160,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
|
|||||||
Error error;
|
Error error;
|
||||||
AudioFormat audio_format;
|
AudioFormat audio_format;
|
||||||
if (!audio_format_init_checked(audio_format, info.sample_freq,
|
if (!audio_format_init_checked(audio_format, info.sample_freq,
|
||||||
SampleFormat::S24_P32,
|
mpcdec_sample_format,
|
||||||
info.channels, error)) {
|
info.channels, error)) {
|
||||||
LogError(error);
|
LogError(error);
|
||||||
mpc_demux_exit(demux);
|
mpc_demux_exit(demux);
|
||||||
@@ -214,7 +212,7 @@ mpcdec_decode(Decoder &mpd_decoder, InputStream &is)
|
|||||||
mpc_uint32_t ret = frame.samples;
|
mpc_uint32_t ret = frame.samples;
|
||||||
ret *= info.channels;
|
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);
|
mpc_to_mpd_buffer(chunk, sample_buffer, ret);
|
||||||
|
|
||||||
long bit_rate = vbr_update_bits * audio_format.sample_rate
|
long bit_rate = vbr_update_bits * audio_format.sample_rate
|
||||||
|
@@ -85,7 +85,7 @@ public:
|
|||||||
|
|
||||||
char *ReadString() {
|
char *ReadString() {
|
||||||
uint32_t length;
|
uint32_t length;
|
||||||
if (!ReadWord(length))
|
if (!ReadWord(length) || length >= 65536)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const char *src = (const char *)Read(length);
|
const char *src = (const char *)Read(length);
|
||||||
|
@@ -157,8 +157,6 @@ flac_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error)
|
|||||||
struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
|
struct flac_encoder *encoder = (struct flac_encoder *)_encoder;
|
||||||
unsigned bits_per_sample;
|
unsigned bits_per_sample;
|
||||||
|
|
||||||
encoder->audio_format = audio_format;
|
|
||||||
|
|
||||||
/* FIXME: flac should support 32bit as well */
|
/* FIXME: flac should support 32bit as well */
|
||||||
switch (audio_format.format) {
|
switch (audio_format.format) {
|
||||||
case SampleFormat::S8:
|
case SampleFormat::S8:
|
||||||
@@ -178,6 +176,8 @@ flac_encoder_open(Encoder *_encoder, AudioFormat &audio_format, Error &error)
|
|||||||
audio_format.format = SampleFormat::S24_P32;
|
audio_format.format = SampleFormat::S24_P32;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
encoder->audio_format = audio_format;
|
||||||
|
|
||||||
/* allocate the encoder */
|
/* allocate the encoder */
|
||||||
encoder->fse = FLAC__stream_encoder_new();
|
encoder->fse = FLAC__stream_encoder_new();
|
||||||
if (encoder->fse == nullptr) {
|
if (encoder->fse == nullptr) {
|
||||||
|
@@ -66,7 +66,7 @@ struct opus_encoder {
|
|||||||
|
|
||||||
ogg_int64_t granulepos;
|
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");
|
static constexpr Domain opus_encoder_domain("opus_encoder");
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
#include "util/NumberParser.hxx"
|
#include "util/NumberParser.hxx"
|
||||||
#include "util/DynamicFifoBuffer.hxx"
|
#include "util/DynamicFifoBuffer.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "util/Domain.hxx"
|
|
||||||
|
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
@@ -60,8 +59,6 @@ struct ShineEncoder {
|
|||||||
bool WriteChunk(bool flush);
|
bool WriteChunk(bool flush);
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Domain shine_encoder_domain("shine_encoder");
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
ShineEncoder::Configure(const config_param ¶m,
|
ShineEncoder::Configure(const config_param ¶m,
|
||||||
gcc_unused Error &error)
|
gcc_unused Error &error)
|
||||||
|
@@ -26,7 +26,6 @@
|
|||||||
#include "AudioFormat.hxx"
|
#include "AudioFormat.hxx"
|
||||||
#include "util/ConstBuffer.hxx"
|
#include "util/ConstBuffer.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "util/Domain.hxx"
|
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -50,8 +49,6 @@ public:
|
|||||||
Error &error) override;
|
Error &error) override;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Domain volume_domain("pcm_volume");
|
|
||||||
|
|
||||||
static Filter *
|
static Filter *
|
||||||
volume_filter_init(gcc_unused const config_param ¶m,
|
volume_filter_init(gcc_unused const config_param ¶m,
|
||||||
gcc_unused Error &error)
|
gcc_unused Error &error)
|
||||||
|
@@ -62,6 +62,7 @@ FileOutputStream::Commit(gcc_unused Error &error)
|
|||||||
assert(IsDefined());
|
assert(IsDefined());
|
||||||
|
|
||||||
CloseHandle(handle);
|
CloseHandle(handle);
|
||||||
|
handle = INVALID_HANDLE_VALUE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +72,7 @@ FileOutputStream::Cancel()
|
|||||||
assert(IsDefined());
|
assert(IsDefined());
|
||||||
|
|
||||||
CloseHandle(handle);
|
CloseHandle(handle);
|
||||||
|
handle = INVALID_HANDLE_VALUE;
|
||||||
RemoveFile(path);
|
RemoveFile(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -54,10 +54,6 @@
|
|||||||
#include "plugins/CdioParanoiaInputPlugin.hxx"
|
#include "plugins/CdioParanoiaInputPlugin.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef ENABLE_DESPOTIFY
|
|
||||||
#include "plugins/DespotifyInputPlugin.hxx"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const InputPlugin *const input_plugins[] = {
|
const InputPlugin *const input_plugins[] = {
|
||||||
&input_plugin_file,
|
&input_plugin_file,
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
@@ -83,9 +79,6 @@ const InputPlugin *const input_plugins[] = {
|
|||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_CDIO_PARANOIA
|
#ifdef ENABLE_CDIO_PARANOIA
|
||||||
&input_plugin_cdio_paranoia,
|
&input_plugin_cdio_paranoia,
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_DESPOTIFY
|
|
||||||
&input_plugin_despotify,
|
|
||||||
#endif
|
#endif
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
@@ -453,6 +453,8 @@ CurlInputStream::RequestDone(CURLcode result, long status)
|
|||||||
SeekDone();
|
SeekDone();
|
||||||
else if (!IsReady())
|
else if (!IsReady())
|
||||||
SetReady();
|
SetReady();
|
||||||
|
else
|
||||||
|
cond.broadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@@ -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,
|
|
||||||
};
|
|
@@ -1,25 +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 INPUT_DESPOTIFY_HXX
|
|
||||||
#define INPUT_DESPOTIFY_HXX
|
|
||||||
|
|
||||||
extern const struct InputPlugin input_plugin_despotify;
|
|
||||||
|
|
||||||
#endif
|
|
@@ -132,6 +132,7 @@ SmbclientInputStream::Read(void *ptr, size_t read_size, Error &error)
|
|||||||
nbytes = 0;
|
nbytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offset += nbytes;
|
||||||
return nbytes;
|
return nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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
|
|
||||||
|
|
@@ -58,9 +58,6 @@ static const char *remoteUrlPrefixes[] = {
|
|||||||
#ifdef ENABLE_CDIO_PARANOIA
|
#ifdef ENABLE_CDIO_PARANOIA
|
||||||
"cdda://",
|
"cdda://",
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_DESPOTIFY
|
|
||||||
"spt://",
|
|
||||||
#endif
|
|
||||||
#ifdef HAVE_ALSA
|
#ifdef HAVE_ALSA
|
||||||
"alsa://",
|
"alsa://",
|
||||||
#endif
|
#endif
|
||||||
|
@@ -25,13 +25,10 @@
|
|||||||
#include "output/Internal.hxx"
|
#include "output/Internal.hxx"
|
||||||
#include "pcm/Volume.hxx"
|
#include "pcm/Volume.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "util/Domain.hxx"
|
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
static constexpr Domain mixer_domain("mixer");
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
output_mixer_get_volume(const AudioOutput &ao)
|
output_mixer_get_volume(const AudioOutput &ao)
|
||||||
{
|
{
|
||||||
|
@@ -218,7 +218,7 @@ PulseMixer::SetVolume(unsigned new_volume, Error &error)
|
|||||||
|
|
||||||
struct pa_cvolume cvolume;
|
struct pa_cvolume cvolume;
|
||||||
pa_cvolume_set(&cvolume, volume.channels,
|
pa_cvolume_set(&cvolume, volume.channels,
|
||||||
(pa_volume_t)new_volume * PA_VOLUME_NORM / 100 + 0.5);
|
(new_volume * PA_VOLUME_NORM + 50) / 100);
|
||||||
bool success = pulse_output_set_volume(output, &cvolume, error);
|
bool success = pulse_output_set_volume(output, &cvolume, error);
|
||||||
if (success)
|
if (success)
|
||||||
volume = cvolume;
|
volume = cvolume;
|
||||||
|
@@ -30,6 +30,7 @@
|
|||||||
#include "Internal.hxx"
|
#include "Internal.hxx"
|
||||||
#include "PlayerControl.hxx"
|
#include "PlayerControl.hxx"
|
||||||
#include "mixer/MixerControl.hxx"
|
#include "mixer/MixerControl.hxx"
|
||||||
|
#include "mixer/Volume.hxx"
|
||||||
#include "Idle.hxx"
|
#include "Idle.hxx"
|
||||||
|
|
||||||
extern unsigned audio_output_state_version;
|
extern unsigned audio_output_state_version;
|
||||||
@@ -47,6 +48,11 @@ audio_output_enable_index(MultipleOutputs &outputs, unsigned idx)
|
|||||||
ao.enabled = true;
|
ao.enabled = true;
|
||||||
idle_add(IDLE_OUTPUT);
|
idle_add(IDLE_OUTPUT);
|
||||||
|
|
||||||
|
if (ao.mixer != nullptr) {
|
||||||
|
InvalidateHardwareVolume();
|
||||||
|
idle_add(IDLE_MIXER);
|
||||||
|
}
|
||||||
|
|
||||||
ao.player_control->UpdateAudio();
|
ao.player_control->UpdateAudio();
|
||||||
|
|
||||||
++audio_output_state_version;
|
++audio_output_state_version;
|
||||||
@@ -70,6 +76,7 @@ audio_output_disable_index(MultipleOutputs &outputs, unsigned idx)
|
|||||||
Mixer *mixer = ao.mixer;
|
Mixer *mixer = ao.mixer;
|
||||||
if (mixer != nullptr) {
|
if (mixer != nullptr) {
|
||||||
mixer_close(mixer);
|
mixer_close(mixer);
|
||||||
|
InvalidateHardwareVolume();
|
||||||
idle_add(IDLE_MIXER);
|
idle_add(IDLE_MIXER);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,6 +101,7 @@ audio_output_toggle_index(MultipleOutputs &outputs, unsigned idx)
|
|||||||
Mixer *mixer = ao.mixer;
|
Mixer *mixer = ao.mixer;
|
||||||
if (mixer != nullptr) {
|
if (mixer != nullptr) {
|
||||||
mixer_close(mixer);
|
mixer_close(mixer);
|
||||||
|
InvalidateHardwareVolume();
|
||||||
idle_add(IDLE_MIXER);
|
idle_add(IDLE_MIXER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -184,7 +184,8 @@ AudioOutput::LockUpdate(const AudioFormat audio_format,
|
|||||||
const ScopeLock protect(mutex);
|
const ScopeLock protect(mutex);
|
||||||
|
|
||||||
if (enabled && really_enabled) {
|
if (enabled && really_enabled) {
|
||||||
if (fail_timer.Check(REOPEN_AFTER * 1000)) {
|
if (!fail_timer.IsDefined() ||
|
||||||
|
fail_timer.Check(REOPEN_AFTER * 1000)) {
|
||||||
return Open(audio_format, mp);
|
return Open(audio_format, mp);
|
||||||
}
|
}
|
||||||
} else if (IsOpen())
|
} else if (IsOpen())
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
#include "../OutputAPI.hxx"
|
#include "../OutputAPI.hxx"
|
||||||
#include "config/ConfigError.hxx"
|
#include "config/ConfigError.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "util/Domain.hxx"
|
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
@@ -44,8 +43,6 @@ struct PipeOutput {
|
|||||||
bool Configure(const config_param ¶m, Error &error);
|
bool Configure(const config_param ¶m, Error &error);
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr Domain pipe_output_domain("pipe_output");
|
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
PipeOutput::Configure(const config_param ¶m, Error &error)
|
PipeOutput::Configure(const config_param ¶m, Error &error)
|
||||||
{
|
{
|
||||||
|
@@ -23,7 +23,6 @@
|
|||||||
#include "plugins/ExtM3uPlaylistPlugin.hxx"
|
#include "plugins/ExtM3uPlaylistPlugin.hxx"
|
||||||
#include "plugins/M3uPlaylistPlugin.hxx"
|
#include "plugins/M3uPlaylistPlugin.hxx"
|
||||||
#include "plugins/XspfPlaylistPlugin.hxx"
|
#include "plugins/XspfPlaylistPlugin.hxx"
|
||||||
#include "plugins/DespotifyPlaylistPlugin.hxx"
|
|
||||||
#include "plugins/SoundCloudPlaylistPlugin.hxx"
|
#include "plugins/SoundCloudPlaylistPlugin.hxx"
|
||||||
#include "plugins/PlsPlaylistPlugin.hxx"
|
#include "plugins/PlsPlaylistPlugin.hxx"
|
||||||
#include "plugins/AsxPlaylistPlugin.hxx"
|
#include "plugins/AsxPlaylistPlugin.hxx"
|
||||||
@@ -54,9 +53,6 @@ const struct playlist_plugin *const playlist_plugins[] = {
|
|||||||
&asx_playlist_plugin,
|
&asx_playlist_plugin,
|
||||||
&rss_playlist_plugin,
|
&rss_playlist_plugin,
|
||||||
#endif
|
#endif
|
||||||
#ifdef ENABLE_DESPOTIFY
|
|
||||||
&despotify_playlist_plugin,
|
|
||||||
#endif
|
|
||||||
#ifdef ENABLE_SOUNDCLOUD
|
#ifdef ENABLE_SOUNDCLOUD
|
||||||
&soundcloud_playlist_plugin,
|
&soundcloud_playlist_plugin,
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,142 +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 "DespotifyPlaylistPlugin.hxx"
|
|
||||||
#include "lib/despotify/DespotifyUtils.hxx"
|
|
||||||
#include "../PlaylistPlugin.hxx"
|
|
||||||
#include "../MemorySongEnumerator.hxx"
|
|
||||||
#include "tag/Tag.hxx"
|
|
||||||
#include "DetachedSong.hxx"
|
|
||||||
#include "Log.hxx"
|
|
||||||
|
|
||||||
extern "C" {
|
|
||||||
#include <despotify.h>
|
|
||||||
}
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
static void
|
|
||||||
add_song(std::forward_list<DetachedSong> &songs, ds_track &track)
|
|
||||||
{
|
|
||||||
const char *dsp_scheme = despotify_playlist_plugin.schemes[0];
|
|
||||||
char uri[128];
|
|
||||||
char *ds_uri;
|
|
||||||
|
|
||||||
/* Create a spt://... URI for MPD */
|
|
||||||
snprintf(uri, sizeof(uri), "%s://", dsp_scheme);
|
|
||||||
ds_uri = uri + strlen(dsp_scheme) + 3;
|
|
||||||
|
|
||||||
if (despotify_track_to_uri(&track, ds_uri) != ds_uri) {
|
|
||||||
/* Should never really fail, but let's be sure */
|
|
||||||
FormatDebug(despotify_domain,
|
|
||||||
"Can't add track %s", track.title);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
songs.emplace_front(uri, mpd_despotify_tag_from_track(track));
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
parse_track(struct despotify_session *session,
|
|
||||||
std::forward_list<DetachedSong> &songs,
|
|
||||||
struct ds_link *link)
|
|
||||||
{
|
|
||||||
struct ds_track *track = despotify_link_get_track(session, link);
|
|
||||||
if (track == nullptr)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
add_song(songs, *track);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool
|
|
||||||
parse_playlist(struct despotify_session *session,
|
|
||||||
std::forward_list<DetachedSong> &songs,
|
|
||||||
struct ds_link *link)
|
|
||||||
{
|
|
||||||
ds_playlist *playlist = despotify_link_get_playlist(session, link);
|
|
||||||
if (playlist == nullptr)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
for (ds_track *track = playlist->tracks; track != nullptr;
|
|
||||||
track = track->next)
|
|
||||||
add_song(songs, *track);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
static SongEnumerator *
|
|
||||||
despotify_playlist_open_uri(const char *url,
|
|
||||||
gcc_unused Mutex &mutex, gcc_unused Cond &cond)
|
|
||||||
{
|
|
||||||
despotify_session *session = mpd_despotify_get_session();
|
|
||||||
if (session == nullptr)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
/* Get link without spt:// */
|
|
||||||
ds_link *link =
|
|
||||||
despotify_link_from_uri(url + strlen(despotify_playlist_plugin.schemes[0]) + 3);
|
|
||||||
if (link == nullptr) {
|
|
||||||
FormatDebug(despotify_domain, "Can't find %s\n", url);
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::forward_list<DetachedSong> songs;
|
|
||||||
|
|
||||||
bool parse_result;
|
|
||||||
switch (link->type) {
|
|
||||||
case LINK_TYPE_TRACK:
|
|
||||||
parse_result = parse_track(session, songs, link);
|
|
||||||
break;
|
|
||||||
case LINK_TYPE_PLAYLIST:
|
|
||||||
parse_result = parse_playlist(session, songs, link);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
parse_result = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
despotify_free_link(link);
|
|
||||||
if (!parse_result)
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
songs.reverse();
|
|
||||||
return new MemorySongEnumerator(std::move(songs));
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *const despotify_schemes[] = {
|
|
||||||
"spt",
|
|
||||||
nullptr
|
|
||||||
};
|
|
||||||
|
|
||||||
const struct playlist_plugin despotify_playlist_plugin = {
|
|
||||||
"despotify",
|
|
||||||
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
despotify_playlist_open_uri,
|
|
||||||
nullptr,
|
|
||||||
|
|
||||||
despotify_schemes,
|
|
||||||
nullptr,
|
|
||||||
nullptr,
|
|
||||||
};
|
|
@@ -1,25 +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_PLAYLIST_DESPOTIFY_PLAYLIST_PLUGIN_HXX
|
|
||||||
#define MPD_PLAYLIST_DESPOTIFY_PLAYLIST_PLUGIN_HXX
|
|
||||||
|
|
||||||
extern const struct playlist_plugin despotify_playlist_plugin;
|
|
||||||
|
|
||||||
#endif
|
|
@@ -25,14 +25,11 @@
|
|||||||
#include "input/InputStream.hxx"
|
#include "input/InputStream.hxx"
|
||||||
#include "tag/TagBuilder.hxx"
|
#include "tag/TagBuilder.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "util/Domain.hxx"
|
|
||||||
#include "lib/expat/ExpatParser.hxx"
|
#include "lib/expat/ExpatParser.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static constexpr Domain xspf_domain("xspf");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is the state object for the GLib XML parser.
|
* This is the state object for the GLib XML parser.
|
||||||
*/
|
*/
|
||||||
|
@@ -92,7 +92,7 @@ check_range(Client &client, unsigned *value_r1, unsigned *value_r2,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unsigned(value) > std::numeric_limits<unsigned>::max()) {
|
if (value > std::numeric_limits<int>::max()) {
|
||||||
command_error(client, ACK_ERROR_ARG,
|
command_error(client, ACK_ERROR_ARG,
|
||||||
"Number too large: %s", s);
|
"Number too large: %s", s);
|
||||||
return false;
|
return false;
|
||||||
@@ -117,7 +117,7 @@ check_range(Client &client, unsigned *value_r1, unsigned *value_r2,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (unsigned(value) > std::numeric_limits<unsigned>::max()) {
|
if (value > std::numeric_limits<int>::max()) {
|
||||||
command_error(client, ACK_ERROR_ARG,
|
command_error(client, ACK_ERROR_ARG,
|
||||||
"Number too large: %s", s);
|
"Number too large: %s", s);
|
||||||
return false;
|
return false;
|
||||||
|
@@ -37,7 +37,7 @@ playlist::TagModified(DetachedSong &&song)
|
|||||||
|
|
||||||
DetachedSong ¤t_song = queue.GetOrder(current);
|
DetachedSong ¤t_song = queue.GetOrder(current);
|
||||||
if (song.IsSame(current_song))
|
if (song.IsSame(current_song))
|
||||||
current_song.MoveTagFrom(std::move(song));
|
current_song.MoveTagItemsFrom(std::move(song));
|
||||||
|
|
||||||
queue.ModifyAtOrder(current);
|
queue.ModifyAtOrder(current);
|
||||||
queue.IncrementVersion();
|
queue.IncrementVersion();
|
||||||
|
@@ -177,6 +177,8 @@ private:
|
|||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
DeferredMonitor::Schedule();
|
DeferredMonitor::Schedule();
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
|
if (state == State::INITIAL)
|
||||||
|
cond.wait(mutex);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case State::CONNECTING:
|
case State::CONNECTING:
|
||||||
@@ -188,8 +190,6 @@ private:
|
|||||||
error.Set(last_error);
|
error.Set(last_error);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
cond.wait(mutex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,8 +40,8 @@ MonotonicClockS(void)
|
|||||||
if (base.denom == 0)
|
if (base.denom == 0)
|
||||||
(void)mach_timebase_info(&base);
|
(void)mach_timebase_info(&base);
|
||||||
|
|
||||||
return (unsigned)((mach_absolute_time() * base.numer / 1000)
|
return (unsigned)(((double)mach_absolute_time() * base.numer / 1000)
|
||||||
/ (1000000 * base.denom));
|
/ base.denom / 1000000);
|
||||||
#elif defined(CLOCK_MONOTONIC)
|
#elif defined(CLOCK_MONOTONIC)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
@@ -62,8 +62,8 @@ MonotonicClockMS(void)
|
|||||||
if (base.denom == 0)
|
if (base.denom == 0)
|
||||||
(void)mach_timebase_info(&base);
|
(void)mach_timebase_info(&base);
|
||||||
|
|
||||||
return (unsigned)((mach_absolute_time() * base.numer)
|
return (unsigned)(((double)mach_absolute_time() * base.numer)
|
||||||
/ (1000000 * base.denom));
|
/ base.denom / 1000000);
|
||||||
#elif defined(CLOCK_MONOTONIC)
|
#elif defined(CLOCK_MONOTONIC)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
@@ -104,8 +104,8 @@ MonotonicClockUS(void)
|
|||||||
if (base.denom == 0)
|
if (base.denom == 0)
|
||||||
(void)mach_timebase_info(&base);
|
(void)mach_timebase_info(&base);
|
||||||
|
|
||||||
return ((uint64_t)mach_absolute_time() * (uint64_t)base.numer)
|
return (uint64_t)(((double)mach_absolute_time() * base.numer)
|
||||||
/ (1000 * (uint64_t)base.denom);
|
/ base.denom / 1000);
|
||||||
#elif defined(CLOCK_MONOTONIC)
|
#elif defined(CLOCK_MONOTONIC)
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||||
|
@@ -63,7 +63,7 @@ protected:
|
|||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
bool IsDefined() const {
|
constexpr bool IsDefined() const {
|
||||||
return last != 0;
|
return last != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -84,14 +84,14 @@ aiff_seek_id3(FILE *file)
|
|||||||
underflow when casting to off_t */
|
underflow when casting to off_t */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (size % 2 != 0)
|
|
||||||
/* pad byte */
|
|
||||||
++size;
|
|
||||||
|
|
||||||
if (memcmp(chunk.id, "ID3 ", 4) == 0)
|
if (memcmp(chunk.id, "ID3 ", 4) == 0)
|
||||||
/* found it! */
|
/* found it! */
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
|
if (size % 2 != 0)
|
||||||
|
/* pad byte */
|
||||||
|
++size;
|
||||||
|
|
||||||
if (fseek(file, size, SEEK_CUR) != 0)
|
if (fseek(file, size, SEEK_CUR) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -78,12 +78,12 @@ ape_scan_internal(FILE *fp, ApeTagCallback callback)
|
|||||||
|
|
||||||
/* get the key */
|
/* get the key */
|
||||||
const char *key = p;
|
const char *key = p;
|
||||||
while (remaining > size && *p != '\0') {
|
const char *key_end = (const char *)memchr(p, '\0', remaining);
|
||||||
p++;
|
if (key_end == nullptr)
|
||||||
remaining--;
|
break;
|
||||||
}
|
|
||||||
p++;
|
p = key_end + 1;
|
||||||
remaining--;
|
remaining -= p - key;
|
||||||
|
|
||||||
/* get the value */
|
/* get the value */
|
||||||
if (remaining < size)
|
if (remaining < size)
|
||||||
|
@@ -82,15 +82,15 @@ riff_seek_id3(FILE *file)
|
|||||||
underflow when casting to off_t */
|
underflow when casting to off_t */
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (size % 2 != 0)
|
|
||||||
/* pad byte */
|
|
||||||
++size;
|
|
||||||
|
|
||||||
if (memcmp(chunk.id, "id3 ", 4) == 0 ||
|
if (memcmp(chunk.id, "id3 ", 4) == 0 ||
|
||||||
memcmp(chunk.id, "ID3 ", 4) == 0)
|
memcmp(chunk.id, "ID3 ", 4) == 0)
|
||||||
/* found it! */
|
/* found it! */
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
|
if (size % 2 != 0)
|
||||||
|
/* pad byte */
|
||||||
|
++size;
|
||||||
|
|
||||||
if (fseek(file, size, SEEK_CUR) != 0)
|
if (fseek(file, size, SEEK_CUR) != 0)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@@ -80,9 +80,17 @@ struct Tag {
|
|||||||
Tag &operator=(Tag &&other) {
|
Tag &operator=(Tag &&other) {
|
||||||
duration = other.duration;
|
duration = other.duration;
|
||||||
has_playlist = other.has_playlist;
|
has_playlist = other.has_playlist;
|
||||||
|
MoveItemsFrom(std::move(other));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Similar to the move operator, but move only the #TagItem
|
||||||
|
* array.
|
||||||
|
*/
|
||||||
|
void MoveItemsFrom(Tag &&other) {
|
||||||
std::swap(items, other.items);
|
std::swap(items, other.items);
|
||||||
std::swap(num_items, other.num_items);
|
std::swap(num_items, other.num_items);
|
||||||
return *this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -25,6 +25,8 @@
|
|||||||
#include "Tag.hxx"
|
#include "Tag.hxx"
|
||||||
#include "util/WritableBuffer.hxx"
|
#include "util/WritableBuffer.hxx"
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -168,12 +170,19 @@ TagBuilder::Complement(const Tag &other)
|
|||||||
|
|
||||||
has_playlist |= other.has_playlist;
|
has_playlist |= other.has_playlist;
|
||||||
|
|
||||||
|
/* build a table of tag types that were already present in
|
||||||
|
this object, which will not be copied from #other */
|
||||||
|
std::array<bool, TAG_NUM_OF_ITEM_TYPES> present;
|
||||||
|
present.fill(false);
|
||||||
|
for (const TagItem *i : items)
|
||||||
|
present[i->type] = true;
|
||||||
|
|
||||||
items.reserve(items.size() + other.num_items);
|
items.reserve(items.size() + other.num_items);
|
||||||
|
|
||||||
tag_pool_lock.lock();
|
tag_pool_lock.lock();
|
||||||
for (unsigned i = 0, n = other.num_items; i != n; ++i) {
|
for (unsigned i = 0, n = other.num_items; i != n; ++i) {
|
||||||
TagItem *item = other.items[i];
|
TagItem *item = other.items[i];
|
||||||
if (!HasType(item->type))
|
if (!present[item->type])
|
||||||
items.push_back(tag_pool_dup_item(item));
|
items.push_back(tag_pool_dup_item(item));
|
||||||
}
|
}
|
||||||
tag_pool_lock.unlock();
|
tag_pool_lock.unlock();
|
||||||
|
@@ -23,19 +23,23 @@
|
|||||||
#include "util/Cast.hxx"
|
#include "util/Cast.hxx"
|
||||||
#include "util/VarSize.hxx"
|
#include "util/VarSize.hxx"
|
||||||
|
|
||||||
|
#include <limits>
|
||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
Mutex tag_pool_lock;
|
Mutex tag_pool_lock;
|
||||||
|
|
||||||
static constexpr size_t NUM_SLOTS = 4096;
|
static constexpr size_t NUM_SLOTS = 4093;
|
||||||
|
|
||||||
struct TagPoolSlot {
|
struct TagPoolSlot {
|
||||||
TagPoolSlot *next;
|
TagPoolSlot *next;
|
||||||
unsigned char ref;
|
unsigned char ref;
|
||||||
TagItem item;
|
TagItem item;
|
||||||
|
|
||||||
|
static constexpr unsigned MAX_REF = std::numeric_limits<decltype(ref)>::max();
|
||||||
|
|
||||||
TagPoolSlot(TagPoolSlot *_next, TagType type,
|
TagPoolSlot(TagPoolSlot *_next, TagType type,
|
||||||
const char *value, size_t length)
|
const char *value, size_t length)
|
||||||
:next(_next), ref(1) {
|
:next(_next), ref(1) {
|
||||||
@@ -116,7 +120,7 @@ tag_pool_get_item(TagType type, const char *value, size_t length)
|
|||||||
if (slot->item.type == type &&
|
if (slot->item.type == type &&
|
||||||
length == strlen(slot->item.value) &&
|
length == strlen(slot->item.value) &&
|
||||||
memcmp(value, slot->item.value, length) == 0 &&
|
memcmp(value, slot->item.value, length) == 0 &&
|
||||||
slot->ref < 0xff) {
|
slot->ref < TagPoolSlot::MAX_REF) {
|
||||||
assert(slot->ref > 0);
|
assert(slot->ref > 0);
|
||||||
++slot->ref;
|
++slot->ref;
|
||||||
return &slot->item;
|
return &slot->item;
|
||||||
@@ -135,19 +139,15 @@ tag_pool_dup_item(TagItem *item)
|
|||||||
|
|
||||||
assert(slot->ref > 0);
|
assert(slot->ref > 0);
|
||||||
|
|
||||||
if (slot->ref < 0xff) {
|
if (slot->ref < TagPoolSlot::MAX_REF) {
|
||||||
++slot->ref;
|
++slot->ref;
|
||||||
return item;
|
return item;
|
||||||
} else {
|
} else {
|
||||||
/* the reference counter overflows above 0xff;
|
/* the reference counter overflows above MAX_REF;
|
||||||
duplicate the item, and start with 1 */
|
obtain a reference to a different TagPoolSlot which
|
||||||
|
isn't yet "full" */
|
||||||
size_t length = strlen(item->value);
|
size_t length = strlen(item->value);
|
||||||
auto slot_p = tag_value_slot_p(item->type,
|
return tag_pool_get_item(item->type, item->value, length);
|
||||||
item->value, length);
|
|
||||||
slot = TagPoolSlot::Create(*slot_p, item->type,
|
|
||||||
item->value, strlen(item->value));
|
|
||||||
*slot_p = slot;
|
|
||||||
return &slot->item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -40,9 +40,9 @@ FindInvalidUTF8(const char *p, const char *const end)
|
|||||||
/* now call the other SequenceLengthUTF8() overload
|
/* now call the other SequenceLengthUTF8() overload
|
||||||
which also validates the continuations */
|
which also validates the continuations */
|
||||||
const size_t t = SequenceLengthUTF8(p);
|
const size_t t = SequenceLengthUTF8(p);
|
||||||
assert(s == t);
|
|
||||||
if (t == 0)
|
if (t == 0)
|
||||||
return p;
|
return p;
|
||||||
|
assert(s == t);
|
||||||
|
|
||||||
p += s;
|
p += s;
|
||||||
}
|
}
|
||||||
|
@@ -23,7 +23,6 @@
|
|||||||
#if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__NetBSD__)
|
#if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__NetBSD__)
|
||||||
# define HAVE_THREAD_NAME
|
# define HAVE_THREAD_NAME
|
||||||
# include <pthread.h>
|
# include <pthread.h>
|
||||||
# include <stdio.h>
|
|
||||||
#elif defined(HAVE_PRCTL)
|
#elif defined(HAVE_PRCTL)
|
||||||
# include <sys/prctl.h>
|
# include <sys/prctl.h>
|
||||||
# ifdef PR_SET_NAME
|
# ifdef PR_SET_NAME
|
||||||
@@ -31,6 +30,10 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef HAVE_THREAD_NAME
|
||||||
|
# include <stdio.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
SetThreadName(const char *name)
|
SetThreadName(const char *name)
|
||||||
{
|
{
|
||||||
|
@@ -41,9 +41,13 @@ class PosixCond {
|
|||||||
pthread_cond_t cond;
|
pthread_cond_t cond;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if defined(__NetBSD__) || defined(__BIONIC__)
|
#ifdef __GLIBC__
|
||||||
/* NetBSD's PTHREAD_COND_INITIALIZER is not compatible with
|
/* optimized constexpr constructor for pthread implementations
|
||||||
"constexpr" */
|
that support it */
|
||||||
|
constexpr PosixCond():cond(PTHREAD_COND_INITIALIZER) {}
|
||||||
|
#else
|
||||||
|
/* slow fallback for pthread implementations that are not
|
||||||
|
compatible with "constexpr" */
|
||||||
PosixCond() {
|
PosixCond() {
|
||||||
pthread_cond_init(&cond, nullptr);
|
pthread_cond_init(&cond, nullptr);
|
||||||
}
|
}
|
||||||
@@ -51,10 +55,6 @@ public:
|
|||||||
~PosixCond() {
|
~PosixCond() {
|
||||||
pthread_cond_destroy(&cond);
|
pthread_cond_destroy(&cond);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
/* optimized constexpr constructor for sane POSIX
|
|
||||||
implementations */
|
|
||||||
constexpr PosixCond():cond(PTHREAD_COND_INITIALIZER) {}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PosixCond(const PosixCond &other) = delete;
|
PosixCond(const PosixCond &other) = delete;
|
||||||
|
@@ -41,9 +41,13 @@ class PosixMutex {
|
|||||||
pthread_mutex_t mutex;
|
pthread_mutex_t mutex;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#if defined(__NetBSD__) || defined(__BIONIC__)
|
#ifdef __GLIBC__
|
||||||
/* NetBSD's PTHREAD_MUTEX_INITIALIZER is not compatible with
|
/* optimized constexpr constructor for pthread implementations
|
||||||
"constexpr" */
|
that support it */
|
||||||
|
constexpr PosixMutex():mutex(PTHREAD_MUTEX_INITIALIZER) {}
|
||||||
|
#else
|
||||||
|
/* slow fallback for pthread implementations that are not
|
||||||
|
compatible with "constexpr" */
|
||||||
PosixMutex() {
|
PosixMutex() {
|
||||||
pthread_mutex_init(&mutex, nullptr);
|
pthread_mutex_init(&mutex, nullptr);
|
||||||
}
|
}
|
||||||
@@ -51,10 +55,6 @@ public:
|
|||||||
~PosixMutex() {
|
~PosixMutex() {
|
||||||
pthread_mutex_destroy(&mutex);
|
pthread_mutex_destroy(&mutex);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
/* optimized constexpr constructor for sane POSIX
|
|
||||||
implementations */
|
|
||||||
constexpr PosixMutex():mutex(PTHREAD_MUTEX_INITIALIZER) {}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
PosixMutex(const PosixMutex &other) = delete;
|
PosixMutex(const PosixMutex &other) = delete;
|
||||||
|
@@ -22,7 +22,6 @@
|
|||||||
#include "system/FatalError.hxx"
|
#include "system/FatalError.hxx"
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "fs/FileSystem.hxx"
|
#include "fs/FileSystem.hxx"
|
||||||
#include "util/Domain.hxx"
|
|
||||||
#include "PidFile.hxx"
|
#include "PidFile.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
@@ -37,8 +36,6 @@
|
|||||||
#include <grp.h>
|
#include <grp.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static constexpr Domain daemon_domain("daemon");
|
|
||||||
|
|
||||||
#ifndef WIN32
|
#ifndef WIN32
|
||||||
|
|
||||||
/** the Unix user name which MPD runs as */
|
/** the Unix user name which MPD runs as */
|
||||||
@@ -113,7 +110,7 @@ daemonize_set_user(void)
|
|||||||
(int)user_gid);
|
(int)user_gid);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef _BSD_SOURCE
|
#ifdef HAVE_INITGROUPS
|
||||||
/* init supplementary groups
|
/* init supplementary groups
|
||||||
* (must be done before we change our uid)
|
* (must be done before we change our uid)
|
||||||
*/
|
*/
|
||||||
|
@@ -17,6 +17,7 @@
|
|||||||
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include "config.h"
|
||||||
#include "Alloc.hxx"
|
#include "Alloc.hxx"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@@ -62,14 +63,14 @@ xstrdup(const char *s)
|
|||||||
char *
|
char *
|
||||||
xstrndup(const char *s, size_t n)
|
xstrndup(const char *s, size_t n)
|
||||||
{
|
{
|
||||||
#ifdef WIN32
|
#ifdef HAVE_STRNDUP
|
||||||
char *p = (char *)xalloc(n + 1);
|
|
||||||
memcpy(p, s, n);
|
|
||||||
p[n] = 0;
|
|
||||||
#else
|
|
||||||
char *p = strndup(s, n);
|
char *p = strndup(s, n);
|
||||||
if (gcc_unlikely(p == nullptr))
|
if (gcc_unlikely(p == nullptr))
|
||||||
oom();
|
oom();
|
||||||
|
#else
|
||||||
|
char *p = (char *)xalloc(n + 1);
|
||||||
|
memcpy(p, s, n);
|
||||||
|
p[n] = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
|
@@ -46,7 +46,7 @@ static size_t
|
|||||||
AlignToPageSize(size_t size)
|
AlignToPageSize(size_t size)
|
||||||
{
|
{
|
||||||
static const long page_size = sysconf(_SC_PAGESIZE);
|
static const long page_size = sysconf(_SC_PAGESIZE);
|
||||||
if (page_size > 0)
|
if (page_size == 0)
|
||||||
return size;
|
return size;
|
||||||
|
|
||||||
size_t ps(page_size);
|
size_t ps(page_size);
|
||||||
|
@@ -7,16 +7,7 @@ ExecStart=@prefix@/bin/mpd --no-daemon
|
|||||||
|
|
||||||
# allow MPD to use real-time priority 50
|
# allow MPD to use real-time priority 50
|
||||||
LimitRTPRIO=50
|
LimitRTPRIO=50
|
||||||
LimitRTTIME=-1
|
LimitRTTIME=infinity
|
||||||
|
|
||||||
# move MPD to a top-level cgroup, as real-time budget assignment fails
|
|
||||||
# in cgroup /system/mpd.service, because /system has a zero real-time
|
|
||||||
# budget; see
|
|
||||||
# http://www.freedesktop.org/wiki/Software/systemd/MyServiceCantGetRealtime/
|
|
||||||
ControlGroup=cpu:/mpd
|
|
||||||
|
|
||||||
# assign a real-time budget
|
|
||||||
ControlGroupAttribute=cpu.rt_runtime_us 500000
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
@@ -35,6 +35,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
const struct filter_plugin *
|
const struct filter_plugin *
|
||||||
filter_plugin_by_name(gcc_unused const char *name)
|
filter_plugin_by_name(gcc_unused const char *name)
|
||||||
|
Reference in New Issue
Block a user