Compare commits

...

43 Commits

Author SHA1 Message Date
Max Kellermann
8534f2d1e2 release v0.18.22 2015-01-14 23:04:49 +01:00
Max Kellermann
665031467a db/proxy, output/shout: fix implicit nullptr/bool conversion
Return false on error, not nullptr.
2014-12-26 13:50:54 +01:00
Max Kellermann
df33171107 db/{simple,proxy}, ...: add "override" keywords
Fixes -Winconsistent-missing-override (clang 3.6).
2014-12-26 13:47:04 +01:00
Max Kellermann
53f4044890 util/{ASCII,UriUtil}, ...: work around -Wtautological-pointer-compare
New in clang 3.6.
2014-12-26 13:43:32 +01:00
Max Kellermann
a5049136ff DatabaseGlue: convert nullptr check to assertion 2014-12-26 13:43:32 +01:00
Max Kellermann
705b3c6b63 util/ASCII: fix indent 2014-12-26 13:37:38 +01:00
Max Kellermann
6b4ac66962 Compiler.h: add macro CLANG_CHECK_VERSION() 2014-12-26 13:31:03 +01:00
Max Kellermann
0964b06240 Compiler.h: add macro GCC_OLDER_THAN() 2014-12-26 13:30:44 +01:00
Max Kellermann
92eeca3ba7 util/Manual: reimplement GCC_CHECK_VERSION() using GCC_MAKE_VERSION() 2014-12-26 13:30:22 +01:00
Max Kellermann
2a86554ac4 Compiler.h: add macro GCC_MAKE_VERSION() 2014-12-26 13:30:11 +01:00
Max Kellermann
805caa30ce configure.ac: prepare for 0.18.22 2014-12-26 13:23:04 +01:00
Max Kellermann
acb798e544 release v0.18.21 2014-12-17 19:13:47 +01:00
k44
773de38bd9 playlist/embcue: fix filename suffix detection
The definition of the playlist_plugin struct member of the embcue
plugin was incorrect.
2014-12-16 18:43:05 +01:00
Max Kellermann
fa4beeee75 decoder/ffmpeg: detect and fix negative time stamps
Works around assertion failure due to something that appears to be a
(minor) FFmpeg bug.
2014-12-15 00:40:46 +01:00
Max Kellermann
d8351772d3 configure.ac: prepare for 0.18.21 2014-12-15 00:39:52 +01:00
Max Kellermann
1b5f33a435 release v0.18.20 2014-12-08 14:57:17 +01:00
Max Kellermann
41b4a63f2b decoder/ffmpeg: support FFmpeg 2.5
Version 2.5 fixed an API oddity, however it broke API compatibility,
at least with C++.  Disable the workaround when a libavformat version
is detected that is recent enough.
2014-12-08 14:25:34 +01:00
Max Kellermann
d8fc2db910 thread/Id: drop "::" prefix before pthread function names
The "::" to explicitly refer to the global namespace appeared like a
good idea in C++, but it breaks with C libraries that implement
standard functions using macros (e.g. musl).
2014-12-08 14:17:17 +01:00
Max Kellermann
dc11dea7cc configure.ac: prepare for 0.18.20 2014-12-08 14:13:20 +01:00
Max Kellermann
04f627c2af release v0.18.19 2014-11-26 19:58:48 +01:00
Max Kellermann
a254f5a3a8 archive/zzip: fix inverted error handler
Set the Error when zzip_seek()==-1 and not on success.  Fixes a crash
after seeking.
2014-11-24 22:08:50 +01:00
Max Kellermann
143c735f96 configure.ac: prepare for 0.18.19 2014-11-24 22:08:50 +01:00
Max Kellermann
7aa2104596 release v0.18.18 2014-11-18 21:34:03 +01:00
Max Kellermann
c8b93d6573 Client: assume uid==0 is local socket
A negative uid value means it's not a "local socket" (PF_LOCAL).
uid==0 means user "root" connected.
2014-11-18 20:56:27 +01:00
Max Kellermann
3f5f96ac91 event/ServerSocket: fix get_remote_uid() error value
Must return -1 on error, not 0.  0 is root.
2014-11-18 20:53:59 +01:00
Florent Le Coz
7e7b403043 Construct a Null AllocatedPath if the filename conversion into UTF8 failed 2014-11-11 17:15:19 +01:00
Max Kellermann
c64ad78c7b decoder/ffmpeg: support opus 2014-11-10 18:00:30 +01:00
Max Kellermann
4a043a915f configure.ac: prepare for 0.18.1 2014-11-10 17:59:06 +01:00
Max Kellermann
38a0d15190 release v0.18.17 2014-11-02 13:06:20 +01:00
Max Kellermann
ec3191f502 input/curl: fix curl_easy_setopt() parameter types 2014-11-02 11:55:48 +01:00
Max Kellermann
32b5654a6e Decoder, Playlist: ignore URI query string for plugin detection
Use the new uri_get_suffix() overload that removes the query string.
2014-11-02 11:54:26 +01:00
Max Kellermann
674091424e util/UriUtil: add uri_get_suffix() overload that ignores query string 2014-11-02 11:53:31 +01:00
Max Kellermann
6ad336743d PlaylistFile: don't allow empty playlist name 2014-11-02 11:52:48 +01:00
Max Kellermann
c882568ccd playlist/m3u: recognize the file suffix ".m3u8" 2014-11-02 11:50:56 +01:00
Max Kellermann
f6b2899dd2 decoder/faad: remove workaround for ancient libfaad2 ABI bug
Many years ago, FAAD had a serious ABI bug: the NeAACDecInit()
prototype in its header declared the "samplerate" parameter to be
"unsigned long *", but internally, the function assumed it was
"uint32_t *" instead.  On 32 bit machines, that was no difference, but
on 64 bit, this left one portion of the return value uninitialized;
and worse, on big-endian, the wrong word was filled.  This bug had to
be worked around in MPD (commit 9c4e97a6).

