From a2af158fd33631d201c9a519911e82ff0a47a923 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Jan 2015 17:26:50 +0100 Subject: [PATCH 01/10] configure.ac: prepare for 0.19.9 --- NEWS | 2 ++ android/AndroidManifest.xml | 4 ++-- configure.ac | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index a9eabfd8c..b20eef79d 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +ver 0.19.9 (not yet released) + ver 0.19.8 (2015/01/14) * input - curl: fix bug after rewinding from end-of-file diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index a1e045e26..208c6e1ae 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="13" + android:versionName="0.19.9"> diff --git a/configure.ac b/configure.ac index 5b4d577ae..d36afffa4 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ AC_PREREQ(2.60) -AC_INIT(mpd, 0.19.8, musicpd-dev-team@lists.sourceforge.net) +AC_INIT(mpd, 0.19.9, musicpd-dev-team@lists.sourceforge.net) VERSION_MAJOR=0 VERSION_MINOR=19 -VERSION_REVISION=8 +VERSION_REVISION=9 VERSION_EXTRA=0 AC_CONFIG_SRCDIR([src/Main.cxx]) From 384b6c82881e26b1b1995cdc6d90683b8b5c1201 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Jan 2015 17:27:19 +0100 Subject: [PATCH 02/10] doc/protocol: "playlistsearch" is case insensitive --- doc/protocol.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/protocol.xml b/doc/protocol.xml index 05468e535..839aa2d03 100644 --- a/doc/protocol.xml +++ b/doc/protocol.xml @@ -1141,7 +1141,7 @@ OK - Searches case-sensitively for partial matches in the + Searches case-insensitively for partial matches in the current playlist. From 276a0d9500b8efc879e4f0c23e9d0e361849e295 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 21 Jan 2015 20:40:56 +0100 Subject: [PATCH 03/10] thread/Name: include stdio.h if HAVE_PRCTL Caused a build failure with uClibc because snprintf() was not available. --- NEWS | 1 + src/thread/Name.hxx | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index b20eef79d..82ba78548 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ ver 0.19.9 (not yet released) +* fix build failure with uClibc ver 0.19.8 (2015/01/14) * input diff --git a/src/thread/Name.hxx b/src/thread/Name.hxx index 0fbad0fd2..a99208dab 100644 --- a/src/thread/Name.hxx +++ b/src/thread/Name.hxx @@ -23,7 +23,6 @@ #if defined(HAVE_PTHREAD_SETNAME_NP) && !defined(__NetBSD__) # define HAVE_THREAD_NAME # include -# include #elif defined(HAVE_PRCTL) # include # ifdef PR_SET_NAME @@ -31,6 +30,10 @@ # endif #endif +#ifdef HAVE_THREAD_NAME +# include +#endif + static inline void SetThreadName(const char *name) { From 212b0faf0c370968b475dbc7725e89ab2dcfb900 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 22 Jan 2015 18:51:53 +0100 Subject: [PATCH 04/10] android/build.py: use os.path.abspath() to build mpd_path Fixes a bug that occurs when runing "build.py" from inside the "android" directory. --- android/build.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/build.py b/android/build.py index 751fce167..351e881cf 100755 --- a/android/build.py +++ b/android/build.py @@ -23,7 +23,7 @@ if not os.path.isdir(ndk_path): sys.exit(1) # the path to the MPD sources -mpd_path = os.path.dirname(os.path.dirname(sys.argv[0])) or '.' +mpd_path = os.path.abspath(os.path.join(os.path.dirname(sys.argv[0]) or '.', '..')) # output directories lib_path = os.path.abspath('lib') From 645554d12f97d0d95a93ab4bddee79bee20dc4b5 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 23 Jan 2015 16:46:48 +0100 Subject: [PATCH 05/10] configure.ac: prepare for 0.18.23 --- NEWS | 2 ++ configure.ac | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/NEWS b/NEWS index e4f6fcf4e..0105b91b1 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +ver 0.18.23 (not yet released) + ver 0.18.22 (2014/01/14) * fix clang 3.6 warnings diff --git a/configure.ac b/configure.ac index e253aa52f..58ec172ea 100644 --- a/configure.ac +++ b/configure.ac @@ -1,10 +1,10 @@ AC_PREREQ(2.60) -AC_INIT(mpd, 0.18.22, mpd-devel@musicpd.org) +AC_INIT(mpd, 0.18.23, mpd-devel@musicpd.org) VERSION_MAJOR=0 VERSION_MINOR=18 -VERSION_REVISION=22 +VERSION_REVISION=23 VERSION_EXTRA=0 AC_CONFIG_SRCDIR([src/Main.cxx]) From 30cb082932b39c78cebb47f3e03cc6c1f987098c Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 23 Jan 2015 16:50:11 +0100 Subject: [PATCH 06/10] ClientProcess: cast enum to int before passing to printf() Fixes gcc5 warning. --- NEWS | 1 + src/ClientProcess.cxx | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 0105b91b1..cb08d67a2 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ ver 0.18.23 (not yet released) +* fix gcc 5.0 warnings ver 0.18.22 (2014/01/14) * fix clang 3.6 warnings diff --git a/src/ClientProcess.cxx b/src/ClientProcess.cxx index 485e687c9..d62a19466 100644 --- a/src/ClientProcess.cxx +++ b/src/ClientProcess.cxx @@ -41,7 +41,7 @@ client_process_command_list(Client &client, bool list_ok, FormatDebug(client_domain, "process command \"%s\"", cmd); ret = command_process(client, num++, cmd); - FormatDebug(client_domain, "command returned %i", ret); + FormatDebug(client_domain, "command returned %i", int(ret)); if (ret != CommandResult::OK || client.IsExpired()) break; else if (list_ok) @@ -90,7 +90,7 @@ client_process_line(Client &client, char *line) std::move(cmd_list)); FormatDebug(client_domain, "[%u] process command " - "list returned %i", client.num, ret); + "list returned %i", client.num, int(ret)); if (ret == CommandResult::CLOSE || client.IsExpired()) @@ -126,7 +126,7 @@ client_process_line(Client &client, char *line) ret = command_process(client, 0, line); FormatDebug(client_domain, "[%u] command returned %i", - client.num, ret); + client.num, int(ret)); if (ret == CommandResult::CLOSE || client.IsExpired()) From ed5c6be2f1c3fa492b3642682dd2363dbc1027df Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 23 Jan 2015 16:46:30 +0100 Subject: [PATCH 07/10] util/list: disable gcc5 warning This file has been removed in newer MPD versions, so don't care about it now. --- src/util/list.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/util/list.h b/src/util/list.h index 73d99befa..c07565cb7 100644 --- a/src/util/list.h +++ b/src/util/list.h @@ -30,6 +30,10 @@ #pragma GCC diagnostic ignored "-Wlanguage-extension-token" #endif +#if defined(__GNUC__) && __GNUC__ >= 5 +#pragma GCC diagnostic ignored "-Winvalid-offsetof" +#endif + /** * container_of - cast a member of a structure out to the containing structure * @ptr: the pointer to the member. From ad1b6ef0ac5e7c869b6adbede153e8b2ac55d708 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 26 Jan 2015 09:55:31 +0100 Subject: [PATCH 08/10] {playlist,input}/despotify: remove defunct plugin --- INSTALL | 3 - Makefile.am | 31 --- NEWS | 1 + configure.ac | 14 -- doc/mpd.conf.5 | 10 - doc/user.xml | 86 +-------- src/DespotifyUtils.cxx | 154 --------------- src/DespotifyUtils.hxx | 71 ------- src/InputRegistry.cxx | 7 - src/PlaylistRegistry.cxx | 4 - src/input/DespotifyInputPlugin.cxx | 234 ----------------------- src/input/DespotifyInputPlugin.hxx | 25 --- src/ls.cxx | 3 - src/playlist/DespotifyPlaylistPlugin.cxx | 145 -------------- src/playlist/DespotifyPlaylistPlugin.hxx | 25 --- 15 files changed, 3 insertions(+), 810 deletions(-) delete mode 100644 src/DespotifyUtils.cxx delete mode 100644 src/DespotifyUtils.hxx delete mode 100644 src/input/DespotifyInputPlugin.cxx delete mode 100644 src/input/DespotifyInputPlugin.hxx delete mode 100644 src/playlist/DespotifyPlaylistPlugin.cxx delete mode 100644 src/playlist/DespotifyPlaylistPlugin.hxx diff --git a/INSTALL b/INSTALL index 9d91ac762..aa6ecd8fa 100644 --- a/INSTALL +++ b/INSTALL @@ -114,9 +114,6 @@ For WavPack playback. libadplug - http://adplug.sourceforge.net/ For AdLib playback. -despotify - https://github.com/SimonKagstrom/despotify -For Spotify playback. - Optional Miscellaneous Dependencies ----------------------------------- diff --git a/Makefile.am b/Makefile.am index a96d69369..b30f8d915 100644 --- a/Makefile.am +++ b/Makefile.am @@ -221,11 +221,6 @@ EXTRA_src_mpd_DEPENDENCIES = src/win32/mpd_win32_rc.$(OBJEXT) src_mpd_LDFLAGS = -Wl,src/win32/mpd_win32_rc.$(OBJEXT) endif -if ENABLE_DESPOTIFY -src_mpd_SOURCES += \ - src/DespotifyUtils.cxx src/DespotifyUtils.hxx -endif - if ENABLE_INOTIFY src_mpd_SOURCES += \ src/InotifyDomain.cxx src/InotifyDomain.hxx \ @@ -770,7 +765,6 @@ libinput_a_CPPFLAGS = $(AM_CPPFLAGS) \ $(CURL_CFLAGS) \ $(CDIO_PARANOIA_CFLAGS) \ $(FFMPEG_CFLAGS) \ - $(DESPOTIFY_CFLAGS) \ $(MMS_CFLAGS) INPUT_LIBS = \ @@ -778,7 +772,6 @@ INPUT_LIBS = \ $(CURL_LIBS) \ $(CDIO_PARANOIA_LIBS) \ $(FFMPEG_LIBS) \ - $(DESPOTIFY_LIBS) \ $(MMS_LIBS) if ENABLE_CURL @@ -803,12 +796,6 @@ libinput_a_SOURCES += \ src/input/MmsInputPlugin.cxx src/input/MmsInputPlugin.hxx endif -if ENABLE_DESPOTIFY -libinput_a_SOURCES += \ - src/input/DespotifyInputPlugin.cxx \ - src/input/DespotifyInputPlugin.hxx -endif - liboutput_plugins_a_CPPFLAGS = $(AM_CPPFLAGS) \ $(AO_CFLAGS) \ @@ -989,12 +976,6 @@ PLAYLIST_LIBS = \ libplaylist_plugins.a \ $(FLAC_LIBS) -if ENABLE_DESPOTIFY -libplaylist_plugins_a_SOURCES += \ - src/playlist/DespotifyPlaylistPlugin.cxx \ - src/playlist/DespotifyPlaylistPlugin.hxx -endif - if ENABLE_SOUNDCLOUD libplaylist_plugins_a_SOURCES += \ src/playlist/SoundCloudPlaylistPlugin.cxx \ @@ -1185,10 +1166,6 @@ test_visit_archive_SOURCES = test/visit_archive.cxx \ src/IOThread.cxx \ src/InputStream.cxx -if ENABLE_DESPOTIFY -test_visit_archive_SOURCES += src/DespotifyUtils.cxx -endif - endif test_dump_text_file_LDADD = \ @@ -1313,14 +1290,6 @@ test_run_filter_SOURCES = test/run_filter.cxx \ src/ReplayGainInfo.cxx \ src/AudioCompress/compress.c -if ENABLE_DESPOTIFY -test_read_tags_SOURCES += src/DespotifyUtils.cxx -test_run_input_SOURCES += src/DespotifyUtils.cxx -test_dump_text_file_SOURCES += src/DespotifyUtils.cxx -test_dump_playlist_SOURCES += src/DespotifyUtils.cxx -test_run_decoder_SOURCES += src/DespotifyUtils.cxx -endif - if ENABLE_ENCODER noinst_PROGRAMS += test/run_encoder test_run_encoder_SOURCES = test/run_encoder.cxx \ diff --git a/NEWS b/NEWS index cb08d67a2..e7a80b964 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,5 @@ ver 0.18.23 (not yet released) +* despotify: remove defunct plugin * fix gcc 5.0 warnings ver 0.18.22 (2014/01/14) diff --git a/configure.ac b/configure.ac index 58ec172ea..276c48768 100644 --- a/configure.ac +++ b/configure.ac @@ -276,11 +276,6 @@ AC_ARG_ENABLE(jack, AC_SYS_LARGEFILE -AC_ARG_ENABLE(despotify, - AS_HELP_STRING([--enable-despotify], - [enable support for despotify (default: disable)]),, - [enable_despotify=no]) - AC_ARG_ENABLE(soundcloud, AS_HELP_STRING([--enable-soundcloud], [enable support for soundcloud.com]),, @@ -725,14 +720,6 @@ if test x$enable_curl = xyes; then fi AM_CONDITIONAL(ENABLE_CURL, test x$enable_curl = xyes) -dnl --------------------------------- Despotify --------------------------------- -MPD_AUTO_PKG(despotify, DESPOTIFY, [despotify], - [Despotify support], [despotify not found]) -if test x$enable_despotify = xyes; then - AC_DEFINE(ENABLE_DESPOTIFY, 1, [Define when despotify is enabled]) -fi -AM_CONDITIONAL(ENABLE_DESPOTIFY, test x$enable_despotify = xyes) - dnl --------------------------------- Soundcloud ------------------------------ if test x$enable_soundcloud != xno; then PKG_CHECK_MODULES([YAJL], [yajl >= 2.0], @@ -1588,7 +1575,6 @@ fi printf '\nStreaming support:\n\t' results(cdio_paranoia, [CDIO_PARANOIA]) results(curl,[CURL]) -results(despotify,[Despotify]) results(soundcloud,[Soundcloud]) printf '\n\t' results(mms,[MMS]) diff --git a/doc/mpd.conf.5 b/doc/mpd.conf.5 index 6431613d1..57b11a30f 100644 --- a/doc/mpd.conf.5 +++ b/doc/mpd.conf.5 @@ -274,16 +274,6 @@ of database. Limit the depth of the directories being watched, 0 means only watch the music directory itself. There is no limit by default. .TP -.B despotify_user -This specifies the user to use when logging in to Spotify using the despotify plugins. -.TP -.B despotify_password -This specifies the password to use when logging in to Spotify using the despotify plugins. -.TP -.B despotify_high_bitrate -This specifies if the requested bitrate for Spotify should be high or not. Higher sounds -better but requires more processing and higher bandwidth. Default is yes. -.TP .SH REQUIRED AUDIO OUTPUT PARAMETERS .TP .B type diff --git a/doc/user.xml b/doc/user.xml index 6357267e4..208e910e6 100644 --- a/doc/user.xml +++ b/doc/user.xml @@ -220,9 +220,8 @@ systemctl start mpd.socket input { - plugin "despotify" - user "foo" - password "bar" + plugin "curl" + proxy "proxy.local" } @@ -842,66 +841,6 @@ systemctl start mpd.socket - -
- <varname>despotify</varname> - - - Plays Spotify tracks using the despotify - library. The despotify plugin uses a spt:// URI and a Spotify - URL. So for example, you can add a song with: - - - - mpc add spt://spotify:track:5qENVY0YEdZ7fiuOax70x1 - - - - 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. - - - - - - - Setting - Description - - - - - - despotify_user - - - Sets up the Spotify username (required) - - - - - despotify_password - - - Sets up the Spotify password (required) - - - - - despotify_high_bitrate - - - 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). - - - - - -
@@ -2193,27 +2132,6 @@ systemctl start mpd.socket playlist files.
- -
- <varname>despotify</varname> - - - Adds Spotify - playlists. Spotify playlists use the spt:// URI, - and a Spotify playlist URL. So for example, you can load a playlist - with - - - - mpc load spt://spotify:user:simon.kagstrom:playlist:3SUwkOe5VbVHysZcidEZtH - - - - See the despotify input plugin for configuration options (username - and password needs to be setup) - -
- diff --git a/src/DespotifyUtils.cxx b/src/DespotifyUtils.cxx deleted file mode 100644 index e91587a7f..000000000 --- a/src/DespotifyUtils.cxx +++ /dev/null @@ -1,154 +0,0 @@ -/* - * Copyright (C) 2003-2013 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 "ConfigGlobal.hxx" -#include "ConfigOption.hxx" -#include "util/Domain.hxx" -#include "Log.hxx" - -extern "C" { -#include -} - -#include - -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(struct ds_track *track) -{ - char tracknum[20]; - char comment[80]; - char date[20]; - - Tag *tag = new Tag(); - - if (!track->has_meta_data) - return 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->time = track->length / 1000; - - return tag; -} - -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; -} diff --git a/src/DespotifyUtils.hxx b/src/DespotifyUtils.hxx deleted file mode 100644 index c0d4af47c..000000000 --- a/src/DespotifyUtils.hxx +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2003-2013 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 a pointer to the filled in tags structure - */ -Tag * -mpd_despotify_tag_from_track(struct 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 - diff --git a/src/InputRegistry.cxx b/src/InputRegistry.cxx index aa6c06ed1..e8a450743 100644 --- a/src/InputRegistry.cxx +++ b/src/InputRegistry.cxx @@ -42,10 +42,6 @@ #include "input/CdioParanoiaInputPlugin.hxx" #endif -#ifdef ENABLE_DESPOTIFY -#include "input/DespotifyInputPlugin.hxx" -#endif - const InputPlugin *const input_plugins[] = { &input_plugin_file, #ifdef ENABLE_ARCHIVE @@ -62,9 +58,6 @@ const InputPlugin *const input_plugins[] = { #endif #ifdef ENABLE_CDIO_PARANOIA &input_plugin_cdio_paranoia, -#endif -#ifdef ENABLE_DESPOTIFY - &input_plugin_despotify, #endif nullptr }; diff --git a/src/PlaylistRegistry.cxx b/src/PlaylistRegistry.cxx index f81978322..87ab3a4f7 100644 --- a/src/PlaylistRegistry.cxx +++ b/src/PlaylistRegistry.cxx @@ -23,7 +23,6 @@ #include "playlist/ExtM3uPlaylistPlugin.hxx" #include "playlist/M3uPlaylistPlugin.hxx" #include "playlist/XspfPlaylistPlugin.hxx" -#include "playlist/DespotifyPlaylistPlugin.hxx" #include "playlist/SoundCloudPlaylistPlugin.hxx" #include "playlist/PlsPlaylistPlugin.hxx" #include "playlist/AsxPlaylistPlugin.hxx" @@ -52,9 +51,6 @@ const struct playlist_plugin *const playlist_plugins[] = { &pls_playlist_plugin, &asx_playlist_plugin, &rss_playlist_plugin, -#ifdef ENABLE_DESPOTIFY - &despotify_playlist_plugin, -#endif #ifdef ENABLE_SOUNDCLOUD &soundcloud_playlist_plugin, #endif diff --git a/src/input/DespotifyInputPlugin.cxx b/src/input/DespotifyInputPlugin.cxx deleted file mode 100644 index b08299516..000000000 --- a/src/input/DespotifyInputPlugin.cxx +++ /dev/null @@ -1,234 +0,0 @@ -/* - * Copyright (C) 2011-2013 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 "DespotifyUtils.hxx" -#include "InputStream.hxx" -#include "InputPlugin.hxx" -#include "tag/Tag.hxx" -#include "Log.hxx" - -extern "C" { -#include -} - -#include - -#include -#include -#include - -#include - -struct DespotifyInputStream { - InputStream base; - - 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) - :base(input_plugin_despotify, 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 */ - base.mime = "audio/x-mpd-cdda-pcm"; - base.ready = true; - } - - ~DespotifyInputStream() { - delete tag; - - despotify_free_track(track); - } -}; - -static void -refill_buffer(DespotifyInputStream *ctx) -{ - /* Wait until there is data */ - while (1) { - int rc = despotify_get_pcm(ctx->session, &ctx->pcm); - - if (rc == 0 && ctx->pcm.len) { - ctx->len_available = ctx->pcm.len; - break; - } - if (ctx->eof == true) - break; - - if (rc < 0) { - LogDebug(despotify_domain, "despotify_get_pcm error"); - ctx->eof = true; - break; - } - - /* Wait a while until next iteration */ - usleep(50 * 1000); - } -} - -static void callback(gcc_unused struct despotify_session* ds, - int sig, gcc_unused void* data, void* callback_data) -{ - DespotifyInputStream *ctx = (DespotifyInputStream *)callback_data; - - switch (sig) { - case DESPOTIFY_NEW_TRACK: - break; - - case DESPOTIFY_TIME_TELL: - break; - - case DESPOTIFY_TRACK_PLAY_ERROR: - LogWarning(despotify_domain, "Track play error"); - ctx->eof = true; - ctx->len_available = 0; - break; - - case DESPOTIFY_END_OF_PLAYLIST: - ctx->eof = true; - FormatDebug(despotify_domain, "End of playlist: %d", ctx->eof); - break; - } -} - - -static InputStream * -input_despotify_open(const char *url, - Mutex &mutex, Cond &cond, - gcc_unused Error &error) -{ - struct despotify_session *session; - struct ds_link *ds_link; - struct ds_track *track; - - if (!g_str_has_prefix(url, "spt://")) - return nullptr; - - session = mpd_despotify_get_session(); - if (!session) - return nullptr; - - 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; - } - - 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->base; -} - -static size_t -input_despotify_read(InputStream *is, void *ptr, size_t size, - gcc_unused Error &error) -{ - DespotifyInputStream *ctx = (DespotifyInputStream *)is; - size_t to_cpy = size; - - if (ctx->len_available == 0) - refill_buffer(ctx); - - if (ctx->len_available < size) - to_cpy = ctx->len_available; - memcpy(ptr, ctx->pcm.buf, to_cpy); - ctx->len_available -= to_cpy; - - is->offset += to_cpy; - - return to_cpy; -} - -static void -input_despotify_close(InputStream *is) -{ - DespotifyInputStream *ctx = (DespotifyInputStream *)is; - - mpd_despotify_unregister_callback(callback); - delete ctx; -} - -static bool -input_despotify_eof(InputStream *is) -{ - DespotifyInputStream *ctx = (DespotifyInputStream *)is; - - return ctx->eof; -} - -static Tag * -input_despotify_tag(InputStream *is) -{ - DespotifyInputStream *ctx = (DespotifyInputStream *)is; - Tag *tag = ctx->tag; - - ctx->tag = nullptr; - - return tag; -} - -const InputPlugin input_plugin_despotify = { - "spt", - nullptr, - nullptr, - input_despotify_open, - input_despotify_close, - nullptr, - nullptr, - input_despotify_tag, - nullptr, - input_despotify_read, - input_despotify_eof, - nullptr, -}; diff --git a/src/input/DespotifyInputPlugin.hxx b/src/input/DespotifyInputPlugin.hxx deleted file mode 100644 index f1911f235..000000000 --- a/src/input/DespotifyInputPlugin.hxx +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2011-2013 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 diff --git a/src/ls.cxx b/src/ls.cxx index b1a636416..554aaf4d4 100644 --- a/src/ls.cxx +++ b/src/ls.cxx @@ -54,9 +54,6 @@ static const char *remoteUrlPrefixes[] = { #endif #ifdef ENABLE_CDIO_PARANOIA "cdda://", -#endif -#ifdef ENABLE_DESPOTIFY - "spt://", #endif NULL }; diff --git a/src/playlist/DespotifyPlaylistPlugin.cxx b/src/playlist/DespotifyPlaylistPlugin.cxx deleted file mode 100644 index a1a865c08..000000000 --- a/src/playlist/DespotifyPlaylistPlugin.cxx +++ /dev/null @@ -1,145 +0,0 @@ -/* - * Copyright (C) 2011-2013 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 "DespotifyUtils.hxx" -#include "PlaylistPlugin.hxx" -#include "MemorySongEnumerator.hxx" -#include "tag/Tag.hxx" -#include "Song.hxx" -#include "Log.hxx" - -extern "C" { -#include -} - -#include -#include - -static void -add_song(std::forward_list &songs, struct ds_track *track) -{ - const char *dsp_scheme = despotify_playlist_plugin.schemes[0]; - Song *song; - 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; - } - - song = Song::NewRemote(uri); - song->tag = mpd_despotify_tag_from_track(track); - - songs.emplace_front(song); -} - -static bool -parse_track(struct despotify_session *session, - std::forward_list &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 &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 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, -}; diff --git a/src/playlist/DespotifyPlaylistPlugin.hxx b/src/playlist/DespotifyPlaylistPlugin.hxx deleted file mode 100644 index c1e5b7f39..000000000 --- a/src/playlist/DespotifyPlaylistPlugin.hxx +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Copyright (C) 2011-2013 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 From 4c616626440beaedd125a788faecf06a3ebe85af Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 26 Jan 2015 20:39:45 +0100 Subject: [PATCH 09/10] test/read_mixer: add missing stdlib.h include --- test/read_mixer.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/test/read_mixer.cxx b/test/read_mixer.cxx index de77a00c4..83a1d26b4 100644 --- a/test/read_mixer.cxx +++ b/test/read_mixer.cxx @@ -35,6 +35,7 @@ #include #include #include +#include const struct filter_plugin * filter_plugin_by_name(gcc_unused const char *name) From 023b9c1e7e6792de4da0b867b6bb5d425928bd5b Mon Sep 17 00:00:00 2001 From: PHO Date: Mon, 26 Jan 2015 13:02:15 +0900 Subject: [PATCH 10/10] Test the existence of strndup(3) before using it. This can eliminate the ad-hoc "#ifdef WIN32" and can also support other platforms lacking it as well (including Darwin 9). --- NEWS | 1 + configure.ac | 1 + src/util/Alloc.cxx | 11 ++++++----- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/NEWS b/NEWS index 82ba78548..02a18fd42 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,6 @@ ver 0.19.9 (not yet released) * fix build failure with uClibc +* fix build failure on non-POSIX operating systems ver 0.19.8 (2015/01/14) * input diff --git a/configure.ac b/configure.ac index d36afffa4..199ff9896 100644 --- a/configure.ac +++ b/configure.ac @@ -206,6 +206,7 @@ if test x$host_is_linux = xyes; then fi AC_CHECK_FUNCS(getpwnam_r getpwuid_r) +AC_CHECK_FUNCS(strndup) if test x$host_is_linux = xyes; then MPD_OPTIONAL_FUNC(eventfd, eventfd, USE_EVENTFD) diff --git a/src/util/Alloc.cxx b/src/util/Alloc.cxx index ec3579470..006e09701 100644 --- a/src/util/Alloc.cxx +++ b/src/util/Alloc.cxx @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "config.h" #include "Alloc.hxx" #include @@ -62,14 +63,14 @@ xstrdup(const char *s) char * xstrndup(const char *s, size_t n) { -#ifdef WIN32 - char *p = (char *)xalloc(n + 1); - memcpy(p, s, n); - p[n] = 0; -#else +#ifdef HAVE_STRNDUP char *p = strndup(s, n); if (gcc_unlikely(p == nullptr)) oom(); +#else + char *p = (char *)xalloc(n + 1); + memcpy(p, s, n); + p[n] = 0; #endif return p;