[Pkg-mpd-commits] [pkg-mpd] 06/12: Imported Upstream version 0.18.5

Florian Schlichting fsfs at moszumanska.debian.org
Sat Nov 23 21:03:44 UTC 2013


This is an automated email from the git hooks/post-receive script.

fsfs pushed a commit to branch master
in repository pkg-mpd.

commit 7abac8efa75cdb674843206b020f20591e759382
Author: Florian Schlichting <fsfs at debian.org>
Date:   Sat Nov 23 21:26:24 2013 +0100

    Imported Upstream version 0.18.5
---
 NEWS                                 | 16 ++++++++
 configure                            | 74 +++++++++++++++++++++++++++++-------
 configure.ac                         | 10 +++--
 doc/doxygen.conf                     |  4 +-
 src/DatabaseGlue.cxx                 |  6 +--
 src/DatabasePlugin.hxx               |  9 +++++
 src/DatabaseSimple.hxx               | 16 +-------
 src/Mapper.cxx                       |  4 +-
 src/Mapper.hxx                       |  3 +-
 src/Stats.cxx                        | 62 +++++++++++++++++++-----------
 src/Stats.hxx                        | 20 ----------
 src/archive/Iso9660ArchivePlugin.cxx |  6 +--
 src/db/ProxyDatabasePlugin.cxx       | 10 +++++
 src/db/SimpleDatabasePlugin.hxx      | 11 ++----
 src/decoder/DsdiffDecoderPlugin.cxx  |  5 +--
 src/decoder/DsfDecoderPlugin.cxx     |  4 +-
 src/decoder/OggFind.cxx              |  2 +
 src/input/CurlInputPlugin.cxx        | 32 ++++++++++++++++
 src/pcm/PcmResample.cxx              | 23 +++++++++++
 src/pcm/PcmResample.hxx              |  8 +---
 src/pcm/PcmResampleInternal.hxx      |  9 +++++
 src/pcm/PcmResampleLibsamplerate.cxx | 25 ++++++++++++
 src/pcm/PcmUtils.hxx                 | 12 ++++++
 src/system/ByteOrder.hxx             | 20 ++++++++--
 src/system/fd_util.h                 |  5 +++
 25 files changed, 287 insertions(+), 109 deletions(-)

diff --git a/NEWS b/NEWS
index 86ab1a2..9301f1d 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,19 @@
+ver 0.18.5 (2013/11/23)
+* configuration
+  - fix crash when db_file is configured without music_directory
+  - fix crash on "stats" without db_file/music_directory
+* database
+  - proxy: auto-reload statistics
+  - proxy: provide "db_update" in "stats" response
+* input
+  - curl: work around stream resume bug (fixed in libcurl 7.32.0)
+* decoder
+  - fluidsynth: auto-detect by default
+* clip 24 bit data from libsamplerate
+* fix ia64, mipsel and other little-endian architectures
+* fix build failures due to missing includes
+* fix build failure with static libmpdclient
+
 ver 0.18.4 (2013/11/13)
 * decoder
   - dsdiff: fix byte order bug
diff --git a/configure b/configure
index 5dbd635..ff42a46 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.69 for mpd 0.18.4.
+# Generated by GNU Autoconf 2.69 for mpd 0.18.5.
 #
 # Report bugs to <musicpd-dev-team at lists.sourceforge.net>.
 #
@@ -580,8 +580,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='mpd'
 PACKAGE_TARNAME='mpd'
-PACKAGE_VERSION='0.18.4'
-PACKAGE_STRING='mpd 0.18.4'
+PACKAGE_VERSION='0.18.5'
+PACKAGE_STRING='mpd 0.18.5'
 PACKAGE_BUGREPORT='musicpd-dev-team at lists.sourceforge.net'
 PACKAGE_URL=''
 