A few months later, the bug was fixed in the FAAD CVS in commit 1.117
on file libfaad/decoder.c; the commit message was:

 "Use public headers internally to prevent duplicate declarations"

The commit message was too brief at best; the problem was not
duplicate declarations, but a prototype mismatch.  No mention of the
bug fix in the ChangeLog.

The MPD project never learned about this bug fix, and so MPD would
always pass a "uin32_t *" dressed up as a "unsigned long *".  Nearly 6
years later, it's about time to fix this second ABI problem.  Let's
kill the workaround!
2014-11-02 11:50:56 +01:00
Steven OBrien
bccd4ef2f7 decoder/ffmpeg: recognize MIME type audio/aacp 2014-11-02 11:50:56 +01:00
Max Kellermann
94c240a026 configure.ac: show DSD in result 2014-11-02 11:50:56 +01:00
Max Kellermann
c50a0cf7bf output/roar: remove unnecessary "volatile" keyword
A mutex acts as a memory barrier, and thus "volatile" is not
necessary.
2014-11-02 11:50:56 +01:00
Max Kellermann
c37f7abb79 TagString: use g_strndup() for unterminated string
Fixes buffer overflow bug.
2014-11-02 11:48:13 +01:00
Max Kellermann
432ce9b1de configure.ac: prepare for 0.18.17 2014-11-02 11:41:40 +01:00
Max Kellermann
fe45f28204 release v0.18.16 2014-09-26 10:57:04 +02:00
Max Kellermann
861067412f configure.ac: fix DSD breakage due to typo 2014-09-26 10:56:20 +02:00
Max Kellermann
7eca886608 configure.ac: prepare for 0.18.16 2014-09-26 10:55:43 +02:00
42 changed files with 260 additions and 124 deletions

36
NEWS
View File

