Compare commits
47 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4a5528697d | ||
![]() |
5489dec28d | ||
![]() |
a4f4fc50b9 | ||
![]() |
ad1b6ef0ac | ||
![]() |
ed5c6be2f1 | ||
![]() |
30cb082932 | ||
![]() |
645554d12f | ||
![]() |
8534f2d1e2 | ||
![]() |
665031467a | ||
![]() |
df33171107 | ||
![]() |
53f4044890 | ||
![]() |
a5049136ff | ||
![]() |
705b3c6b63 | ||
![]() |
6b4ac66962 | ||
![]() |
0964b06240 | ||
![]() |
92eeca3ba7 | ||
![]() |
2a86554ac4 | ||
![]() |
805caa30ce | ||
![]() |
acb798e544 | ||
![]() |
773de38bd9 | ||
![]() |
fa4beeee75 | ||
![]() |
d8351772d3 | ||
![]() |
1b5f33a435 | ||
![]() |
41b4a63f2b | ||
![]() |
d8fc2db910 | ||
![]() |
dc11dea7cc | ||
![]() |
04f627c2af | ||
![]() |
a254f5a3a8 | ||
![]() |
143c735f96 | ||
![]() |
7aa2104596 | ||
![]() |
c8b93d6573 | ||
![]() |
3f5f96ac91 | ||
![]() |
7e7b403043 | ||
![]() |
c64ad78c7b | ||
![]() |
4a043a915f | ||
![]() |
38a0d15190 | ||
![]() |
ec3191f502 | ||
![]() |
32b5654a6e | ||
![]() |
674091424e | ||
![]() |
6ad336743d | ||
![]() |
c882568ccd | ||
![]() |
f6b2899dd2 | ||
![]() |
bccd4ef2f7 | ||
![]() |
94c240a026 | ||
![]() |
c50a0cf7bf | ||
![]() |
c37f7abb79 | ||
![]() |
432ce9b1de |
INSTALLMakefile.amNEWSconfigure.ac
doc
m4
src
Client.hxxClientFile.cxxClientProcess.cxxCompiler.hDatabaseGlue.cxxDecoderPlugin.cxxDecoderThread.cxxDespotifyUtils.cxxDespotifyUtils.hxxDirectory.cxxInputRegistry.cxxInputStream.cxxPlaylistFile.cxxPlaylistRegistry.cxxSongFilter.cxx
archive
db
decoder
event
filter
ChainFilterPlugin.cxxNormalizeFilterPlugin.cxxReplayGainFilterPlugin.cxxRouteFilterPlugin.cxxVolumeFilterPlugin.cxx
fs
input
ls.cxxoutput
playlist
DespotifyPlaylistPlugin.cxxDespotifyPlaylistPlugin.hxxEmbeddedCuePlaylistPlugin.cxxExtM3uPlaylistPlugin.cxxM3uPlaylistPlugin.cxx
system
tag
thread
util
test
3
INSTALL
3
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
|
||||
-----------------------------------
|
||||
|
31
Makefile.am
31
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 \
|
||||
|
38
NEWS
38
NEWS
@@ -1,3 +1,41 @@
|
||||
ver 0.18.23 (2015/02/06)
|
||||
* despotify: remove defunct plugin
|
||||
* fix clock integer overflow on OS X
|
||||
* fix gcc 5.0 warnings
|
||||
|
||||
ver 0.18.22 (2015/01/14)
|
||||
* fix clang 3.6 warnings
|
||||
|
||||
ver 0.18.21 (2014/12/17)
|
||||
* playlist
|
||||
- embcue: fix filename suffix detection
|
||||
* decoder
|
||||
- ffmpeg: fix time stamp underflow
|
||||
|
||||
ver 0.18.20 (2014/12/08)
|
||||
* decoder
|
||||
- ffmpeg: support FFmpeg 2.5
|
||||
* fix build failure with musl
|
||||
|
||||
ver 0.18.19 (2014/11/26)
|
||||
* archive
|
||||
- zzip: fix crash after seeking
|
||||
|
||||
ver 0.18.18 (2014/11/18)
|
||||
* decoder
|
||||
- ffmpeg: support opus
|
||||
* fix crash on failed filename charset conversion
|
||||
* fix local socket detection from uid=0 (root)
|
||||
|
||||
ver 0.18.17 (2014/11/02)
|
||||
* playlist
|
||||
- don't allow empty playlist name
|
||||
- m3u: recognize the file suffix ".m3u8"
|
||||
* decoder
|
||||
- ignore URI query string for plugin detection
|
||||
- faad: remove workaround for ancient libfaad2 ABI bug
|
||||
- ffmpeg: recognize MIME type audio/aacp
|
||||
|
||||
ver 0.18.16 (2014/09/26)
|
||||
* fix DSD breakage due to typo in configure.ac
|
||||
|
||||
|
19
configure.ac
19
configure.ac
@@ -1,10 +1,10 @@
|
||||
AC_PREREQ(2.60)
|
||||
|
||||
AC_INIT(mpd, 0.18.16, mpd-devel@musicpd.org)
|
||||
AC_INIT(mpd, 0.18.23, mpd-devel@musicpd.org)
|
||||
|
||||
VERSION_MAJOR=0
|
||||
VERSION_MINOR=18
|
||||
VERSION_REVISION=0
|
||||
VERSION_REVISION=23
|
||||
VERSION_EXTRA=0
|
||||
|
||||
AC_CONFIG_SRCDIR([src/Main.cxx])
|
||||
@@ -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],
|
||||
@@ -1523,6 +1510,7 @@ results(un,[UNIX Domain Sockets])
|
||||
printf '\nFile format support:\n\t'
|
||||
results(aac, [AAC])
|
||||
results(adplug, [AdPlug])
|
||||
results(dsd, [DSD])
|
||||
results(sidplay, [C64 SID])
|
||||
results(ffmpeg, [FFMPEG])
|
||||
results(flac, [FLAC])
|
||||
@@ -1587,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])
|
||||
|
@@ -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 <name>
|
||||
This specifies the user to use when logging in to Spotify using the despotify plugins.
|
||||
.TP
|
||||
.B despotify_password <name>
|
||||
This specifies the password to use when logging in to Spotify using the despotify plugins.
|
||||
.TP
|
||||
.B despotify_high_bitrate <yes or no>
|
||||
This specifies if the requested bitrate for Spotify should be high or not. Higher sounds
|
||||
better but requires more processing and higher bandwidth. Default is yes.
|
||||
.TP
|
||||
.SH REQUIRED AUDIO OUTPUT PARAMETERS
|
||||
.TP
|
||||
.B type <type>
|
||||
|
86
doc/user.xml
86
doc/user.xml
@@ -220,9 +220,8 @@ systemctl start mpd.socket</programlisting>
|
||||
</para>
|
||||
|
||||
<programlisting>input {
|
||||
plugin "despotify"
|
||||
user "foo"
|
||||
password "bar"
|
||||
plugin "curl"
|
||||
proxy "proxy.local"
|
||||
}
|
||||
</programlisting>
|
||||
|
||||
@@ -842,66 +841,6 @@ systemctl start mpd.socket</programlisting>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title><varname>despotify</varname></title>
|
||||
|
||||
<para>
|
||||
Plays <ulink url="http://www.spotify.com">Spotify</ulink> tracks using the despotify
|
||||
library. The despotify plugin uses a <filename>spt://</filename> URI and a Spotify
|
||||
URL. So for example, you can add a song with:
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<filename>mpc add spt://spotify:track:5qENVY0YEdZ7fiuOax70x1</filename>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
You need a Spotify premium account to use this plugin, and you need
|
||||
to setup username and password in the configuration file. The
|
||||
configuration settings are global since the despotify playlist plugin
|
||||
use the same settings.
|
||||
</para>
|
||||
|
||||
<informaltable>
|
||||
<tgroup cols="2">
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Setting</entry>
|
||||
<entry>Description</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>
|
||||
<varname>despotify_user</varname>
|
||||
</entry>
|
||||
<entry>
|
||||
Sets up the Spotify username (required)
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<varname>despotify_password</varname>
|
||||
</entry>
|
||||
<entry>
|
||||
Sets up the Spotify password (required)
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>
|
||||
<varname>despotify_high_bitrate</varname>
|
||||
</entry>
|
||||
<entry>
|
||||
Set up if high bitrate should be used for Spotify tunes.
|
||||
High bitrate sounds better but slow systems can have problems
|
||||
with playback (default yes).
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
@@ -2193,27 +2132,6 @@ systemctl start mpd.socket</programlisting>
|
||||
playlist files.
|
||||
</para>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<title><varname>despotify</varname></title>
|
||||
|
||||
<para>
|
||||
Adds <ulink url="http://www.spotify.com/">Spotify</ulink>
|
||||
playlists. Spotify playlists use the <filename>spt://</filename> URI,
|
||||
and a Spotify playlist URL. So for example, you can load a playlist
|
||||
with
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<filename>mpc load spt://spotify:user:simon.kagstrom:playlist:3SUwkOe5VbVHysZcidEZtH</filename>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
See the despotify input plugin for configuration options (username
|
||||
and password needs to be setup)
|
||||
</para>
|
||||
</section>
|
||||
|
||||
</section>
|
||||
</chapter>
|
||||
</book>
|
||||
|
31
m4/faad.m4
31
m4/faad.m4
@@ -62,36 +62,7 @@ int main() {
|
||||
CPPFLAGS=$oldcppflags
|
||||
fi
|
||||
|
||||
if test x$enable_aac = xyes; then
|
||||
oldcflags=$CFLAGS
|
||||
oldlibs=$LIBS
|
||||
oldcppflags=$CPPFLAGS
|
||||
CFLAGS="$CFLAGS $FAAD_CFLAGS -Werror"
|
||||
LIBS="$LIBS $FAAD_LIBS"
|
||||
CPPFLAGS=$CFLAGS
|
||||
|
||||
AC_MSG_CHECKING(for broken libfaad headers)
|
||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
||||
#include <faad.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main() {
|
||||
unsigned char channels;
|
||||
uint32_t sample_rate;
|
||||
|
||||
NeAACDecInit2(NULL, NULL, 0, &sample_rate, &channels);
|
||||
return 0;
|
||||
}
|
||||
])],
|
||||
[AC_MSG_RESULT(correct)],
|
||||
[AC_MSG_RESULT(broken);
|
||||
AC_DEFINE(HAVE_FAAD_LONG, 1, [Define if faad.h uses the broken "unsigned long" pointers])])
|
||||
|
||||
CFLAGS=$oldcflags
|
||||
LIBS=$oldlibs
|
||||
CPPFLAGS=$oldcppflags
|
||||
else
|
||||
if test x$enable_aac = xno; then
|
||||
FAAD_LIBS=""
|
||||
FAAD_CFLAGS=""
|
||||
fi
|
||||
|
@@ -109,7 +109,7 @@ public:
|
||||
* a local (UNIX domain) socket?
|
||||
*/
|
||||
bool IsLocal() const {
|
||||
return uid > 0;
|
||||
return uid >= 0;
|
||||
}
|
||||
|
||||
unsigned GetPermission() const {
|
||||
|
@@ -47,7 +47,7 @@ client_allow_file(const Client &client, Path path_fs, Error &error)
|
||||
instance */
|
||||
return true;
|
||||
|
||||
if (uid <= 0) {
|
||||
if (uid < 0) {
|
||||
/* unauthenticated client */
|
||||
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
|
||||
return false;
|
||||
|
@@ -41,7 +41,7 @@ client_process_command_list(Client &client, bool list_ok,
|
||||
|
||||
FormatDebug(client_domain, "process command \"%s\"", cmd);
|
||||
ret = command_process(client, num++, cmd);
|
||||
FormatDebug(client_domain, "command returned %i", ret);
|
||||
FormatDebug(client_domain, "command returned %i", int(ret));
|
||||
if (ret != CommandResult::OK || client.IsExpired())
|
||||
break;
|
||||
else if (list_ok)
|
||||
@@ -90,7 +90,7 @@ client_process_line(Client &client, char *line)
|
||||
std::move(cmd_list));
|
||||
FormatDebug(client_domain,
|
||||
"[%u] process command "
|
||||
"list returned %i", client.num, ret);
|
||||
"list returned %i", client.num, int(ret));
|
||||
|
||||
if (ret == CommandResult::CLOSE ||
|
||||
client.IsExpired())
|
||||
@@ -126,7 +126,7 @@ client_process_line(Client &client, char *line)
|
||||
ret = command_process(client, 0, line);
|
||||
FormatDebug(client_domain,
|
||||
"[%u] command returned %i",
|
||||
client.num, ret);
|
||||
client.num, int(ret));
|
||||
|
||||
if (ret == CommandResult::CLOSE ||
|
||||
client.IsExpired())
|
||||
|
@@ -20,33 +20,45 @@
|
||||
#ifndef COMPILER_H
|
||||
#define COMPILER_H
|
||||
|
||||
#define GCC_CHECK_VERSION(major, minor) \
|
||||
(defined(__GNUC__) && \
|
||||
(__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
|
||||
#define GCC_MAKE_VERSION(major, minor, patchlevel) ((major) * 10000 + (minor) * 100 + patchlevel)
|
||||
|
||||
#ifdef __GNUC__
|
||||
#define GCC_VERSION (__GNUC__ * 10000 \
|
||||
+ __GNUC_MINOR__ * 100 \
|
||||
+ __GNUC_PATCHLEVEL__)
|
||||
#define GCC_VERSION GCC_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
|
||||
#else
|
||||
#define GCC_VERSION 0
|
||||
#endif
|
||||
|
||||
#define GCC_CHECK_VERSION(major, minor) \
|
||||
(defined(__GNUC__) && GCC_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
|
||||
|
||||
/**
|
||||
* Are we building with gcc (not clang or any other compiler) and a
|
||||
* version older than the specified one?
|
||||
*/
|
||||
#define GCC_OLDER_THAN(major, minor) \
|
||||
(defined(__GNUC__) && !defined(__clang__) && \
|
||||
GCC_VERSION < GCC_MAKE_VERSION(major, minor, 0))
|
||||
|
||||
#ifdef __clang__
|
||||
# define CLANG_VERSION (__clang_major__ * 10000 \
|
||||
+ __clang_minor__ * 100 \
|
||||
+ __clang_patchlevel__)
|
||||
# define CLANG_VERSION GCC_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
|
||||
# if __clang_major__ < 3
|
||||
# error Sorry, your clang version is too old. You need at least version 3.1.
|
||||
# endif
|
||||
#elif defined(__GNUC__)
|
||||
# if !GCC_CHECK_VERSION(4,6)
|
||||
# if GCC_OLDER_THAN(4,6)
|
||||
# error Sorry, your gcc version is too old. You need at least version 4.6.
|
||||
# endif
|
||||
#else
|
||||
# warning Untested compiler. Use at your own risk!
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Are we building with the specified version of clang or newer?
|
||||
*/
|
||||
#define CLANG_CHECK_VERSION(major, minor) \
|
||||
(defined(__clang__) && \
|
||||
CLANG_VERSION >= GCC_MAKE_VERSION(major, minor, 0))
|
||||
|
||||
#if GCC_CHECK_VERSION(4,0)
|
||||
|
||||
/* GCC 4.x */
|
||||
@@ -141,7 +153,7 @@
|
||||
#if defined(__cplusplus)
|
||||
|
||||
/* support for C++11 "override" was added in gcc 4.7 */
|
||||
#if !defined(__clang__) && !GCC_CHECK_VERSION(4,7)
|
||||
#if GCC_OLDER_THAN(4,7)
|
||||
#define override
|
||||
#define final
|
||||
#endif
|
||||
|
@@ -112,13 +112,15 @@ db_get_root(void)
|
||||
Directory *
|
||||
db_get_directory(const char *name)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(name != nullptr);
|
||||
#endif
|
||||
|
||||
if (db == nullptr)
|
||||
return nullptr;
|
||||
|
||||
Directory *music_root = db_get_root();
|
||||
if (name == nullptr)
|
||||
return music_root;
|
||||
|
||||
return music_root->LookupDirectory(name);
|
||||
}
|
||||
|
||||
|
@@ -26,7 +26,10 @@
|
||||
bool
|
||||
DecoderPlugin::SupportsSuffix(const char *suffix) const
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(suffix != nullptr);
|
||||
#endif
|
||||
|
||||
return suffixes != nullptr && string_array_contains(suffixes, suffix);
|
||||
|
||||
@@ -35,7 +38,10 @@ DecoderPlugin::SupportsSuffix(const char *suffix) const
|
||||
bool
|
||||
DecoderPlugin::SupportsMimeType(const char *mime_type) const
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(mime_type != nullptr);
|
||||
#endif
|
||||
|
||||
return mime_types != nullptr &&
|
||||
string_array_contains(mime_types, mime_type);
|
||||
|
@@ -212,7 +212,8 @@ static bool
|
||||
decoder_run_stream_locked(Decoder &decoder, InputStream &is,
|
||||
const char *uri, bool &tried_r)
|
||||
{
|
||||
const char *const suffix = uri_get_suffix(uri);
|
||||
UriSuffixBuffer suffix_buffer;
|
||||
const char *const suffix = uri_get_suffix(uri, suffix_buffer);
|
||||
|
||||
using namespace std::placeholders;
|
||||
const auto f = std::bind(decoder_run_stream_plugin,
|
||||
|
@@ -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 <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(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;
|
||||
}
|
@@ -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
|
||||
|
@@ -40,7 +40,10 @@ extern "C" {
|
||||
inline Directory *
|
||||
Directory::Allocate(const char *path)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(path != nullptr);
|
||||
#endif
|
||||
|
||||
const size_t path_size = strlen(path) + 1;
|
||||
Directory *directory =
|
||||
|
@@ -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
|
||||
};
|
||||
|
@@ -155,7 +155,10 @@ InputStream::IsAvailable()
|
||||
size_t
|
||||
InputStream::Read(void *ptr, size_t _size, Error &error)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(ptr != nullptr);
|
||||
#endif
|
||||
assert(_size > 0);
|
||||
|
||||
return plugin.read(this, ptr, _size, error);
|
||||
@@ -164,7 +167,10 @@ InputStream::Read(void *ptr, size_t _size, Error &error)
|
||||
size_t
|
||||
InputStream::LockRead(void *ptr, size_t _size, Error &error)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(ptr != nullptr);
|
||||
#endif
|
||||
assert(_size > 0);
|
||||
|
||||
const ScopeLock protect(mutex);
|
||||
|
@@ -69,6 +69,10 @@ spl_global_init(void)
|
||||
bool
|
||||
spl_valid_name(const char *name_utf8)
|
||||
{
|
||||
if (*name_utf8 == 0)
|
||||
/* empty name not allowed */
|
||||
return false;
|
||||
|
||||
/*
|
||||
* Not supporting '/' was done out of laziness, and we should
|
||||
* really strive to support it in the future.
|
||||
|
@@ -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
|
||||
@@ -164,12 +160,12 @@ static SongEnumerator *
|
||||
playlist_list_open_uri_suffix(const char *uri, Mutex &mutex, Cond &cond,
|
||||
const bool *tried)
|
||||
{
|
||||
const char *suffix;
|
||||
SongEnumerator *playlist = nullptr;
|
||||
|
||||
assert(uri != nullptr);
|
||||
|
||||
suffix = uri_get_suffix(uri);
|
||||
UriSuffixBuffer suffix_buffer;
|
||||
const char *const suffix = uri_get_suffix(uri, suffix_buffer);
|
||||
if (suffix == nullptr)
|
||||
return nullptr;
|
||||
|
||||
@@ -273,8 +269,6 @@ playlist_list_open_stream_suffix(InputStream &is, const char *suffix)
|
||||
SongEnumerator *
|
||||
playlist_list_open_stream(InputStream &is, const char *uri)
|
||||
{
|
||||
const char *suffix;
|
||||
|
||||
is.LockWaitReady();
|
||||
|
||||
const char *const mime = is.GetMimeType();
|
||||
@@ -284,7 +278,10 @@ playlist_list_open_stream(InputStream &is, const char *uri)
|
||||
return playlist;
|
||||
}
|
||||
|
||||
suffix = uri != nullptr ? uri_get_suffix(uri) : nullptr;
|
||||
UriSuffixBuffer suffix_buffer;
|
||||
const char *suffix = uri != nullptr
|
||||
? uri_get_suffix(uri, suffix_buffer)
|
||||
: nullptr;
|
||||
if (suffix != nullptr) {
|
||||
auto playlist = playlist_list_open_stream_suffix(is, suffix);
|
||||
if (playlist != nullptr)
|
||||
|
@@ -78,7 +78,10 @@ SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case)
|
||||
bool
|
||||
SongFilter::Item::StringMatch(const char *s) const
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(s != nullptr);
|
||||
#endif
|
||||
|
||||
if (fold_case) {
|
||||
char *p = g_utf8_casefold(s, -1);
|
||||
|
@@ -186,12 +186,13 @@ zzip_input_seek(InputStream *is, InputPlugin::offset_type offset,
|
||||
{
|
||||
ZzipInputStream *zis = (ZzipInputStream *)is;
|
||||
zzip_off_t ofs = zzip_seek(zis->file, offset, whence);
|
||||
if (ofs != -1) {
|
||||
if (ofs < 0) {
|
||||
error.Set(zzip_domain, "zzip_seek() has failed");
|
||||
is->offset = ofs;
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
|
||||
is->offset = ofs;
|
||||
return true;
|
||||
}
|
||||
|
||||
/* exported structures */
|
||||
|
@@ -57,7 +57,7 @@ public:
|
||||
virtual void Close() override;
|
||||
virtual Song *GetSong(const char *uri_utf8,
|
||||
Error &error) const override;
|
||||
virtual void ReturnSong(Song *song) const;
|
||||
void ReturnSong(Song *song) const override;
|
||||
|
||||
virtual bool Visit(const DatabaseSelection &selection,
|
||||
VisitDirectory visit_directory,
|
||||
@@ -592,7 +592,7 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
|
||||
{
|
||||
// TODO: eliminate the const_cast
|
||||
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
|
||||
return nullptr;
|
||||
return false;
|
||||
|
||||
if (!visit_directory && !visit_playlist && selection.recursive &&
|
||||
(ServerSupportsSearchBase(connection)
|
||||
@@ -617,7 +617,7 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
|
||||
{
|
||||
// TODO: eliminate the const_cast
|
||||
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
|
||||
return nullptr;
|
||||
return false;
|
||||
|
||||
enum mpd_tag_type tag_type2 = Convert(tag_type);
|
||||
if (tag_type2 == MPD_TAG_COUNT) {
|
||||
@@ -657,7 +657,7 @@ ProxyDatabase::GetStats(const DatabaseSelection &selection,
|
||||
|
||||
// TODO: eliminate the const_cast
|
||||
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
|
||||
return nullptr;
|
||||
return false;
|
||||
|
||||
struct mpd_stats *stats2 =
|
||||
mpd_run_stats(connection);
|
||||
|
@@ -61,7 +61,7 @@ public:
|
||||
|
||||
virtual Song *GetSong(const char *uri_utf8,
|
||||
Error &error) const override;
|
||||
virtual void ReturnSong(Song *song) const;
|
||||
void ReturnSong(Song *song) const override;
|
||||
|
||||
virtual bool Visit(const DatabaseSelection &selection,
|
||||
VisitDirectory visit_directory,
|
||||
|
@@ -277,20 +277,12 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer *buffer,
|
||||
}
|
||||
|
||||
uint8_t channels;
|
||||
uint32_t sample_rate;
|
||||
#ifdef HAVE_FAAD_LONG
|
||||
/* neaacdec.h declares all arguments as "unsigned long", but
|
||||
internally expects uint32_t pointers. To avoid gcc
|
||||
warnings, use this workaround. */
|
||||
unsigned long *sample_rate_p = (unsigned long *)(void *)&sample_rate;
|
||||
#else
|
||||
uint32_t *sample_rate_p = &sample_rate;
|
||||
#endif
|
||||
unsigned long sample_rate;
|
||||
long nbytes = NeAACDecInit(decoder,
|
||||
/* deconst hack, libfaad requires this */
|
||||
const_cast<unsigned char *>(data),
|
||||
length,
|
||||
sample_rate_p, &channels);
|
||||
&sample_rate, &channels);
|
||||
if (nbytes < 0) {
|
||||
error.Set(faad_decoder_domain, "Not an AAC stream");
|
||||
return false;
|
||||
|
@@ -284,10 +284,13 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
|
||||
AVFrame *frame,
|
||||
uint8_t **buffer, int *buffer_size)
|
||||
{
|
||||
if (packet->pts >= 0 && packet->pts != (int64_t)AV_NOPTS_VALUE)
|
||||
decoder_timestamp(decoder,
|
||||
time_from_ffmpeg(packet->pts - start_time_fallback(*stream),
|
||||
stream->time_base));
|
||||
if (packet->pts >= 0 && packet->pts != (int64_t)AV_NOPTS_VALUE) {
|
||||
auto start = start_time_fallback(*stream);
|
||||
if (packet->pts >= start)
|
||||
decoder_timestamp(decoder,
|
||||
time_from_ffmpeg(packet->pts - start,
|
||||
stream->time_base));
|
||||
}
|
||||
|
||||
AVPacket packet2 = *packet;
|
||||
|
||||
@@ -394,10 +397,15 @@ ffmpeg_probe(Decoder *decoder, InputStream &is)
|
||||
avpd.filename = is.uri.c_str();
|
||||
|
||||
#ifdef AVPROBE_SCORE_MIME
|
||||
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(56, 5, 1)
|
||||
/* this attribute was added in libav/ffmpeg version 11, but
|
||||
unfortunately it's "uint8_t" instead of "char", and it's
|
||||
not "const" - wtf? */
|
||||
avpd.mime_type = (uint8_t *)const_cast<char *>(is.GetMimeType());
|
||||
#else
|
||||
/* API problem fixed in FFmpeg 2.5 */
|
||||
avpd.mime_type = is.GetMimeType();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return av_probe_input_format(&avpd, true);
|
||||
@@ -620,7 +628,7 @@ static const char *const ffmpeg_suffixes[] = {
|
||||
"mj2", "mjpeg", "mjpg", "mka", "mkv", "mlp", "mm", "mmf", "mov", "mp+",
|
||||
"mp1", "mp2", "mp3", "mp4", "mpc", "mpeg", "mpg", "mpga", "mpp", "mpu",
|
||||
"mve", "mvi", "mxf", "nc", "nsv", "nut", "nuv", "oga", "ogm", "ogv",
|
||||
"ogx", "oma", "ogg", "omg", "psp", "pva", "qcp", "qt", "r3d", "ra",
|
||||
"ogx", "oma", "ogg", "omg", "opus", "psp", "pva", "qcp", "qt", "r3d", "ra",
|
||||
"ram", "rl2", "rm", "rmvb", "roq", "rpl", "rvc", "shn", "smk", "snd",
|
||||
"sol", "son", "spx", "str", "swf", "tgi", "tgq", "tgv", "thp", "ts",
|
||||
"tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc",
|
||||
@@ -643,6 +651,7 @@ static const char *const ffmpeg_mime_types[] = {
|
||||
"audio/8svx",
|
||||
"audio/16sv",
|
||||
"audio/aac",
|
||||
"audio/aacp",
|
||||
"audio/ac3",
|
||||
"audio/aiff"
|
||||
"audio/amr",
|
||||
@@ -653,6 +662,7 @@ static const char *const ffmpeg_mime_types[] = {
|
||||
"audio/mpeg",
|
||||
"audio/musepack",
|
||||
"audio/ogg",
|
||||
"audio/opus",
|
||||
"audio/qcelp",
|
||||
"audio/vorbis",
|
||||
"audio/vorbis+ogg",
|
||||
|
@@ -141,7 +141,7 @@ get_remote_uid(int fd)
|
||||
socklen_t len = sizeof (cred);
|
||||
|
||||
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) < 0)
|
||||
return 0;
|
||||
return -1;
|
||||
|
||||
return cred.uid;
|
||||
#else
|
||||
|
@@ -52,10 +52,11 @@ public:
|
||||
children.emplace_back(name, filter);
|
||||
}
|
||||
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error);
|
||||
/* virtual methods from class Filter */
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error) override;
|
||||
|
||||
private:
|
||||
/**
|
||||
|
@@ -34,10 +34,11 @@ class NormalizeFilter final : public Filter {
|
||||
PcmBuffer buffer;
|
||||
|
||||
public:
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error);
|
||||
/* virtual methods from class Filter */
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error) override;
|
||||
};
|
||||
|
||||
static Filter *
|
||||
|
@@ -116,10 +116,11 @@ public:
|
||||
*/
|
||||
void Update();
|
||||
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error);
|
||||
/* virtual methods from class Filter */
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error) override;
|
||||
};
|
||||
|
||||
void
|
||||
|
@@ -120,10 +120,11 @@ public:
|
||||
*/
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error);
|
||||
/* virtual methods from class Filter */
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error) override;
|
||||
};
|
||||
|
||||
bool
|
||||
|
@@ -57,10 +57,10 @@ public:
|
||||
volume = _volume;
|
||||
}
|
||||
|
||||
virtual AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
virtual void Close();
|
||||
virtual const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error);
|
||||
AudioFormat Open(AudioFormat &af, Error &error) override;
|
||||
void Close() override;
|
||||
const void *FilterPCM(const void *src, size_t src_size,
|
||||
size_t *dest_size_r, Error &error) override;
|
||||
};
|
||||
|
||||
static constexpr Domain volume_domain("pcm_volume");
|
||||
|
@@ -46,7 +46,11 @@ AllocatedPath::Build(const_pointer a, const_pointer b)
|
||||
AllocatedPath
|
||||
AllocatedPath::FromUTF8(const char *path_utf8)
|
||||
{
|
||||
return AllocatedPath(Donate(), ::PathFromUTF8(path_utf8));
|
||||
char *path = ::PathFromUTF8(path_utf8);
|
||||
if (path == nullptr)
|
||||
return AllocatedPath::Null();
|
||||
|
||||
return AllocatedPath(Donate(), path);
|
||||
}
|
||||
|
||||
AllocatedPath
|
||||
|
@@ -79,7 +79,10 @@ GetFSCharset()
|
||||
std::string
|
||||
PathToUTF8(const char *path_fs)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(path_fs != nullptr);
|
||||
#endif
|
||||
|
||||
if (fs_charset.empty())
|
||||
return std::string(path_fs);
|
||||
@@ -109,7 +112,10 @@ PathToUTF8(const char *path_fs)
|
||||
char *
|
||||
PathFromUTF8(const char *path_utf8)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(path_utf8 != nullptr);
|
||||
#endif
|
||||
|
||||
if (fs_charset.empty())
|
||||
return g_strdup(path_utf8);
|
||||
|
@@ -25,7 +25,10 @@
|
||||
const char *
|
||||
PathTraits::GetBaseUTF8(const char *p)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(p != nullptr);
|
||||
#endif
|
||||
|
||||
const char *slash = strrchr(p, SEPARATOR_UTF8);
|
||||
return slash != nullptr
|
||||
@@ -36,7 +39,10 @@ PathTraits::GetBaseUTF8(const char *p)
|
||||
std::string
|
||||
PathTraits::GetParentUTF8(const char *p)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(p != nullptr);
|
||||
#endif
|
||||
|
||||
const char *slash = strrchr(p, SEPARATOR_UTF8);
|
||||
return slash != nullptr
|
||||
|
@@ -983,10 +983,10 @@ input_curl_easy_init(struct input_curl *c, Error &error)
|
||||
input_curl_writefunction);
|
||||
curl_easy_setopt(c->easy, CURLOPT_WRITEDATA, c);
|
||||
curl_easy_setopt(c->easy, CURLOPT_HTTP200ALIASES, http_200_aliases);
|
||||
curl_easy_setopt(c->easy, CURLOPT_FOLLOWLOCATION, 1);
|
||||
curl_easy_setopt(c->easy, CURLOPT_NETRC, 1);
|
||||
curl_easy_setopt(c->easy, CURLOPT_MAXREDIRS, 5);
|
||||
curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, true);
|
||||
curl_easy_setopt(c->easy, CURLOPT_FOLLOWLOCATION, 1l);
|
||||
curl_easy_setopt(c->easy, CURLOPT_NETRC, 1l);
|
||||
curl_easy_setopt(c->easy, CURLOPT_MAXREDIRS, 5l);
|
||||
curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, 1l);
|
||||
curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error);
|
||||
curl_easy_setopt(c->easy, CURLOPT_NOPROGRESS, 1l);
|
||||
curl_easy_setopt(c->easy, CURLOPT_NOSIGNAL, 1l);
|
||||
|
@@ -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 <despotify.h>
|
||||
}
|
||||
|
||||
#include <glib.h>
|
||||
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
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,
|
||||
};
|
@@ -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
|
@@ -54,9 +54,6 @@ static const char *remoteUrlPrefixes[] = {
|
||||
#endif
|
||||
#ifdef ENABLE_CDIO_PARANOIA
|
||||
"cdda://",
|
||||
#endif
|
||||
#ifdef ENABLE_DESPOTIFY
|
||||
"spt://",
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
@@ -46,7 +46,7 @@ class RoarOutput {
|
||||
struct roar_connection con;
|
||||
struct roar_audio_info info;
|
||||
mutable Mutex mutex;
|
||||
volatile bool alive;
|
||||
bool alive;
|
||||
|
||||
public:
|
||||
RoarOutput()
|
||||
|
@@ -114,7 +114,7 @@ ShoutOutput::Configure(const config_param ¶m, Error &error)
|
||||
if (!audio_format.IsFullyDefined()) {
|
||||
error.Set(config_domain,
|
||||
"Need full audio format specification");
|
||||
return nullptr;
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *host = require_block_string(param, "host");
|
||||
|
@@ -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 <despotify.h>
|
||||
}
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
static void
|
||||
add_song(std::forward_list<SongPointer> &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<SongPointer> &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<SongPointer> &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<SongPointer> 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) 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
|
@@ -178,7 +178,7 @@ const struct playlist_plugin embcue_playlist_plugin = {
|
||||
embcue_playlist_open_uri,
|
||||
nullptr,
|
||||
|
||||
nullptr,
|
||||
embcue_playlist_suffixes,
|
||||
nullptr,
|
||||
nullptr,
|
||||
};
|
||||
|
@@ -135,7 +135,8 @@ ExtM3uPlaylist::NextSong()
|
||||
|
||||
static const char *const extm3u_suffixes[] = {
|
||||
"m3u",
|
||||
NULL
|
||||
"m3u8",
|
||||
nullptr
|
||||
};
|
||||
|
||||
static const char *const extm3u_mime_types[] = {
|
||||
|
@@ -61,6 +61,7 @@ M3uPlaylist::NextSong()
|
||||
|
||||
static const char *const m3u_suffixes[] = {
|
||||
"m3u",
|
||||
"m3u8",
|
||||
nullptr
|
||||
};
|
||||
|
||||
|
@@ -40,8 +40,8 @@ MonotonicClockMS(void)
|
||||
if (base.denom == 0)
|
||||
(void)mach_timebase_info(&base);
|
||||
|
||||
return (unsigned)((mach_absolute_time() * base.numer)
|
||||
/ (1000000 * base.denom));
|
||||
return (unsigned)(((double)mach_absolute_time() * base.numer)
|
||||
/ base.denom / 1000000);
|
||||
#elif defined(CLOCK_MONOTONIC)
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
@@ -82,8 +82,8 @@ MonotonicClockUS(void)
|
||||
if (base.denom == 0)
|
||||
(void)mach_timebase_info(&base);
|
||||
|
||||
return ((uint64_t)mach_absolute_time() * (uint64_t)base.numer)
|
||||
/ (1000 * (uint64_t)base.denom);
|
||||
return (uint64_t)(((double)mach_absolute_time() * base.numer)
|
||||
/ base.denom / 1000);
|
||||
#elif defined(CLOCK_MONOTONIC)
|
||||
struct timespec ts;
|
||||
clock_gettime(CLOCK_MONOTONIC, &ts);
|
||||
|
@@ -77,7 +77,10 @@ TagBuilder::Commit()
|
||||
inline void
|
||||
TagBuilder::AddItemInternal(TagType type, const char *value, size_t length)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(value != nullptr);
|
||||
#endif
|
||||
assert(length > 0);
|
||||
|
||||
char *p = FixTagString(value, length);
|
||||
@@ -98,7 +101,10 @@ TagBuilder::AddItemInternal(TagType type, const char *value, size_t length)
|
||||
void
|
||||
TagBuilder::AddItem(TagType type, const char *value, size_t length)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(value != nullptr);
|
||||
#endif
|
||||
|
||||
if (length == 0 || ignore_tag_items[type])
|
||||
return;
|
||||
@@ -109,7 +115,10 @@ TagBuilder::AddItem(TagType type, const char *value, size_t length)
|
||||
void
|
||||
TagBuilder::AddItem(TagType type, const char *value)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(value != nullptr);
|
||||
#endif
|
||||
|
||||
AddItem(type, value, strlen(value));
|
||||
}
|
||||
|
@@ -33,7 +33,7 @@ patch_utf8(const char *src, size_t length, const gchar *end)
|
||||
{
|
||||
/* duplicate the string, and replace invalid bytes in that
|
||||
buffer */
|
||||
char *dest = g_strdup(src);
|
||||
char *dest = g_strndup(src, length);
|
||||
|
||||
do {
|
||||
dest[end - src] = '?';
|
||||
|
@@ -75,7 +75,7 @@ public:
|
||||
#ifdef WIN32
|
||||
return ::GetCurrentThreadId();
|
||||
#else
|
||||
return ::pthread_self();
|
||||
return pthread_self();
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
#ifdef WIN32
|
||||
return id == other.id;
|
||||
#else
|
||||
return ::pthread_equal(id, other.id);
|
||||
return pthread_equal(id, other.id);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@@ -43,24 +43,30 @@ gcc_pure gcc_nonnull_all
|
||||
static inline bool
|
||||
StringEqualsCaseASCII(const char *a, const char *b)
|
||||
{
|
||||
assert(a != nullptr);
|
||||
assert(b != nullptr);
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(a != nullptr);
|
||||
assert(b != nullptr);
|
||||
#endif
|
||||
|
||||
/* note: strcasecmp() depends on the locale, but for ASCII-only
|
||||
strings, it's safe to use */
|
||||
return strcasecmp(a, b) == 0;
|
||||
/* note: strcasecmp() depends on the locale, but for ASCII-only
|
||||
strings, it's safe to use */
|
||||
return strcasecmp(a, b) == 0;
|
||||
}
|
||||
|
||||
gcc_pure gcc_nonnull_all
|
||||
static inline bool
|
||||
StringEqualsCaseASCII(const char *a, const char *b, size_t n)
|
||||
{
|
||||
assert(a != nullptr);
|
||||
assert(b != nullptr);
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(a != nullptr);
|
||||
assert(b != nullptr);
|
||||
#endif
|
||||
|
||||
/* note: strcasecmp() depends on the locale, but for ASCII-only
|
||||
strings, it's safe to use */
|
||||
return strncasecmp(a, b, n) == 0;
|
||||
/* note: strcasecmp() depends on the locale, but for ASCII-only
|
||||
strings, it's safe to use */
|
||||
return strncasecmp(a, b, n) == 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -35,7 +35,7 @@
|
||||
#include <new>
|
||||
#include <utility>
|
||||
|
||||
#if !defined(__clang__) && __GNUC__ && !GCC_CHECK_VERSION(4,8)
|
||||
#if GCC_OLDER_THAN(4,8)
|
||||
#include <type_traits>
|
||||
#endif
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
*/
|
||||
template<class T>
|
||||
class Manual {
|
||||
#if !defined(__clang__) && __GNUC__ && !GCC_CHECK_VERSION(4,8)
|
||||
#if GCC_OLDER_THAN(4,8)
|
||||
/* no alignas() on gcc < 4.8: apply worst-case fallback */
|
||||
__attribute__((aligned(8)))
|
||||
#else
|
||||
|
@@ -44,6 +44,23 @@ uri_get_suffix(const char *uri)
|
||||
return suffix;
|
||||
}
|
||||
|
||||
const char *
|
||||
uri_get_suffix(const char *uri, UriSuffixBuffer &buffer)
|
||||
{
|
||||
const char *suffix = uri_get_suffix(uri);
|
||||
if (suffix == nullptr)
|
||||
return nullptr;
|
||||
|
||||
const char *q = strchr(suffix, '?');
|
||||
if (q != nullptr && size_t(q - suffix) < sizeof(buffer.data)) {
|
||||
memcpy(buffer.data, suffix, q - suffix);
|
||||
buffer.data[q - suffix] = 0;
|
||||
suffix = buffer.data;
|
||||
}
|
||||
|
||||
return suffix;
|
||||
}
|
||||
|
||||
static const char *
|
||||
verify_uri_segment(const char *p)
|
||||
{
|
||||
@@ -111,8 +128,11 @@ uri_remove_auth(const char *uri)
|
||||
bool
|
||||
uri_is_child(const char *parent, const char *child)
|
||||
{
|
||||
#if !CLANG_CHECK_VERSION(3,6)
|
||||
/* disabled on clang due to -Wtautological-pointer-compare */
|
||||
assert(parent != nullptr);
|
||||
assert(child != nullptr);
|
||||
#endif
|
||||
|
||||
const size_t parent_length = strlen(parent);
|
||||
return memcmp(parent, child, parent_length) == 0 &&
|
||||
|
@@ -35,6 +35,17 @@ gcc_pure
|
||||
const char *
|
||||
uri_get_suffix(const char *uri);
|
||||
|
||||
struct UriSuffixBuffer {
|
||||
char data[8];
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns the file name suffix, ignoring the query string.
|
||||
*/
|
||||
gcc_pure
|
||||
const char *
|
||||
uri_get_suffix(const char *uri, UriSuffixBuffer &buffer);
|
||||
|
||||
/**
|
||||
* Returns true if this is a safe "local" URI:
|
||||
*
|
||||
|
@@ -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.
|
||||
|
@@ -33,6 +33,25 @@ public:
|
||||
uri_get_suffix(".jpg"));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
|
||||
uri_get_suffix("/foo/.jpg"));
|
||||
|
||||
/* the first overload does not eliminate the query
|
||||
string */
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo/bar.jpg?query_string"),
|
||||
"jpg?query_string"));
|
||||
|
||||
/* ... but the second one does */
|
||||
UriSuffixBuffer buffer;
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo/bar.jpg?query_string",
|
||||
buffer),
|
||||
"jpg"));
|
||||
|
||||
/* repeat some of the above tests with the second overload */
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
|
||||
uri_get_suffix("/foo/bar", buffer));
|
||||
CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
|
||||
uri_get_suffix("/foo.jpg/bar", buffer));
|
||||
CPPUNIT_ASSERT_EQUAL(0, strcmp(uri_get_suffix("/foo/bar.jpg", buffer),
|
||||
"jpg"));
|
||||
}
|
||||
|
||||
void TestRemoveAuth() {
|
||||
|
Reference in New Issue
Block a user