diff --git a/packages/mpd/build.sh b/packages/mpd/build.sh new file mode 100644 index 000000000..89f5dcf42 --- /dev/null +++ b/packages/mpd/build.sh @@ -0,0 +1,51 @@ +TERMUX_PKG_HOMEPAGE="https://www.musicpd.org" +TERMUX_PKG_DESCRIPTION="music player daemon" +TERMUX_PKG_VERSION=0.20.6 +TERMUX_PKG_SRCURL=https://github.com/MusicPlayerDaemon/MPD/archive/v$TERMUX_PKG_VERSION.tar.gz +TERMUX_PKG_FOLDERNAME=MPD-$TERMUX_PKG_VERSION +TERMUX_PKG_SHA256=42729305dbafb912bb9197698822b112aa78ab691f87433e37c511ce91ce0a0d +TERMUX_PKG_DEPENDS="libcurl, libid3tag, libopus, libevent, fftw, libpulseaudio, libmpdclient, boost, openal-soft, libvorbis, libsqlite, ffmpeg" +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" --disable-sndio --disable-alsa --disable-ao --disable-mad --without-tremor --disable-epoll --disable-iconv --disable-icu" +TERMUX_PKG_BUILD_IN_SRC=yes +TERMUX_PKG_CONFFILES="$TERMUX_PREFIX/etc/mpd.conf" +termux_step_pre_configure() { + CXXFLAGS+=" -DTERMUX -UANDROID" + LDFLAGS+=" -llog -lOpenSLES" + NOCONFIGURE=1 ./autogen.sh + rm -f /data/data/com.termux/files/usr/etc/mpd.conf +} +termux_step_make_install () { + # Try to work around OpenSL ES library clashes: + # Linking against libOpenSLES causes indirect linkage against + # libskia.so, which links against the platform libjpeg.so and + # libpng.so, which are not compatible with the Termux ones. + # + # On Android N also liblzma seems to conflict. + make install + cp -f $TERMUX_PREFIX/share/doc/mpd/mpdconf.example /data/data/com.termux/files/usr/etc/mpd.conf + mkdir -p $TERMUX_PREFIX/libexec + mkdir -p $TERMUX_PREFIX/var/mpd + mv $TERMUX_PREFIX/bin/mpd $TERMUX_PREFIX/libexec + local SYSTEM_LIBFOLDER=lib64 + if [ $TERMUX_ARCH_BITS = 32 ]; then SYSTEM_LIBFOLDER=lib; fi + + echo "#!/bin/sh" > $TERMUX_PREFIX/bin/mpd + cat $TERMUX_SCRIPTDIR/packages/mpd/mpd-script.sh >> $TERMUX_PREFIX/bin/mpd + # Work around issues on devices having ffmpeg libraries + # in a system vendor dir, reported by live_the_dream on #termux: + local FFMPEG_LIBS="" lib + # gnustl_shared needs to go first in every c++ app that uses audio directly. + for lib in gnustl_shared curl ssl event opus vorbis avcodec avfilter avformat avutil postproc swresample swscale sqlite3; do + if [ -n "$FFMPEG_LIBS" ]; then FFMPEG_LIBS+=":"; fi + FFMPEG_LIBS+="$TERMUX_PREFIX/lib/lib${lib}.so" + done + echo "export LD_PRELOAD=$FFMPEG_LIBS" >> $TERMUX_PREFIX/bin/mpd + chmod +x $TERMUX_PREFIX/bin/mpd + # /system/vendor/lib(64) needed for libqc-opt.so on + # a xperia z5 c, reported by BrainDamage on #termux: + echo "LD_LIBRARY_PATH=/system/$SYSTEM_LIBFOLDER:/system/vendor/$SYSTEM_LIBFOLDER:$TERMUX_PREFIX/lib exec $TERMUX_PREFIX/libexec/mpd \"\$@\"" >> $TERMUX_PREFIX/bin/mpd + +} +termux_step_create_debscripts() { +echo 'mkdir -p $HOME/.mpd/playlists' >> postinst +} diff --git a/packages/mpd/configure.ac.patch b/packages/mpd/configure.ac.patch new file mode 100644 index 000000000..2adbb8ded --- /dev/null +++ b/packages/mpd/configure.ac.patch @@ -0,0 +1,20 @@ +--- ../cache/MPD-0.20.6/configure.ac 2017-03-10 15:57:59.000000000 +0000 ++++ ./configure.ac 2017-05-13 01:18:13.566696356 +0000 +@@ -97,7 +97,7 @@ + + case "$host_os" in + linux-android*) +- host_is_android=yes ++ host_is_android=no + host_is_linux=yes + linux_auto=auto + AM_CPPFLAGS="$AM_CPPFLAGS -DANDROID" +@@ -196,7 +196,7 @@ + fi + fi + +-AC_SUBST(ANDROID_SDK, [$with_android_sdk]) ++#AC_SUBST(ANDROID_SDK, [$with_android_sdk]) + + dnl --------------------------------------------------------------------------- + dnl Language Checks diff --git a/packages/mpd/makefile.am.patch b/packages/mpd/makefile.am.patch new file mode 100644 index 000000000..c7386101f --- /dev/null +++ b/packages/mpd/makefile.am.patch @@ -0,0 +1,18 @@ +--- ../cache/MPD-0.20.6/Makefile.am 2017-03-10 15:57:59.000000000 +0000 ++++ ./Makefile.am 2017-05-13 03:28:47.725309586 +0000 +@@ -1481,7 +1481,14 @@ + if HAVE_OPENAL + liboutput_plugins_a_SOURCES += \ + src/output/plugins/OpenALOutputPlugin.cxx \ +- src/output/plugins/OpenALOutputPlugin.hxx ++ src/output/plugins/OpenALOutputPlugin.hxx \ ++ src/output/plugins/sles/Object.hxx \ ++ src/output/plugins/sles/Engine.hxx \ ++ src/output/plugins/sles/Play.hxx \ ++ src/output/plugins/sles/AndroidSimpleBufferQueue.hxx \ ++ src/output/plugins/sles/SlesOutputPlugin.cxx \ ++ src/output/plugins/sles/SlesOutputPlugin.hxx ++OUTPUT_LIBS += -lOpenSLES + endif + + if HAVE_OSX diff --git a/packages/mpd/mpd-script.sh b/packages/mpd/mpd-script.sh new file mode 100644 index 000000000..97a472519 --- /dev/null +++ b/packages/mpd/mpd-script.sh @@ -0,0 +1,29 @@ +mpd_test=$(pgrep -f /data/data/com.termux/files/usr/libexec/mpd) +CmdArgs=$(echo "$@") +#echo $mpd_test +mkdir -p ~/music +mkdir -p ~/.mpd +mkdir -p ~/.mpd/playlists +touch ~/.mpd/state +touch ~/.mpd/log +touch ~/.mpd/pid +if [ "x$CmdArgs" = x ] ; then + if [ -z "$MULTIPLE_MPDS" ] ; then + if [ -n "$mpd_test" ] ; then + echo -n "restart music player daemon (y/n)? " + read answer + if echo "$answer" | grep -iq "^y" ;then + echo "restarting music player daemon" + pgrep -f /data/data/com.termux/files/usr/libexec/mpd | while read line; do kill "$line"; done + else + echo "doing nothing" + exit + fi + else + echo "starting mpd the music player daemon" + fi + sleep 0.5; + chmod +rw ~/.mpd/* 2>&1 > /dev/null + rm -rf ~/.mpd/pid 2>&1 > /dev/null + fi +fi diff --git a/packages/mpd/mpdconf.example.patch b/packages/mpd/mpdconf.example.patch new file mode 100644 index 000000000..6dd1fd4e3 --- /dev/null +++ b/packages/mpd/mpdconf.example.patch @@ -0,0 +1,201 @@ +--- ../cache/MPD-0.20.6/doc/mpdconf.example 2017-03-10 15:57:59.000000000 +0000 ++++ ./doc/mpdconf.example 2017-05-17 07:48:09.273191173 +0000 +@@ -10,14 +10,14 @@ + # be disabled and audio files will only be accepted over ipc socket (using + # file:// protocol) or streaming files over an accepted protocol. + # +-#music_directory "~/music" ++music_directory "/sdcard/Music" + # + # This setting sets the MPD internal playlist directory. The purpose of this + # directory is storage for playlists created by MPD. The server will use + # playlist files not created by the server but only if they are in the MPD + # format. This setting defaults to playlist saving being disabled. + # +-#playlist_directory "~/.mpd/playlists" ++playlist_directory "~/.mpd/playlists" + # + # This setting sets the location of the MPD database. This file is used to + # load the database at server start up and store the database while the +@@ -25,7 +25,7 @@ + # MPD to accept files over ipc socket (using file:// protocol) or streaming + # files over an accepted protocol. + # +-#db_file "~/.mpd/database" ++db_file "~/.mpd/database" + # + # These settings are the locations for the daemon log files for the daemon. + # These logs are great for troubleshooting, depending on your log_level +@@ -34,25 +34,25 @@ + # The special value "syslog" makes MPD use the local syslog daemon. This + # setting defaults to logging to syslog, otherwise logging is disabled. + # +-#log_file "~/.mpd/log" ++#log_file "/data/data/com.termux/files/home/.mpd/log" + # + # This setting sets the location of the file which stores the process ID + # for use of mpd --kill and some init scripts. This setting is disabled by + # default and the pid file will not be stored. + # +-#pid_file "~/.mpd/pid" ++pid_file "~/.mpd/pid" + # + # This setting sets the location of the file which contains information about + # most variables to get MPD back into the same general shape it was in before + # it was brought down. This setting is disabled by default and the server + # state will be reset on server start up. + # +-#state_file "~/.mpd/state" ++state_file "~/.mpd/state" + # + # The location of the sticker database. This is a database which + # manages dynamic information attached to songs. + # +-#sticker_file "~/.mpd/sticker.sql" ++sticker_file "~/.mpd/sticker.sql" + # + ############################################################################### + +@@ -77,17 +77,18 @@ + # should be paid if this is assigned to anything other then the default, any. + # This setting can deny access to control of the daemon. Not effective if + # systemd socket activiation is in use. +-# ++# For local connections only ++#bind_to_address "localhost" + # For network + #bind_to_address "any" + # + # And for Unix Socket +-#bind_to_address "~/.mpd/socket" ++bind_to_address "/data/data/com.termux/files/usr/tmp/mpd.socket" + # + # This setting is the TCP port that is desired for the daemon to get assigned +-# to. ++# to. Normally this is 6600 but for termux this port needs to be above 8000. + # +-#port "6600" ++#port "8600" + # + # This setting controls the type of information which is logged. Available + # setting arguments are "default", "secure" or "verbose". The "verbose" setting +@@ -137,12 +138,12 @@ + # If this setting is set to "yes", MPD will discover audio files by following + # symbolic links outside of the configured music_directory. + # +-#follow_outside_symlinks "yes" ++follow_outside_symlinks "yes" + # + # If this setting is set to "yes", MPD will discover audio files by following + # symbolic links inside of the configured music_directory. + # +-#follow_inside_symlinks "yes" ++follow_inside_symlinks "yes" + # + ############################################################################### + +@@ -205,28 +206,6 @@ + # blocks. Setting this block is optional, though the server will only attempt + # autodetection for one sound card. + # +-# An example of an ALSA output: +-# +-#audio_output { +-# type "alsa" +-# name "My ALSA Device" +-## device "hw:0,0" # optional +-## mixer_type "hardware" # optional +-## mixer_device "default" # optional +-## mixer_control "PCM" # optional +-## mixer_index "0" # optional +-#} +-# +-# An example of an OSS output: +-# +-#audio_output { +-# type "oss" +-# name "My OSS Device" +-## device "/dev/dsp" # optional +-## mixer_type "hardware" # optional +-## mixer_device "/dev/mixer" # optional +-## mixer_control "PCM" # optional +-#} + # + # An example of a shout output (for streaming to Icecast): + # +@@ -257,7 +236,8 @@ + # type "recorder" + # name "My recorder" + # encoder "vorbis" # optional, vorbis or lame +-# path "/var/lib/mpd/recorder/mpd.ogg" ++## for termux changed "path" to somewhere on android that works ++# path "~/mpd.ogg" + ## quality "5.0" # do not define if bitrate is defined + # bitrate "128" # do not define if quality is defined + # format "44100:16:1" +@@ -286,41 +266,34 @@ + ## sink "remote_server_sink" # optional + #} + # +-# An example of a winmm output (Windows multimedia API). +-# +-#audio_output { +-# type "winmm" +-# name "My WinMM output" +-## device "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional +-# or +-## device "0" # optional +-## mixer_type "hardware" # optional +-#} ++ ++# An example of an opensl android output. ++audio_output { ++ type "sles" ++ name "OpenSLES output" ++ mixer_type "software" ++} ++ + # + # An example of an openal output. + # +-#audio_output { +-# type "openal" +-# name "My OpenAL output" +-## device "Digital Audio (S/PDIF) (High Definition Audio Device)" # optional +-#} +-# +-# An example of an sndio output. +-# +-#audio_output { +-# type "sndio" +-# name "sndio output" +-# mixer_type "software" +-#} +-# +-# An example of an OS X output: ++audio_output { ++ type "openal" ++ name "OpenAL output" ++ mixer_type "software" ++ device "OpenSL" ++ enabled "no" ++} ++#Fifo output for visualizations in ncmpcpp-git ++ audio_output { ++ type "fifo" ++ name "ncmpcpp visualizer" ++ path "~/../usr/tmp/mpd.fifo" ++ format "44100:16:1" ++ enabled "no" ++} ++ + # +-#audio_output { +-# type "osx" +-# name "My OS X Device" +-## device "Built-in Output" # optional +-## channel_map "-1,-1,0,1" # optional +-#} + # + ## Example "pipe" output: + # diff --git a/packages/mpd/registry.cxx.patch b/packages/mpd/registry.cxx.patch new file mode 100644 index 000000000..b13fc54d0 --- /dev/null +++ b/packages/mpd/registry.cxx.patch @@ -0,0 +1,11 @@ +--- ../cache/MPD-0.20.6/src/output/Registry.cxx 2017-03-10 15:57:59.000000000 +0000 ++++ ./src/output/Registry.cxx 2017-05-13 03:07:25.443629772 +0000 +@@ -47,7 +47,7 @@ + &shout_output_plugin, + #endif + &null_output_plugin, +-#ifdef ANDROID ++#if defined(ANDROID) || defined(TERMUX) + &sles_output_plugin, + #endif + #ifdef HAVE_FIFO