@@ -1,3 +1,39 @@
ver 0.18.22 (2014/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
ver 0.18.15 (2014/09/26) ver 0.18.15 (2014/09/26)
* command * command
- list: reset used size after the list has been processed - list: reset used size after the list has been processed

View File

@@ -1,10 +1,10 @@
AC_PREREQ(2.60) AC_PREREQ(2.60)
AC_INIT(mpd, 0.18.15, mpd-devel@musicpd.org) AC_INIT(mpd, 0.18.22, mpd-devel@musicpd.org)
VERSION_MAJOR=0 VERSION_MAJOR=0
VERSION_MINOR=18 VERSION_MINOR=18
VERSION_REVISION=0 VERSION_REVISION=22
VERSION_EXTRA=0 VERSION_EXTRA=0
AC_CONFIG_SRCDIR([src/Main.cxx]) AC_CONFIG_SRCDIR([src/Main.cxx])
@@ -854,7 +854,7 @@ fi
dnl ----------------------------------- DSD ----------------------------------- dnl ----------------------------------- DSD -----------------------------------
if test x$enable_dsd = xyes; then if test x$enable_dsd = xyes; then
AC_DEFINE(HAVE_DSD, 1, [Define for the DSD decoder]) AC_DEFINE(ENABLE_DSD, 1, [Define for the DSD decoder])
fi fi
AM_CONDITIONAL(ENABLE_DSD, test x$enable_dsd = xyes) AM_CONDITIONAL(ENABLE_DSD, test x$enable_dsd = xyes)
@@ -1523,6 +1523,7 @@ results(un,[UNIX Domain Sockets])
printf '\nFile format support:\n\t' printf '\nFile format support:\n\t'
results(aac, [AAC]) results(aac, [AAC])
results(adplug, [AdPlug]) results(adplug, [AdPlug])
results(dsd, [DSD])
results(sidplay, [C64 SID]) results(sidplay, [C64 SID])
results(ffmpeg, [FFMPEG]) results(ffmpeg, [FFMPEG])
results(flac, [FLAC]) results(flac, [FLAC])

View File

@@ -62,36 +62,7 @@ int main() {
CPPFLAGS=$oldcppflags CPPFLAGS=$oldcppflags
fi fi
if test x$enable_aac = xyes; then if test x$enable_aac = xno; 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
FAAD_LIBS="" FAAD_LIBS=""
FAAD_CFLAGS="" FAAD_CFLAGS=""
fi fi

View File

@@ -109,7 +109,7 @@ public:
* a local (UNIX domain) socket? * a local (UNIX domain) socket?
*/ */
bool IsLocal() const { bool IsLocal() const {
return uid > 0; return uid >= 0;
} }
unsigned GetPermission() const { unsigned GetPermission() const {

View File

@@ -47,7 +47,7 @@ client_allow_file(const Client &client, Path path_fs, Error &error)
instance */ instance */
return true; return true;
if (uid <= 0) { if (uid < 0) {
/* unauthenticated client */ /* unauthenticated client */
error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied"); error.Set(ack_domain, ACK_ERROR_PERMISSION, "Access denied");
return false; return false;

View File

@@ -20,33 +20,45 @@
#ifndef COMPILER_H #ifndef COMPILER_H
#define COMPILER_H #define COMPILER_H
#define GCC_CHECK_VERSION(major, minor) \ #define GCC_MAKE_VERSION(major, minor, patchlevel) ((major) * 10000 + (minor) * 100 + patchlevel)
(defined(__GNUC__) && \
(__GNUC__ > (major) || (__GNUC__ == (major) && __GNUC_MINOR__ >= (minor))))
#ifdef __GNUC__ #ifdef __GNUC__
#define GCC_VERSION (__GNUC__ * 10000 \ #define GCC_VERSION GCC_MAKE_VERSION(__GNUC__, __GNUC_MINOR__, __GNUC_PATCHLEVEL__)
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#else #else
#define GCC_VERSION 0 #define GCC_VERSION 0
#endif #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__ #ifdef __clang__
# define CLANG_VERSION (__clang_major__ * 10000 \ # define CLANG_VERSION GCC_MAKE_VERSION(__clang_major__, __clang_minor__, __clang_patchlevel__)
+ __clang_minor__ * 100 \
+ __clang_patchlevel__)
# if __clang_major__ < 3 # if __clang_major__ < 3
# error Sorry, your clang version is too old. You need at least version 3.1. # error Sorry, your clang version is too old. You need at least version 3.1.
# endif # endif
#elif defined(__GNUC__) #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. # error Sorry, your gcc version is too old. You need at least version 4.6.
# endif # endif
#else #else
# warning Untested compiler. Use at your own risk! # warning Untested compiler. Use at your own risk!
#endif #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) #if GCC_CHECK_VERSION(4,0)
/* GCC 4.x */ /* GCC 4.x */
@@ -141,7 +153,7 @@
#if defined(__cplusplus) #if defined(__cplusplus)
/* support for C++11 "override" was added in gcc 4.7 */ /* 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 override
#define final #define final
#endif #endif

View File

@@ -112,13 +112,15 @@ db_get_root(void)
Directory * Directory *
db_get_directory(const char *name) 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) if (db == nullptr)
return nullptr; return nullptr;
Directory *music_root = db_get_root(); Directory *music_root = db_get_root();
if (name == nullptr)
return music_root;
return music_root->LookupDirectory(name); return music_root->LookupDirectory(name);
} }

View File

@@ -26,7 +26,10 @@
bool bool
DecoderPlugin::SupportsSuffix(const char *suffix) const DecoderPlugin::SupportsSuffix(const char *suffix) const
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(suffix != nullptr); assert(suffix != nullptr);
#endif
return suffixes != nullptr && string_array_contains(suffixes, suffix); return suffixes != nullptr && string_array_contains(suffixes, suffix);
@@ -35,7 +38,10 @@ DecoderPlugin::SupportsSuffix(const char *suffix) const
bool bool
DecoderPlugin::SupportsMimeType(const char *mime_type) const 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); assert(mime_type != nullptr);
#endif
return mime_types != nullptr && return mime_types != nullptr &&
string_array_contains(mime_types, mime_type); string_array_contains(mime_types, mime_type);

View File

@@ -212,7 +212,8 @@ static bool
decoder_run_stream_locked(Decoder &decoder, InputStream &is, decoder_run_stream_locked(Decoder &decoder, InputStream &is,
const char *uri, bool &tried_r) 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; using namespace std::placeholders;
const auto f = std::bind(decoder_run_stream_plugin, const auto f = std::bind(decoder_run_stream_plugin,

View File

@@ -40,7 +40,10 @@ extern "C" {
inline Directory * inline Directory *
Directory::Allocate(const char *path) Directory::Allocate(const char *path)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(path != nullptr); assert(path != nullptr);
#endif
const size_t path_size = strlen(path) + 1; const size_t path_size = strlen(path) + 1;
Directory *directory = Directory *directory =

View File

@@ -155,7 +155,10 @@ InputStream::IsAvailable()
size_t size_t
InputStream::Read(void *ptr, size_t _size, Error &error) 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); assert(ptr != nullptr);
#endif
assert(_size > 0); assert(_size > 0);
return plugin.read(this, ptr, _size, error); return plugin.read(this, ptr, _size, error);
@@ -164,7 +167,10 @@ InputStream::Read(void *ptr, size_t _size, Error &error)
size_t size_t
InputStream::LockRead(void *ptr, size_t _size, Error &error) 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); assert(ptr != nullptr);
#endif
assert(_size > 0); assert(_size > 0);
const ScopeLock protect(mutex); const ScopeLock protect(mutex);

View File

@@ -69,6 +69,10 @@ spl_global_init(void)
bool bool
spl_valid_name(const char *name_utf8) 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 * Not supporting '/' was done out of laziness, and we should
* really strive to support it in the future. * really strive to support it in the future.

View File

@@ -164,12 +164,12 @@ static SongEnumerator *
playlist_list_open_uri_suffix(const char *uri, Mutex &mutex, Cond &cond, playlist_list_open_uri_suffix(const char *uri, Mutex &mutex, Cond &cond,
const bool *tried) const bool *tried)
{ {
const char *suffix;
SongEnumerator *playlist = nullptr; SongEnumerator *playlist = nullptr;
assert(uri != 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) if (suffix == nullptr)
return nullptr; return nullptr;
@@ -273,8 +273,6 @@ playlist_list_open_stream_suffix(InputStream &is, const char *suffix)
SongEnumerator * SongEnumerator *
playlist_list_open_stream(InputStream &is, const char *uri) playlist_list_open_stream(InputStream &is, const char *uri)
{ {
const char *suffix;
is.LockWaitReady(); is.LockWaitReady();
const char *const mime = is.GetMimeType(); const char *const mime = is.GetMimeType();
@@ -284,7 +282,10 @@ playlist_list_open_stream(InputStream &is, const char *uri)
return playlist; 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) { if (suffix != nullptr) {
auto playlist = playlist_list_open_stream_suffix(is, suffix); auto playlist = playlist_list_open_stream_suffix(is, suffix);
if (playlist != nullptr) if (playlist != nullptr)

View File

@@ -78,7 +78,10 @@ SongFilter::Item::Item(unsigned _tag, const char *_value, bool _fold_case)
bool bool
SongFilter::Item::StringMatch(const char *s) const SongFilter::Item::StringMatch(const char *s) const
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(s != nullptr); assert(s != nullptr);
#endif
if (fold_case) { if (fold_case) {
char *p = g_utf8_casefold(s, -1); char *p = g_utf8_casefold(s, -1);

View File

@@ -186,12 +186,13 @@ zzip_input_seek(InputStream *is, InputPlugin::offset_type offset,
{ {
ZzipInputStream *zis = (ZzipInputStream *)is; ZzipInputStream *zis = (ZzipInputStream *)is;
zzip_off_t ofs = zzip_seek(zis->file, offset, whence); zzip_off_t ofs = zzip_seek(zis->file, offset, whence);
if (ofs != -1) { if (ofs < 0) {
error.Set(zzip_domain, "zzip_seek() has failed"); error.Set(zzip_domain, "zzip_seek() has failed");
is->offset = ofs; return false;
return true;
} }
return false;
is->offset = ofs;
return true;
} }
/* exported structures */ /* exported structures */

View File

@@ -57,7 +57,7 @@ public:
virtual void Close() override; virtual void Close() override;
virtual Song *GetSong(const char *uri_utf8, virtual Song *GetSong(const char *uri_utf8,
Error &error) const override; Error &error) const override;
virtual void ReturnSong(Song *song) const; void ReturnSong(Song *song) const override;
virtual bool Visit(const DatabaseSelection &selection, virtual bool Visit(const DatabaseSelection &selection,
VisitDirectory visit_directory, VisitDirectory visit_directory,
@@ -592,7 +592,7 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
{ {
// TODO: eliminate the const_cast // TODO: eliminate the const_cast
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error)) if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
return nullptr; return false;
if (!visit_directory && !visit_playlist && selection.recursive && if (!visit_directory && !visit_playlist && selection.recursive &&
(ServerSupportsSearchBase(connection) (ServerSupportsSearchBase(connection)
@@ -617,7 +617,7 @@ ProxyDatabase::VisitUniqueTags(const DatabaseSelection &selection,
{ {
// TODO: eliminate the const_cast // TODO: eliminate the const_cast
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error)) if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
return nullptr; return false;
enum mpd_tag_type tag_type2 = Convert(tag_type); enum mpd_tag_type tag_type2 = Convert(tag_type);
if (tag_type2 == MPD_TAG_COUNT) { if (tag_type2 == MPD_TAG_COUNT) {
@@ -657,7 +657,7 @@ ProxyDatabase::GetStats(const DatabaseSelection &selection,
// TODO: eliminate the const_cast // TODO: eliminate the const_cast
if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error)) if (!const_cast<ProxyDatabase *>(this)->EnsureConnected(error))
return nullptr; return false;
struct mpd_stats *stats2 = struct mpd_stats *stats2 =
mpd_run_stats(connection); mpd_run_stats(connection);

View File

@@ -61,7 +61,7 @@ public:
virtual Song *GetSong(const char *uri_utf8, virtual Song *GetSong(const char *uri_utf8,
Error &error) const override; Error &error) const override;
virtual void ReturnSong(Song *song) const; void ReturnSong(Song *song) const override;
virtual bool Visit(const DatabaseSelection &selection, virtual bool Visit(const DatabaseSelection &selection,
VisitDirectory visit_directory, VisitDirectory visit_directory,

View File

@@ -277,20 +277,12 @@ faad_decoder_init(NeAACDecHandle decoder, DecoderBuffer *buffer,
} }
uint8_t channels; uint8_t channels;
uint32_t sample_rate; unsigned long 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
long nbytes = NeAACDecInit(decoder, long nbytes = NeAACDecInit(decoder,
/* deconst hack, libfaad requires this */ /* deconst hack, libfaad requires this */
const_cast<unsigned char *>(data), const_cast<unsigned char *>(data),
length, length,
sample_rate_p, &channels); &sample_rate, &channels);
if (nbytes < 0) { if (nbytes < 0) {
error.Set(faad_decoder_domain, "Not an AAC stream"); error.Set(faad_decoder_domain, "Not an AAC stream");
return false; return false;

View File

@@ -284,10 +284,13 @@ ffmpeg_send_packet(Decoder &decoder, InputStream &is,
AVFrame *frame, AVFrame *frame,
uint8_t **buffer, int *buffer_size) uint8_t **buffer, int *buffer_size)
{ {
if (packet->pts >= 0 && packet->pts != (int64_t)AV_NOPTS_VALUE) if (packet->pts >= 0 && packet->pts != (int64_t)AV_NOPTS_VALUE) {
decoder_timestamp(decoder, auto start = start_time_fallback(*stream);
time_from_ffmpeg(packet->pts - start_time_fallback(*stream), if (packet->pts >= start)
stream->time_base)); decoder_timestamp(decoder,
time_from_ffmpeg(packet->pts - start,
stream->time_base));
}
AVPacket packet2 = *packet; AVPacket packet2 = *packet;
@@ -394,10 +397,15 @@ ffmpeg_probe(Decoder *decoder, InputStream &is)
avpd.filename = is.uri.c_str(); avpd.filename = is.uri.c_str();
#ifdef AVPROBE_SCORE_MIME #ifdef AVPROBE_SCORE_MIME
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(56, 5, 1)
/* this attribute was added in libav/ffmpeg version 11, but /* this attribute was added in libav/ffmpeg version 11, but
unfortunately it's "uint8_t" instead of "char", and it's unfortunately it's "uint8_t" instead of "char", and it's
not "const" - wtf? */ not "const" - wtf? */
avpd.mime_type = (uint8_t *)const_cast<char *>(is.GetMimeType()); 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 #endif
return av_probe_input_format(&avpd, true); 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+", "mj2", "mjpeg", "mjpg", "mka", "mkv", "mlp", "mm", "mmf", "mov", "mp+",
"mp1", "mp2", "mp3", "mp4", "mpc", "mpeg", "mpg", "mpga", "mpp", "mpu", "mp1", "mp2", "mp3", "mp4", "mpc", "mpeg", "mpg", "mpga", "mpp", "mpu",
"mve", "mvi", "mxf", "nc", "nsv", "nut", "nuv", "oga", "ogm", "ogv", "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", "ram", "rl2", "rm", "rmvb", "roq", "rpl", "rvc", "shn", "smk", "snd",
"sol", "son", "spx", "str", "swf", "tgi", "tgq", "tgv", "thp", "ts", "sol", "son", "spx", "str", "swf", "tgi", "tgq", "tgv", "thp", "ts",
"tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc", "tsp", "tta", "xa", "xvid", "uv", "uv2", "vb", "vid", "vob", "voc",
@@ -643,6 +651,7 @@ static const char *const ffmpeg_mime_types[] = {
"audio/8svx", "audio/8svx",
"audio/16sv", "audio/16sv",
"audio/aac", "audio/aac",
"audio/aacp",
"audio/ac3", "audio/ac3",
"audio/aiff" "audio/aiff"
"audio/amr", "audio/amr",
@@ -653,6 +662,7 @@ static const char *const ffmpeg_mime_types[] = {
"audio/mpeg", "audio/mpeg",
"audio/musepack", "audio/musepack",
"audio/ogg", "audio/ogg",
"audio/opus",
"audio/qcelp", "audio/qcelp",
"audio/vorbis", "audio/vorbis",
"audio/vorbis+ogg", "audio/vorbis+ogg",

View File

@@ -141,7 +141,7 @@ get_remote_uid(int fd)
socklen_t len = sizeof (cred); socklen_t len = sizeof (cred);
if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) < 0) if (getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &cred, &len) < 0)
return 0; return -1;
return cred.uid; return cred.uid;
#else #else

View File

@@ -52,10 +52,11 @@ public:
children.emplace_back(name, filter); children.emplace_back(name, filter);
} }
virtual AudioFormat Open(AudioFormat &af, Error &error) override; /* virtual methods from class Filter */
virtual void Close(); AudioFormat Open(AudioFormat &af, Error &error) override;
virtual const void *FilterPCM(const void *src, size_t src_size, void Close() override;
size_t *dest_size_r, Error &error); const void *FilterPCM(const void *src, size_t src_size,
size_t *dest_size_r, Error &error) override;
private: private:
/** /**

View File

@@ -34,10 +34,11 @@ class NormalizeFilter final : public Filter {
PcmBuffer buffer; PcmBuffer buffer;
public: public:
virtual AudioFormat Open(AudioFormat &af, Error &error) override; /* virtual methods from class Filter */
virtual void Close(); AudioFormat Open(AudioFormat &af, Error &error) override;
virtual const void *FilterPCM(const void *src, size_t src_size, void Close() override;
size_t *dest_size_r, Error &error); const void *FilterPCM(const void *src, size_t src_size,
size_t *dest_size_r, Error &error) override;
}; };
static Filter * static Filter *

View File

@@ -116,10 +116,11 @@ public:
*/ */
void Update(); void Update();
virtual AudioFormat Open(AudioFormat &af, Error &error) override; /* virtual methods from class Filter */
virtual void Close(); AudioFormat Open(AudioFormat &af, Error &error) override;
virtual const void *FilterPCM(const void *src, size_t src_size, void Close() override;
size_t *dest_size_r, Error &error); const void *FilterPCM(const void *src, size_t src_size,
size_t *dest_size_r, Error &error) override;
}; };
void void

View File

@@ -120,10 +120,11 @@ public:
*/ */
bool Configure(const config_param &param, Error &error); bool Configure(const config_param &param, Error &error);
virtual AudioFormat Open(AudioFormat &af, Error &error) override; /* virtual methods from class Filter */
virtual void Close(); AudioFormat Open(AudioFormat &af, Error &error) override;
virtual const void *FilterPCM(const void *src, size_t src_size, void Close() override;
size_t *dest_size_r, Error &error); const void *FilterPCM(const void *src, size_t src_size,
size_t *dest_size_r, Error &error) override;
}; };
bool bool

View File

@@ -57,10 +57,10 @@ public:
volume = _volume; volume = _volume;
} }
virtual AudioFormat Open(AudioFormat &af, Error &error) override; AudioFormat Open(AudioFormat &af, Error &error) override;
virtual void Close(); void Close() override;
virtual const void *FilterPCM(const void *src, size_t src_size, const void *FilterPCM(const void *src, size_t src_size,
size_t *dest_size_r, Error &error); size_t *dest_size_r, Error &error) override;
}; };
static constexpr Domain volume_domain("pcm_volume"); static constexpr Domain volume_domain("pcm_volume");

View File

@@ -46,7 +46,11 @@ AllocatedPath::Build(const_pointer a, const_pointer b)
AllocatedPath AllocatedPath
AllocatedPath::FromUTF8(const char *path_utf8) 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 AllocatedPath

View File

@@ -79,7 +79,10 @@ GetFSCharset()
std::string std::string
PathToUTF8(const char *path_fs) PathToUTF8(const char *path_fs)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(path_fs != nullptr); assert(path_fs != nullptr);
#endif
if (fs_charset.empty()) if (fs_charset.empty())
return std::string(path_fs); return std::string(path_fs);
@@ -109,7 +112,10 @@ PathToUTF8(const char *path_fs)
char * char *
PathFromUTF8(const char *path_utf8) PathFromUTF8(const char *path_utf8)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(path_utf8 != nullptr); assert(path_utf8 != nullptr);
#endif
if (fs_charset.empty()) if (fs_charset.empty())
return g_strdup(path_utf8); return g_strdup(path_utf8);

View File

@@ -25,7 +25,10 @@
const char * const char *
PathTraits::GetBaseUTF8(const char *p) PathTraits::GetBaseUTF8(const char *p)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
#endif
const char *slash = strrchr(p, SEPARATOR_UTF8); const char *slash = strrchr(p, SEPARATOR_UTF8);
return slash != nullptr return slash != nullptr
@@ -36,7 +39,10 @@ PathTraits::GetBaseUTF8(const char *p)
std::string std::string
PathTraits::GetParentUTF8(const char *p) PathTraits::GetParentUTF8(const char *p)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(p != nullptr); assert(p != nullptr);
#endif
const char *slash = strrchr(p, SEPARATOR_UTF8); const char *slash = strrchr(p, SEPARATOR_UTF8);
return slash != nullptr return slash != nullptr

View File

@@ -983,10 +983,10 @@ input_curl_easy_init(struct input_curl *c, Error &error)
input_curl_writefunction); input_curl_writefunction);
curl_easy_setopt(c->easy, CURLOPT_WRITEDATA, c); curl_easy_setopt(c->easy, CURLOPT_WRITEDATA, c);
curl_easy_setopt(c->easy, CURLOPT_HTTP200ALIASES, http_200_aliases); curl_easy_setopt(c->easy, CURLOPT_HTTP200ALIASES, http_200_aliases);
curl_easy_setopt(c->easy, CURLOPT_FOLLOWLOCATION, 1); curl_easy_setopt(c->easy, CURLOPT_FOLLOWLOCATION, 1l);
curl_easy_setopt(c->easy, CURLOPT_NETRC, 1); curl_easy_setopt(c->easy, CURLOPT_NETRC, 1l);
curl_easy_setopt(c->easy, CURLOPT_MAXREDIRS, 5); curl_easy_setopt(c->easy, CURLOPT_MAXREDIRS, 5l);
curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, true); curl_easy_setopt(c->easy, CURLOPT_FAILONERROR, 1l);
curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error); curl_easy_setopt(c->easy, CURLOPT_ERRORBUFFER, c->error);
curl_easy_setopt(c->easy, CURLOPT_NOPROGRESS, 1l); curl_easy_setopt(c->easy, CURLOPT_NOPROGRESS, 1l);
curl_easy_setopt(c->easy, CURLOPT_NOSIGNAL, 1l); curl_easy_setopt(c->easy, CURLOPT_NOSIGNAL, 1l);