@@ -1673,7 +1673,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures mpd 0.18.4 to adapt to many kinds of systems.
+\`configure' configures mpd 0.18.5 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1743,7 +1743,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of mpd 0.18.4:";;
+     short | recursive ) echo "Configuration of mpd 0.18.5:";;
    esac
   cat <<\_ACEOF
 
@@ -2039,7 +2039,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-mpd configure 0.18.4
+mpd configure 0.18.5
 generated by GNU Autoconf 2.69
 
 Copyright (C) 2012 Free Software Foundation, Inc.
@@ -2492,7 +2492,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by mpd $as_me 0.18.4, which was
+It was created by mpd $as_me 0.18.5, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   $ $0 $@
@@ -3314,7 +3314,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='mpd'
- VERSION='0.18.4'
+ VERSION='0.18.5'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -10595,7 +10595,9 @@ fi
 
 enable_flac_encoder=$enable_flac
 
-if test x$enable_fluidsynth = xyes; then
+
+
+	if eval "test x`echo '$'enable_fluidsynth` != xno"; then
 
 pkg_failed=no
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for FLUIDSYNTH" >&5
@@ -10657,19 +10659,63 @@ fi
 
 	{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-                enable_fluidsynth=no
+                eval "found_fluidsynth=no"
 elif test $pkg_failed = untried; then
-	enable_fluidsynth=no
+	eval "found_fluidsynth=no"
 else
 	FLUIDSYNTH_CFLAGS=$pkg_cv_FLUIDSYNTH_CFLAGS
 	FLUIDSYNTH_LIBS=$pkg_cv_FLUIDSYNTH_LIBS
         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
+	eval "found_fluidsynth=yes"
+fi
+	fi
+
+
+	name="fluidsynth"
+	var="enable_fluidsynth"
+	found="found_$name"
+	feature="fluidsynth decoder"
+	msg="fluidsynth not found"
+
+	if eval "test x`echo '$'$var` = xno"; then
+		eval "$found=no"
+	fi
+
+	if eval "test x`echo '$'$found` = xyes"; then
+
+	var="enable_$name"
+	feature="$feature"
+
+	if eval "test x`echo '$'$var` = xauto"; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: auto-detected $feature" >&5
+$as_echo "$as_me: auto-detected $feature" >&6;}
+		eval "$var=yes"
+	fi
+
+	else
+
+	var="enable_$name"
+	feature="$feature"
+	msg="$msg"
+
+	if eval "test x`echo '$'$var` = xauto"; then
+		{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $msg -- disabling $feature" >&5
+$as_echo "$as_me: WARNING: $msg -- disabling $feature" >&2;}
+		eval "$var=no"
+	elif eval "test x`echo '$'$var` = xyes"; then
+		as_fn_error $? "$feature: $msg" "$LINENO" 5
+	fi
+
+	fi
+
+
+
+if test x$enable_fluidsynth = xyes; then
 
 $as_echo "#define ENABLE_FLUIDSYNTH 1" >>confdefs.h
 
 fi
-fi
 
  if test x$enable_fluidsynth = xyes; then
   ENABLE_FLUIDSYNTH_TRUE=
@@ -18227,7 +18273,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by mpd $as_me 0.18.4, which was
+This file was extended by mpd $as_me 0.18.5, which was
 generated by GNU Autoconf 2.69.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -18293,7 +18339,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-mpd config.status 0.18.4
+mpd config.status 0.18.5
 configured by $0, generated by GNU Autoconf 2.69,
   with options \\"\$ac_cs_config\\"
 
diff --git a/configure.ac b/configure.ac
index 6805a5d..b55c19e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,6 +1,6 @@
 AC_PREREQ(2.60)
 
-AC_INIT(mpd, 0.18.4, musicpd-dev-team at lists.sourceforge.net)
+AC_INIT(mpd, 0.18.5, musicpd-dev-team at lists.sourceforge.net)
 
 VERSION_MAJOR=0
 VERSION_MINOR=18
@@ -874,10 +874,12 @@ AM_CONDITIONAL(HAVE_FLAC, test x$enable_flac = xyes)
 enable_flac_encoder=$enable_flac
 
 dnl -------------------------------- FluidSynth -------------------------------
+
+MPD_AUTO_PKG(fluidsynth, FLUIDSYNTH, [fluidsynth >= 1.1],
+	[fluidsynth decoder], [fluidsynth not found])
+
 if test x$enable_fluidsynth = xyes; then
-	PKG_CHECK_MODULES(FLUIDSYNTH, [fluidsynth >= 1.1],
-		AC_DEFINE(ENABLE_FLUIDSYNTH, 1, [Define for fluidsynth support]),
-		enable_fluidsynth=no)
+	AC_DEFINE(ENABLE_FLUIDSYNTH, 1, [Define for fluidsynth support])
 fi
 
 AM_CONDITIONAL(ENABLE_FLUIDSYNTH, test x$enable_fluidsynth = xyes)
diff --git a/doc/doxygen.conf b/doc/doxygen.conf
index f9bd1d1..e56193b 100644
--- a/doc/doxygen.conf
+++ b/doc/doxygen.conf
@@ -31,7 +31,7 @@ PROJECT_NAME           = MPD
 # This could be handy for archiving the generated documentation or
 # if some version control system is used.
 
-PROJECT_NUMBER = 0.18.4
+PROJECT_NUMBER = 0.18.5
 
 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute)
 # base path where the generated documentation will be put.
@@ -534,7 +534,7 @@ WARN_LOGFILE           =
 # directories like "/usr/src/myproject". Separate the files or directories
 # with spaces.
 
-INPUT = /home/max/git/mpd/src/
+INPUT = /home/max/git/stable-mpd/src/
 
 # This tag can be used to specify the character encoding of the source files
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is
diff --git a/src/DatabaseGlue.cxx b/src/DatabaseGlue.cxx
index e845037..013a3e3 100644
--- a/src/DatabaseGlue.cxx
+++ b/src/DatabaseGlue.cxx
@@ -148,12 +148,12 @@ DatabaseGlobalOpen(Error &error)
 	return true;
 }
 
-time_t
-db_get_mtime(void)
+bool
+db_exists()
 {
 	assert(db != nullptr);
 	assert(db_is_open);
 	assert(db_is_simple());
 
-	return ((SimpleDatabase *)db)->GetLastModified();
+	return ((SimpleDatabase *)db)->GetUpdateStamp() > 0;
 }
diff --git a/src/DatabasePlugin.hxx b/src/DatabasePlugin.hxx
index 629dff3..ccf8993 100644
--- a/src/DatabasePlugin.hxx
+++ b/src/DatabasePlugin.hxx
@@ -30,6 +30,8 @@
 #include "tag/TagType.h"
 #include "Compiler.h"
 
+#include <time.h>
+
 struct config_param;
 struct DatabaseSelection;
 struct db_visitor;
@@ -132,6 +134,13 @@ public:
 	virtual bool GetStats(const DatabaseSelection &selection,
 			      DatabaseStats &stats,
 			      Error &error) const = 0;
+
+	/**
+	 * Returns the time stamp of the last database update.
+	 * Returns 0 if that is not not known/available.
+	 */
+	gcc_pure
+	virtual time_t GetUpdateStamp() const = 0;
 };
 
 struct DatabasePlugin {
diff --git a/src/DatabaseSimple.hxx b/src/DatabaseSimple.hxx
index 124d78a..6d52ac0 100644
--- a/src/DatabaseSimple.hxx
+++ b/src/DatabaseSimple.hxx
@@ -63,24 +63,12 @@ bool
 db_save(Error &error);
 
 /**
- * May only be used if db_is_simple() returns true.
- */
-gcc_pure
-time_t
-db_get_mtime(void);
-
-/**
  * Returns true if there is a valid database file on the disk.
  *
  * May only be used if db_is_simple() returns true.
  */
 gcc_pure
-static inline bool
-db_exists(void)
-{
-	/* mtime is set only if the database file was loaded or saved
-	   successfully */
-	return db_get_mtime() > 0;
-}
+bool
+db_exists();
 
 #endif
diff --git a/src/Mapper.cxx b/src/Mapper.cxx
index 0859773..cbe45da 100644
--- a/src/Mapper.cxx
+++ b/src/Mapper.cxx
@@ -133,7 +133,9 @@ void mapper_finish(void)
 const char *
 mapper_get_music_directory_utf8(void)
 {
-	return music_dir_utf8.c_str();
+	return music_dir_utf8.empty()
+		? nullptr
+		: music_dir_utf8.c_str();
 }
 
 const AllocatedPath &
diff --git a/src/Mapper.hxx b/src/Mapper.hxx
index be69a71..947fd28 100644
--- a/src/Mapper.hxx
+++ b/src/Mapper.hxx
@@ -41,7 +41,8 @@ mapper_init(AllocatedPath &&music_dir, AllocatedPath &&playlist_dir);
 void mapper_finish(void);
 
 /**
- * Return the absolute path of the music directory encoded in UTF-8.
+ * Return the absolute path of the music directory encoded in UTF-8 or
+ * nullptr if no music directory was configured.
  */
 gcc_const
 const char *
diff --git a/src/Stats.cxx b/src/Stats.cxx
index 88f7692..f224bdf 100644
--- a/src/Stats.cxx
+++ b/src/Stats.cxx
@@ -30,59 +30,75 @@
 
 #include <glib.h>
 
-struct stats stats;
+static GTimer *uptime;
+static DatabaseStats stats;
 
 void stats_global_init(void)
 {
-	stats.timer = g_timer_new();
+	uptime = g_timer_new();
 }
 
 void stats_global_finish(void)
 {
-	g_timer_destroy(stats.timer);
+	g_timer_destroy(uptime);
 }
 
 void stats_update(void)
 {
+	assert(GetDatabase() != nullptr);
+
 	Error error;
 
 	DatabaseStats stats2;
 
 	const DatabaseSelection selection("", true);
 	if (GetDatabase()->GetStats(selection, stats2, error)) {
-		stats.song_count = stats2.song_count;
-		stats.song_duration = stats2.total_duration;
-		stats.artist_count = stats2.artist_count;
-		stats.album_count = stats2.album_count;
+		stats = stats2;
 	} else {
 		LogError(error);
 
-		stats.song_count = 0;
-		stats.song_duration = 0;
-		stats.artist_count = 0;
-		stats.album_count = 0;
+		stats.Clear();
 	}
 }
 
-void
-stats_print(Client &client)
+static void
+db_stats_print(Client &client)
 {
+	assert(GetDatabase() != nullptr);
+
+	if (!db_is_simple())
+		/* reload statistics if we're using the "proxy"
+		   database plugin */
+		/* TODO: move this into the "proxy" database plugin as
+		   an "idle" handler */
+		stats_update();
+
 	client_printf(client,
 		      "artists: %u\n"
 		      "albums: %u\n"
-		      "songs: %i\n"
-		      "uptime: %li\n"
-		      "playtime: %li\n"
-		      "db_playtime: %li\n",
+		      "songs: %u\n"
+		      "db_playtime: %lu\n",
 		      stats.artist_count,
 		      stats.album_count,
 		      stats.song_count,
-		      (long)g_timer_elapsed(stats.timer, NULL),
-		      (long)(client.player_control.GetTotalPlayTime() + 0.5),
-		      stats.song_duration);
+		      stats.total_duration);
 
-	if (db_is_simple())
+	const time_t update_stamp = GetDatabase()->GetUpdateStamp();
+	if (update_stamp > 0)
 		client_printf(client,
-			      "db_update: %li\n",
-			      (long)db_get_mtime());
+			      "db_update: %lu\n",
+			      (unsigned long)update_stamp);
+}
+
+void
+stats_print(Client &client)
+{
+	client_printf(client,
+		      "uptime: %lu\n"
+		      "playtime: %lu\n",
+		      (unsigned long)g_timer_elapsed(uptime, NULL),
+		      (unsigned long)(client.player_control.GetTotalPlayTime() + 0.5));
+
+	if (GetDatabase() != nullptr)
+		db_stats_print(client);
 }
diff --git a/src/Stats.hxx b/src/Stats.hxx
index 1b14135..dd131ce 100644
--- a/src/Stats.hxx
+++ b/src/Stats.hxx
@@ -21,26 +21,6 @@
 #define MPD_STATS_HXX
 
 class Client;
-typedef struct _GTimer GTimer;
-
-struct stats {
-	GTimer *timer;
-
-	/** number of song files in the music directory */
-	unsigned song_count;
-
-	/** sum of all song durations in the music directory (in
-	    seconds) */
-	unsigned long song_duration;
-
-	/** number of distinct artist names in the music directory */
-	unsigned artist_count;
-
-	/** number of distinct album names in the music directory */
-	unsigned album_count;
-};
-
-extern struct stats stats;
 
 void stats_global_init(void);
 
diff --git a/src/archive/Iso9660ArchivePlugin.cxx b/src/archive/Iso9660ArchivePlugin.cxx
index 8233d03..ad21d4a 100644
--- a/src/archive/Iso9660ArchivePlugin.cxx
+++ b/src/archive/Iso9660ArchivePlugin.cxx
@@ -190,18 +190,16 @@ iso9660_input_read(InputStream *is, void *ptr, size_t size,
 		   Error &error)
 {
 	Iso9660InputStream *iis = (Iso9660InputStream *)is;
-	int toread, readed = 0;
+	int readed = 0;
 	int no_blocks, cur_block;
 	size_t left_bytes = iis->statbuf->size - is->offset;
 
 	size = (size * ISO_BLOCKSIZE) / ISO_BLOCKSIZE;
 
 	if (left_bytes < size) {
-		toread = left_bytes;
 		no_blocks = CEILING(left_bytes,ISO_BLOCKSIZE);
 	} else {
-		toread = size;
-		no_blocks = toread / ISO_BLOCKSIZE;
+		no_blocks = size / ISO_BLOCKSIZE;
 	}
 	if (no_blocks > 0) {
 
diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx
index fc99242..00b5d44 100644
--- a/src/db/ProxyDatabasePlugin.cxx
+++ b/src/db/ProxyDatabasePlugin.cxx
@@ -46,6 +46,9 @@ class ProxyDatabase : public Database {
 	struct mpd_connection *connection;
 	Directory *root;
 
+	/* this is mutable because GetStats() must be "const" */
+	mutable time_t update_stamp;
+
 public:
 	static Database *Create(const config_param &param,
 				Error &error);
@@ -71,6 +74,10 @@ public:
 			      DatabaseStats &stats,
 			      Error &error) const override;
 
+	virtual time_t GetUpdateStamp() const override {
+		return update_stamp;
+	}
+
 private:
 	bool Configure(const config_param &param, Error &error);
 
@@ -237,6 +244,7 @@ ProxyDatabase::Open(Error &error)
 		return false;
 
 	root = Directory::NewRoot();
+	update_stamp = 0;
 
 	return true;
 }
@@ -631,6 +639,8 @@ ProxyDatabase::GetStats(const DatabaseSelection &selection,
 	if (stats2 == nullptr)
 		return CheckError(connection, error);
 
+	update_stamp = (time_t)mpd_stats_get_db_update_time(stats2);
+
 	stats.song_count = mpd_stats_get_number_of_songs(stats2);
 	stats.total_duration = mpd_stats_get_db_play_time(stats2);
 	stats.artist_count = mpd_stats_get_number_of_artists(stats2);
diff --git a/src/db/SimpleDatabasePlugin.hxx b/src/db/SimpleDatabasePlugin.hxx
index 24e150a..dfe981d 100644
--- a/src/db/SimpleDatabasePlugin.hxx
+++ b/src/db/SimpleDatabasePlugin.hxx
@@ -26,8 +26,6 @@
 
 #include <cassert>
 
-#include <time.h>
-
 struct Directory;
 
 class SimpleDatabase : public Database {
@@ -55,11 +53,6 @@ public:
 
 	bool Save(Error &error);
 
-	gcc_pure
-	time_t GetLastModified() const {
-		return mtime;
-	}
-
 	static Database *Create(const config_param &param,
 				Error &error);
 
@@ -85,6 +78,10 @@ public:
 			      DatabaseStats &stats,
 			      Error &error) const override;
 
+	virtual time_t GetUpdateStamp() const override {
+		return mtime;
+	}
+
 protected:
 	bool Configure(const config_param &param, Error &error);
 
diff --git a/src/decoder/DsdiffDecoderPlugin.cxx b/src/decoder/DsdiffDecoderPlugin.cxx
index 347f5b5..a3c0149 100644
--- a/src/decoder/DsdiffDecoderPlugin.cxx
+++ b/src/decoder/DsdiffDecoderPlugin.cxx
@@ -294,7 +294,6 @@ dsdiff_read_metadata_extra(Decoder *decoder, InputStream &is,
 			if (!dsdiff_read_chunk_header(decoder, is, chunk_header))
 				return false;
 		}
-		chunk_size = 0;
 	}
 	/* done processing chunk headers, process tags if any */
 
@@ -385,10 +384,10 @@ dsdiff_decode_chunk(Decoder &decoder, InputStream &is,
 	while (chunk_size > 0) {
 		/* see how much aligned data from the remaining chunk
 		   fits into the local buffer */
-		unsigned now_frames = buffer_frames;
 		size_t now_size = buffer_size;
 		if (chunk_size < (uint64_t)now_size) {
-			now_frames = (unsigned)chunk_size / frame_size;
+			unsigned now_frames =
+				(unsigned)chunk_size / frame_size;
 			now_size = now_frames * frame_size;
 		}
 
diff --git a/src/decoder/DsfDecoderPlugin.cxx b/src/decoder/DsfDecoderPlugin.cxx
index 0507f50..5ef94e6 100644
--- a/src/decoder/DsfDecoderPlugin.cxx
+++ b/src/decoder/DsfDecoderPlugin.cxx
@@ -240,10 +240,10 @@ dsf_decode_chunk(Decoder &decoder, InputStream &is,
 	while (chunk_size > 0) {
 		/* see how much aligned data from the remaining chunk
 		   fits into the local buffer */
-		unsigned now_frames = buffer_frames;
 		size_t now_size = buffer_size;
 		if (chunk_size < (uint64_t)now_size) {
-			now_frames = (unsigned)chunk_size / frame_size;
+			unsigned now_frames =
+				(unsigned)chunk_size / frame_size;
 			now_size = now_frames * frame_size;
 		}
 
diff --git a/src/decoder/OggFind.cxx b/src/decoder/OggFind.cxx
index 821f75c..65c7fa3 100644
--- a/src/decoder/OggFind.cxx
+++ b/src/decoder/OggFind.cxx
@@ -22,6 +22,8 @@
 #include "OggSyncState.hxx"
 #include "util/Error.hxx"
 
+#include <stdio.h>
+
 bool
 OggFindEOS(OggSyncState &oy, ogg_stream_state &os, ogg_packet &packet)
 {
diff --git a/src/input/CurlInputPlugin.cxx b/src/input/CurlInputPlugin.cxx
index 841db6c..b785459 100644
--- a/src/input/CurlInputPlugin.cxx
+++ b/src/input/CurlInputPlugin.cxx
@@ -273,12 +273,27 @@ public:
 		SocketAction(CURL_SOCKET_TIMEOUT, 0);
 	}
 
+	/**
+	 * This is a kludge to allow pausing/resuming a stream with
+	 * libcurl < 7.32.0.  Read the curl_easy_pause manpage for
+	 * more information.
+	 */
+	void ResumeSockets() {
+		int running_handles;
+		curl_multi_socket_all(multi, &running_handles);
+	}
+
 private:
 	static int TimerFunction(CURLM *multi, long timeout_ms, void *userp);
 
 	virtual void OnTimeout() override;
 };
 
+/**
+ * libcurl version number encoded in a 24 bit integer.
+ */
+static unsigned curl_version_num;
+
 /** libcurl should accept "ICY 200 OK" */
 static struct curl_slist *http_200_aliases;
 
@@ -330,6 +345,13 @@ input_curl_resume(struct input_curl *c)
 	if (c->paused) {
 		c->paused = false;
 		curl_easy_pause(c->easy, CURLPAUSE_CONT);
+
+		if (curl_version_num < 0x072000)
+			/* libcurl older than 7.32.0 does not update
+			   its sockets after curl_easy_pause(); force
+			   libcurl to do it now */
+			curl_multi->ResumeSockets();
+
 		curl_multi->InvalidateSockets();
 	}
 }
@@ -586,6 +608,16 @@ input_curl_init(const config_param &param, Error &error)
 		return false;
 	}
 
+	const auto version_info = curl_version_info(CURLVERSION_FIRST);
+	if (version_info != nullptr) {
+		FormatDebug(curl_domain, "version %s", version_info->version);
+		if (version_info->features & CURL_VERSION_SSL)
+			FormatDebug(curl_domain, "with %s",
+				    version_info->ssl_version);
+
+		curl_version_num = version_info->version_num;
+	}
+
 	http_200_aliases = curl_slist_append(http_200_aliases, "ICY 200 OK");
 
 	proxy = param.GetBlockValue("proxy");
diff --git a/src/pcm/PcmResample.cxx b/src/pcm/PcmResample.cxx
index e2ce095..01f269e 100644
--- a/src/pcm/PcmResample.cxx
+++ b/src/pcm/PcmResample.cxx
@@ -148,3 +148,26 @@ PcmResampler::Resample32(unsigned channels, unsigned src_rate,
 					src_rate, src_buffer, src_size,
 					dest_rate, dest_size_r);
 }
+
+const int32_t *
+PcmResampler::Resample24(unsigned channels, unsigned src_rate,
+			 const int32_t *src_buffer, size_t src_size,
+			 unsigned dest_rate, size_t *dest_size_r,
+			 Error &error_r)
+{
+#ifdef HAVE_LIBSAMPLERATE
+	if (pcm_resample_lsr_enabled())
+		return pcm_resample_lsr_24(this, channels,
+					   src_rate, src_buffer, src_size,
+					   dest_rate, dest_size_r,
+					   error_r);
+#else
+	(void)error_r;
+#endif
+
+	/* reuse the 32 bit code - the resampler code doesn't care if
+	   the upper 8 bits are actually used */
+	return pcm_resample_fallback_32(this, channels,
+					src_rate, src_buffer, src_size,
+					dest_rate, dest_size_r);
+}
diff --git a/src/pcm/PcmResample.hxx b/src/pcm/PcmResample.hxx
index 8a74074..e839d6e 100644
--- a/src/pcm/PcmResample.hxx
+++ b/src/pcm/PcmResample.hxx
@@ -124,13 +124,7 @@ struct PcmResampler {
 	const int32_t *Resample24(unsigned channels, unsigned src_rate,
 				  const int32_t *src_buffer, size_t src_size,
 				  unsigned dest_rate, size_t *dest_size_r,
-				  Error &error_r)
-	{
-		/* reuse the 32 bit code - the resampler code doesn't care if
-		   the upper 8 bits are actually used */
-		return Resample32(channels, src_rate, src_buffer, src_size,
-				  dest_rate, dest_size_r, error_r);
-	}
+				  Error &error_r);
 };
 
 bool
diff --git a/src/pcm/PcmResampleInternal.hxx b/src/pcm/PcmResampleInternal.hxx
index 59bb2f5..5090c13 100644
--- a/src/pcm/PcmResampleInternal.hxx
+++ b/src/pcm/PcmResampleInternal.hxx
@@ -69,6 +69,15 @@ pcm_resample_lsr_32(PcmResampler *state,
 		    unsigned dest_rate, size_t *dest_size_r,
 		    Error &error);
 
+const int32_t *
+pcm_resample_lsr_24(PcmResampler *state,
+		    unsigned channels,
+		    unsigned src_rate,
+		    const int32_t *src_buffer,
+		    size_t src_size,
+		    unsigned dest_rate, size_t *dest_size_r,
+		    Error &error);
+
 #endif
 
 const int16_t *
diff --git a/src/pcm/PcmResampleLibsamplerate.cxx b/src/pcm/PcmResampleLibsamplerate.cxx
index 1986e88..9eac2d5 100644
--- a/src/pcm/PcmResampleLibsamplerate.cxx
+++ b/src/pcm/PcmResampleLibsamplerate.cxx
@@ -19,6 +19,7 @@
 
 #include "config.h"
 #include "PcmResampleInternal.hxx"
+#include "PcmUtils.hxx"
 #include "util/ASCII.hxx"
 #include "util/Error.hxx"
 #include "util/Domain.hxx"
@@ -283,3 +284,27 @@ pcm_resample_lsr_32(PcmResampler *state,
 
 	return dest_buffer;
 }
+
+const int32_t *
+pcm_resample_lsr_24(PcmResampler *state,
+		    unsigned channels,
+		    unsigned src_rate,
+		    const int32_t *src_buffer, size_t src_size,
+		    unsigned dest_rate, size_t *dest_size_r,
+		    Error &error)
+{
+	const auto result = pcm_resample_lsr_32(state, channels,
+						src_rate, src_buffer, src_size,
+						dest_rate, dest_size_r,
+						error);
+	if (result != nullptr)
+		/* src_float_to_int_array() clamps for 32 bit
+		   integers; now make sure everything's fine for 24
+		   bit */
+		/* TODO: eliminate the 32 bit clamp to reduce overhead */
+		PcmClampN<int32_t, int32_t, 24>(const_cast<int32_t *>(result),
+						result,
+						*dest_size_r / sizeof(*result));
+
+	return result;
+}
diff --git a/src/pcm/PcmUtils.hxx b/src/pcm/PcmUtils.hxx
index 108ba85..febe12d 100644
--- a/src/pcm/PcmUtils.hxx
+++ b/src/pcm/PcmUtils.hxx
@@ -63,4 +63,16 @@ PcmClamp(U x)
 	return T(x);
 }
 
+/**
+ * Check if the values in this buffer are within the range of the
+ * provided bit size, and clamps them whenever necessary.
+ */
+template<typename T, typename U, unsigned bits>
+static inline void
+PcmClampN(T *dest, const U *src, unsigned n)
+{
+	while (n-- > 0)
+		*dest++ = PcmClamp<T, U, bits>(*src++);
+}
+
 #endif
diff --git a/src/system/ByteOrder.hxx b/src/system/ByteOrder.hxx
index 6220032..8beda61 100644
--- a/src/system/ByteOrder.hxx
+++ b/src/system/ByteOrder.hxx
@@ -33,11 +33,23 @@
 #include <stdint.h>
 
 #if defined(__i386__) || defined(__x86_64__) || defined(__ARMEL__)
-#define IS_LITTLE_ENDIAN true
-#define IS_BIG_ENDIAN false
+/* well-known little-endian */
+#  define IS_LITTLE_ENDIAN true
+#  define IS_BIG_ENDIAN false
+#elif defined(__MIPSEB__)
+/* well-known big-endian */
+#  define IS_LITTLE_ENDIAN false
+#  define IS_BIG_ENDIAN true
 #else
-#define IS_LITTLE_ENDIAN false
-#define IS_BIG_ENDIAN true
+/* generic compile-time check */
+#  include <endian.h>
+#  if __BYTE_ORDER == __LITTLE_ENDIAN
+#    define IS_LITTLE_ENDIAN true
+#    define IS_BIG_ENDIAN false
+#  else
+#    define IS_LITTLE_ENDIAN false
+#    define IS_BIG_ENDIAN true
+#  endif
 #endif
 
 static inline constexpr bool
diff --git a/src/system/fd_util.h b/src/system/fd_util.h
index 9003b16..b7a9a6d 100644
--- a/src/system/fd_util.h
+++ b/src/system/fd_util.h
@@ -104,6 +104,11 @@ socketpair_cloexec_nonblock(int domain, int type, int protocol, int sv[2]);
 
 #endif
 
+#ifdef HAVE_LIBMPDCLIENT
+/* Avoid symbol conflict with statically linked libmpdclient */
+#define socket_cloexec_nonblock socket_cloexec_nonblock_noconflict
+#endif
+
 /**
  * Wrapper for socket(), which sets the CLOEXEC and the NONBLOCK flag
  * (atomically if supported by the OS).

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mpd/pkg-mpd.git



More information about the Pkg-mpd-commits mailing list