diff options
author | Max Kellermann <max@musicpd.org> | 2018-02-11 13:22:43 +0100 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-02-11 13:22:43 +0100 |
commit | 65bbb0e0aa0f613a9da683900838d2912f2454ba (patch) | |
tree | 3527ff6fdec933826a9278a611166d4b69f14827 /src | |
parent | 5147654f6c6e452132be6bd4b8d525d1c1856878 (diff) | |
parent | c2940a8385201b6501a43aefa6f9bee983950c01 (diff) |
Merge tag 'v0.20.17'
release v0.20.17
Diffstat (limited to 'src')
-rw-r--r-- | src/SongSave.cxx | 3 | ||||
-rw-r--r-- | src/db/update/Service.cxx | 3 | ||||
-rw-r--r-- | src/filter/plugins/ConvertFilterPlugin.cxx | 3 | ||||
-rw-r--r-- | src/input/plugins/FileInputPlugin.cxx | 3 | ||||
-rw-r--r-- | src/lib/curl/patches/no_netrc.patch | 20 | ||||
-rw-r--r-- | src/lib/curl/patches/only_lib.patch | 15 | ||||
-rw-r--r-- | src/lib/curl/patches/series | 2 | ||||
-rw-r--r-- | src/mixer/plugins/volume_mapping.c | 7 | ||||
-rw-r--r-- | src/pcm/Order.cxx | 2 | ||||
-rw-r--r-- | src/protocol/ArgParser.cxx | 3 | ||||
-rw-r--r-- | src/queue/PlaylistState.cxx | 7 | ||||
-rw-r--r-- | src/tag/ReplayGain.cxx | 9 | ||||
-rw-r--r-- | src/thread/Util.cxx | 26 | ||||
-rw-r--r-- | src/util/NumberParser.hxx | 5 |
14 files changed, 92 insertions, 16 deletions
diff --git a/src/SongSave.cxx b/src/SongSave.cxx index ab80c5c75..c3593d823 100644 --- a/src/SongSave.cxx +++ b/src/SongSave.cxx @@ -30,6 +30,7 @@ #include "util/ChronoUtil.hxx" #include "util/StringStrip.hxx" #include "util/RuntimeError.hxx" +#include "util/NumberParser.hxx" #include <string.h> #include <stdlib.h> @@ -98,7 +99,7 @@ song_load(TextFile &file, const char *uri) if ((type = tag_name_parse(line)) != TAG_NUM_OF_ITEM_TYPES) { tag.AddItem(type, value); } else if (strcmp(line, "Time") == 0) { - tag.SetDuration(SignedSongTime::FromS(atof(value))); + tag.SetDuration(SignedSongTime::FromS(ParseDouble(value))); } else if (strcmp(line, "Playlist") == 0) { tag.SetHasPlaylist(strcmp(value, "yes") == 0); } else if (strcmp(line, SONG_MTIME) == 0) { diff --git a/src/db/update/Service.cxx b/src/db/update/Service.cxx index ded404424..d115fb5d9 100644 --- a/src/db/update/Service.cxx +++ b/src/db/update/Service.cxx @@ -29,6 +29,7 @@ #include "Idle.hxx" #include "Log.hxx" #include "thread/Thread.hxx" +#include "thread/Name.hxx" #include "thread/Util.hxx" #ifndef NDEBUG @@ -111,6 +112,8 @@ UpdateService::Task() { assert(walk != nullptr); + SetThreadName("update"); + if (!next.path_utf8.empty()) FormatDebug(update_domain, "starting: %s", next.path_utf8.c_str()); diff --git a/src/filter/plugins/ConvertFilterPlugin.cxx b/src/filter/plugins/ConvertFilterPlugin.cxx index 77c82eea9..eaa5fc4a3 100644 --- a/src/filter/plugins/ConvertFilterPlugin.cxx +++ b/src/filter/plugins/ConvertFilterPlugin.cxx @@ -51,7 +51,8 @@ public: void Set(const AudioFormat &_out_audio_format); void Reset() noexcept override { - state.Reset(); + if (IsActive()) + state.Reset(); } ConstBuffer<void> FilterPCM(ConstBuffer<void> src) override; diff --git a/src/input/plugins/FileInputPlugin.cxx b/src/input/plugins/FileInputPlugin.cxx index 9e0398916..cc8e62413 100644 --- a/src/input/plugins/FileInputPlugin.cxx +++ b/src/input/plugins/FileInputPlugin.cxx @@ -65,10 +65,13 @@ OpenFileInputStream(Path path, throw FormatRuntimeError("Not a regular file: %s", path.c_str()); +#if !defined(__BIONIC__) || __ANDROID_API__ >= 21 + /* posix_fadvise() requires Android API 21 */ #ifdef POSIX_FADV_SEQUENTIAL posix_fadvise(reader.GetFD().Get(), (off_t)0, info.GetSize(), POSIX_FADV_SEQUENTIAL); #endif +#endif return std::make_unique<FileInputStream>(path.ToUTF8().c_str(), std::move(reader), info.GetSize(), diff --git a/src/lib/curl/patches/no_netrc.patch b/src/lib/curl/patches/no_netrc.patch new file mode 100644 index 000000000..22557d162 --- /dev/null +++ b/src/lib/curl/patches/no_netrc.patch @@ -0,0 +1,20 @@ +Index: curl-7.58.0/lib/url.c +=================================================================== +--- curl-7.58.0.orig/lib/url.c ++++ curl-7.58.0/lib/url.c +@@ -3503,6 +3503,7 @@ static CURLcode override_login(struct Cu + } + + conn->bits.netrc = FALSE; ++#ifndef __BIONIC__ + if(data->set.use_netrc != CURL_NETRC_IGNORED) { + int ret = Curl_parsenetrc(conn->host.name, + userp, passwdp, +@@ -3524,6 +3525,7 @@ static CURLcode override_login(struct Cu + conn->bits.user_passwd = TRUE; /* enable user+password */ + } + } ++#endif + + return CURLE_OK; + } diff --git a/src/lib/curl/patches/only_lib.patch b/src/lib/curl/patches/only_lib.patch new file mode 100644 index 000000000..2bc374983 --- /dev/null +++ b/src/lib/curl/patches/only_lib.patch @@ -0,0 +1,15 @@ +Index: curl-7.58.0/Makefile.in +=================================================================== +--- curl-7.58.0.orig/Makefile.in ++++ curl-7.58.0/Makefile.in +@@ -641,8 +641,8 @@ CLEANFILES = $(VC6_LIBDSP) $(VC6_SRCDSP) + $(VC14_LIBVCXPROJ) $(VC14_SRCVCXPROJ) $(VC15_LIBVCXPROJ) $(VC15_SRCVCXPROJ) + + bin_SCRIPTS = curl-config +-SUBDIRS = lib src +-DIST_SUBDIRS = $(SUBDIRS) tests packages scripts include docs ++SUBDIRS = lib ++DIST_SUBDIRS = $(SUBDIRS) include + pkgconfigdir = $(libdir)/pkgconfig + pkgconfig_DATA = libcurl.pc + LIB_VAUTH_CFILES = vauth/vauth.c vauth/cleartext.c vauth/cram.c \ diff --git a/src/lib/curl/patches/series b/src/lib/curl/patches/series new file mode 100644 index 000000000..f9bd7bfe3 --- /dev/null +++ b/src/lib/curl/patches/series @@ -0,0 +1,2 @@ +only_lib.patch +no_netrc.patch diff --git a/src/mixer/plugins/volume_mapping.c b/src/mixer/plugins/volume_mapping.c index 4e559cf54..2078d346d 100644 --- a/src/mixer/plugins/volume_mapping.c +++ b/src/mixer/plugins/volume_mapping.c @@ -139,6 +139,13 @@ static int set_normalized_volume(snd_mixer_elem_t *elem, return set_raw[ctl_dir](elem, value); } + /* two special cases to avoid rounding errors at 0% and + 100% */ + if (volume <= 0) + return set_dB[ctl_dir](elem, min, dir); + else if (volume >= 100) + return set_dB[ctl_dir](elem, max, dir); + if (use_linear_dB_scale(min, max)) { value = lrint_dir(volume * (max - min), dir) + min; return set_dB[ctl_dir](elem, value, dir); diff --git a/src/pcm/Order.cxx b/src/pcm/Order.cxx index 8f246bdce..3a1a412a8 100644 --- a/src/pcm/Order.cxx +++ b/src/pcm/Order.cxx @@ -88,7 +88,7 @@ static inline ConstBuffer<V> ToAlsaChannelOrder71(PcmBuffer &buffer, ConstBuffer<V> src) noexcept { auto dest = buffer.GetT<V>(src.size); - ToAlsaChannelOrder71(dest, src.data, src.size / 6); + ToAlsaChannelOrder71(dest, src.data, src.size / 8); return { dest, src.size }; } diff --git a/src/protocol/ArgParser.cxx b/src/protocol/ArgParser.cxx index 185c57863..47fdfa405 100644 --- a/src/protocol/ArgParser.cxx +++ b/src/protocol/ArgParser.cxx @@ -21,6 +21,7 @@ #include "ArgParser.hxx" #include "Ack.hxx" #include "Chrono.hxx" +#include "util/NumberParser.hxx" #include <stdlib.h> @@ -151,7 +152,7 @@ float ParseCommandArgFloat(const char *s) { char *endptr; - auto value = strtof(s, &endptr); + auto value = ParseFloat(s, &endptr); if (endptr == s || *endptr != 0) throw FormatProtocolError(ACK_ERROR_ARG, "Float expected: %s", s); diff --git a/src/queue/PlaylistState.cxx b/src/queue/PlaylistState.cxx index d08610efc..614f01c19 100644 --- a/src/queue/PlaylistState.cxx +++ b/src/queue/PlaylistState.cxx @@ -35,6 +35,7 @@ #include "util/CharUtil.hxx" #include "util/StringAPI.hxx" #include "util/StringCompare.hxx" +#include "util/NumberParser.hxx" #include "Log.hxx" #include <string.h> @@ -148,7 +149,7 @@ playlist_state_restore(const char *line, TextFile &file, while ((line = file.ReadLine()) != nullptr) { const char *p; if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_TIME))) { - seek_time = SongTime::FromS(atof(p)); + seek_time = SongTime::FromS(ParseDouble(p)); } else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_REPEAT))) { playlist.SetRepeat(pc, StringIsEqual(p, "1")); } else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_SINGLE))) { @@ -158,12 +159,12 @@ playlist_state_restore(const char *line, TextFile &file, } else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_CROSSFADE))) { pc.SetCrossFade(atoi(p)); } else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_MIXRAMPDB))) { - pc.SetMixRampDb(atof(p)); + pc.SetMixRampDb(ParseFloat(p)); } else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_MIXRAMPDELAY))) { /* this check discards "nan" which was used prior to MPD 0.18 */ if (IsDigitASCII(*p)) - pc.SetMixRampDelay(atof(p)); + pc.SetMixRampDelay(ParseFloat(p)); } else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_RANDOM))) { random_mode = StringIsEqual(p, "1"); } else if ((p = StringAfterPrefix(line, PLAYLIST_STATE_FILE_CURRENT))) { diff --git a/src/tag/ReplayGain.cxx b/src/tag/ReplayGain.cxx index 10f2f8a32..ccdcf3fc8 100644 --- a/src/tag/ReplayGain.cxx +++ b/src/tag/ReplayGain.cxx @@ -22,6 +22,7 @@ #include "VorbisComment.hxx" #include "ReplayGainInfo.hxx" #include "util/ASCII.hxx" +#include "util/NumberParser.hxx" #include <assert.h> #include <stdlib.h> @@ -33,16 +34,16 @@ ParseReplayGainTagTemplate(ReplayGainInfo &info, const T t) const char *value; if ((value = t["replaygain_track_gain"]) != nullptr) { - info.track.gain = atof(value); + info.track.gain = ParseFloat(value); return true; } else if ((value = t["replaygain_album_gain"]) != nullptr) { - info.album.gain = atof(value); + info.album.gain = ParseFloat(value); return true; } else if ((value = t["replaygain_track_peak"]) != nullptr) { - info.track.peak = atof(value); + info.track.peak = ParseFloat(value); return true; } else if ((value = t["replaygain_album_peak"]) != nullptr) { - info.album.peak = atof(value); + info.album.peak = ParseFloat(value); return true; } else return false; diff --git a/src/thread/Util.cxx b/src/thread/Util.cxx index d50d507e1..5b61b62be 100644 --- a/src/thread/Util.cxx +++ b/src/thread/Util.cxx @@ -38,10 +38,12 @@ #include <windows.h> #endif -#if defined(__linux__) && !defined(ANDROID) +#ifdef __linux__ + +#ifndef ANDROID static int -ioprio_set(int which, int who, int ioprio) noexcept +linux_ioprio_set(int which, int who, int ioprio) noexcept { return syscall(__NR_ioprio_set, which, who, ioprio); } @@ -55,7 +57,21 @@ ioprio_set_idle() noexcept static constexpr int _IOPRIO_IDLE = (_IOPRIO_CLASS_IDLE << _IOPRIO_CLASS_SHIFT) | 7; - ioprio_set(_IOPRIO_WHO_PROCESS, 0, _IOPRIO_IDLE); + linux_ioprio_set(_IOPRIO_WHO_PROCESS, 0, _IOPRIO_IDLE); +} + +#endif /* !ANDROID */ + +/** + * Wrapper for the "sched_setscheduler" system call. We don't use the + * one from the C library because Musl has an intentionally broken + * implementation. + */ +static int +linux_sched_setscheduler(pid_t pid, int sched, + const struct sched_param *param) noexcept +{ + return syscall(__NR_sched_setscheduler, pid, sched, param); } #endif @@ -66,7 +82,7 @@ SetThreadIdlePriority() noexcept #ifdef __linux__ #ifdef SCHED_IDLE static struct sched_param sched_param; - sched_setscheduler(0, SCHED_IDLE, &sched_param); + linux_sched_setscheduler(0, SCHED_IDLE, &sched_param); #endif #ifndef ANDROID @@ -92,7 +108,7 @@ SetThreadRealtime() policy |= SCHED_RESET_ON_FORK; #endif - if (sched_setscheduler(0, policy, &sched_param) < 0) + if (linux_sched_setscheduler(0, policy, &sched_param) < 0) throw MakeErrno("sched_setscheduler failed"); #endif // __linux__ }; diff --git a/src/util/NumberParser.hxx b/src/util/NumberParser.hxx index 47e9aacbd..67d42affa 100644 --- a/src/util/NumberParser.hxx +++ b/src/util/NumberParser.hxx @@ -78,7 +78,12 @@ ParseDouble(const char *p, char **endptr=nullptr) static inline float ParseFloat(const char *p, char **endptr=nullptr) { +#if defined(__BIONIC__) && __ANDROID_API__ < 21 + /* strtof() requires API level 21 */ return (float)ParseDouble(p, endptr); +#else + return strtof(p, endptr); +#endif } #endif |