View File

@@ -46,7 +46,7 @@ class RoarOutput {
struct roar_connection con; struct roar_connection con;
struct roar_audio_info info; struct roar_audio_info info;
mutable Mutex mutex; mutable Mutex mutex;
volatile bool alive; bool alive;
public: public:
RoarOutput() RoarOutput()

View File

@@ -114,7 +114,7 @@ ShoutOutput::Configure(const config_param &param, Error &error)
if (!audio_format.IsFullyDefined()) { if (!audio_format.IsFullyDefined()) {
error.Set(config_domain, error.Set(config_domain,
"Need full audio format specification"); "Need full audio format specification");
return nullptr; return false;
} }
const char *host = require_block_string(param, "host"); const char *host = require_block_string(param, "host");

View File

@@ -178,7 +178,7 @@ const struct playlist_plugin embcue_playlist_plugin = {
embcue_playlist_open_uri, embcue_playlist_open_uri,
nullptr, nullptr,
nullptr,
embcue_playlist_suffixes, embcue_playlist_suffixes,
nullptr, nullptr,
nullptr,
}; };

View File

@@ -135,7 +135,8 @@ ExtM3uPlaylist::NextSong()
static const char *const extm3u_suffixes[] = { static const char *const extm3u_suffixes[] = {
"m3u", "m3u",
NULL "m3u8",
nullptr
}; };
static const char *const extm3u_mime_types[] = { static const char *const extm3u_mime_types[] = {

View File

@@ -61,6 +61,7 @@ M3uPlaylist::NextSong()
static const char *const m3u_suffixes[] = { static const char *const m3u_suffixes[] = {
"m3u", "m3u",
"m3u8",
nullptr nullptr
}; };

View File

@@ -77,7 +77,10 @@ TagBuilder::Commit()
inline void inline void
TagBuilder::AddItemInternal(TagType type, const char *value, size_t length) 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); assert(value != nullptr);
#endif
assert(length > 0); assert(length > 0);
char *p = FixTagString(value, length); char *p = FixTagString(value, length);
@@ -98,7 +101,10 @@ TagBuilder::AddItemInternal(TagType type, const char *value, size_t length)
void void
TagBuilder::AddItem(TagType type, const char *value, size_t length) 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); assert(value != nullptr);
#endif
if (length == 0 || ignore_tag_items[type]) if (length == 0 || ignore_tag_items[type])
return; return;
@@ -109,7 +115,10 @@ TagBuilder::AddItem(TagType type, const char *value, size_t length)
void void
TagBuilder::AddItem(TagType type, const char *value) TagBuilder::AddItem(TagType type, const char *value)
{ {
#if !CLANG_CHECK_VERSION(3,6)
/* disabled on clang due to -Wtautological-pointer-compare */
assert(value != nullptr); assert(value != nullptr);
#endif
AddItem(type, value, strlen(value)); AddItem(type, value, strlen(value));
} }

View File

@@ -33,7 +33,7 @@ patch_utf8(const char *src, size_t length, const gchar *end)
{ {
/* duplicate the string, and replace invalid bytes in that /* duplicate the string, and replace invalid bytes in that
buffer */ buffer */
char *dest = g_strdup(src); char *dest = g_strndup(src, length);
do { do {
dest[end - src] = '?'; dest[end - src] = '?';

View File

@@ -75,7 +75,7 @@ public:
#ifdef WIN32 #ifdef WIN32
return ::GetCurrentThreadId(); return ::GetCurrentThreadId();
#else #else
return ::pthread_self(); return pthread_self();
#endif #endif
} }
@@ -84,7 +84,7 @@ public:
#ifdef WIN32 #ifdef WIN32
return id == other.id; return id == other.id;
#else #else
return ::pthread_equal(id, other.id); return pthread_equal(id, other.id);
#endif #endif
} }

View File

@@ -43,24 +43,30 @@ gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringEqualsCaseASCII(const char *a, const char *b) StringEqualsCaseASCII(const char *a, const char *b)
{ {
assert(a != nullptr); #if !CLANG_CHECK_VERSION(3,6)
assert(b != nullptr); /* 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 /* note: strcasecmp() depends on the locale, but for ASCII-only
strings, it's safe to use */ strings, it's safe to use */
return strcasecmp(a, b) == 0; return strcasecmp(a, b) == 0;
} }
gcc_pure gcc_nonnull_all gcc_pure gcc_nonnull_all
static inline bool static inline bool
StringEqualsCaseASCII(const char *a, const char *b, size_t n) StringEqualsCaseASCII(const char *a, const char *b, size_t n)
{ {
assert(a != nullptr); #if !CLANG_CHECK_VERSION(3,6)
assert(b != nullptr); /* 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 /* note: strcasecmp() depends on the locale, but for ASCII-only
strings, it's safe to use */ strings, it's safe to use */
return strncasecmp(a, b, n) == 0; return strncasecmp(a, b, n) == 0;
} }
#endif #endif

View File

@@ -35,7 +35,7 @@
#include <new> #include <new>
#include <utility> #include <utility>
#if !defined(__clang__) && __GNUC__ && !GCC_CHECK_VERSION(4,8) #if GCC_OLDER_THAN(4,8)
#include <type_traits> #include <type_traits>
#endif #endif
@@ -54,7 +54,7 @@
*/ */
template<class T> template<class T>
class Manual { 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 */ /* no alignas() on gcc < 4.8: apply worst-case fallback */
__attribute__((aligned(8))) __attribute__((aligned(8)))
#else #else

View File

@@ -44,6 +44,23 @@ uri_get_suffix(const char *uri)
return suffix; 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 * static const char *
verify_uri_segment(const char *p) verify_uri_segment(const char *p)
{ {
@@ -111,8 +128,11 @@ uri_remove_auth(const char *uri)
bool bool
uri_is_child(const char *parent, const char *child) 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(parent != nullptr);
assert(child != nullptr); assert(child != nullptr);
#endif
const size_t parent_length = strlen(parent); const size_t parent_length = strlen(parent);
return memcmp(parent, child, parent_length) == 0 && return memcmp(parent, child, parent_length) == 0 &&

View File

@@ -35,6 +35,17 @@ gcc_pure
const char * const char *
uri_get_suffix(const char *uri); 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: * Returns true if this is a safe "local" URI:
* *

View File

@@ -33,6 +33,25 @@ public:
uri_get_suffix(".jpg")); uri_get_suffix(".jpg"));
CPPUNIT_ASSERT_EQUAL((const char *)nullptr, CPPUNIT_ASSERT_EQUAL((const char *)nullptr,
uri_get_suffix("/foo/.jpg")); 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() { void TestRemoveAuth() {