From 39b302dcad888dd38b282c761233d293bb6d4e5f Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 12 Jul 2019 17:22:20 +0200 Subject: [PATCH 1/5] increment version number to 0.21.12 --- NEWS | 2 ++ android/AndroidManifest.xml | 4 ++-- doc/conf.py | 2 +- meson.build | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/NEWS b/NEWS index b5972e4b5..3e81a3389 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +ver 0.21.12 (not yet released) + ver 0.21.11 (2019/07/03) * input - tidal: deprecated because Tidal has changed the protocol diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 9384fd838..84455850c 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="35" + android:versionName="0.21.12"> diff --git a/doc/conf.py b/doc/conf.py index fab5d9cba..f7ac8edfc 100644 --- a/doc/conf.py +++ b/doc/conf.py @@ -38,7 +38,7 @@ author = 'Max Kellermann' # built documents. # # The short X.Y version. -version = '0.21.11' +version = '0.21.12' # The full version, including alpha/beta/rc tags. release = version diff --git a/meson.build b/meson.build index b11e91cb8..dd4bef90d 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'mpd', ['c', 'cpp'], - version: '0.21.11', + version: '0.21.12', meson_version: '>= 0.49.0', default_options: [ 'c_std=c99', From d8aec4b2dc8a709a078bbce44e3a9f5866065a59 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 12 Jul 2019 17:49:12 +0200 Subject: [PATCH 2/5] test/run_decoder: catch StopDecoder This exception is usually thrown by class DecoderBridge, but the Opus plugin (ab)uses it as well, so we need to catch it. --- test/RunChromaprint.cxx | 12 +++++++++--- test/run_decoder.cxx | 11 +++++++++-- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test/RunChromaprint.cxx b/test/RunChromaprint.cxx index b04bf9060..a28c6336f 100644 --- a/test/RunChromaprint.cxx +++ b/test/RunChromaprint.cxx @@ -23,7 +23,7 @@ #include "event/Thread.hxx" #include "decoder/DecoderList.hxx" #include "decoder/DecoderPlugin.hxx" -#include "decoder/Client.hxx" +#include "decoder/DecoderAPI.hxx" /* for class StopDecoder */ #include "input/Init.hxx" #include "input/InputStream.hxx" #include "fs/Path.hxx" @@ -244,10 +244,16 @@ try { ChromaprintDecoderClient client; if (plugin->file_decode != nullptr) { - plugin->FileDecode(client, Path::FromFS(c.uri)); + try { + plugin->FileDecode(client, Path::FromFS(c.uri)); + } catch (StopDecoder) { + } } else if (plugin->stream_decode != nullptr) { auto is = InputStream::OpenReady(c.uri, client.mutex); - plugin->StreamDecode(client, *is); + try { + plugin->StreamDecode(client, *is); + } catch (StopDecoder) { + } } else { fprintf(stderr, "Decoder plugin is not usable\n"); return EXIT_FAILURE; diff --git a/test/run_decoder.cxx b/test/run_decoder.cxx index c94b5ee07..f7e3d6739 100644 --- a/test/run_decoder.cxx +++ b/test/run_decoder.cxx @@ -21,6 +21,7 @@ #include "event/Thread.hxx" #include "decoder/DecoderList.hxx" #include "decoder/DecoderPlugin.hxx" +#include "decoder/DecoderAPI.hxx" /* for class StopDecoder */ #include "DumpDecoderClient.hxx" #include "input/Init.hxx" #include "input/InputStream.hxx" @@ -116,10 +117,16 @@ try { DumpDecoderClient client; if (plugin->file_decode != nullptr) { - plugin->FileDecode(client, Path::FromFS(c.uri)); + try { + plugin->FileDecode(client, Path::FromFS(c.uri)); + } catch (StopDecoder) { + } } else if (plugin->stream_decode != nullptr) { auto is = InputStream::OpenReady(c.uri, client.mutex); - plugin->StreamDecode(client, *is); + try { + plugin->StreamDecode(client, *is); + } catch (StopDecoder) { + } } else { fprintf(stderr, "Decoder plugin is not usable\n"); return EXIT_FAILURE; From 83b08712481cd06c8a583a2f48b327fdd16d3442 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 29 Jul 2019 09:52:57 +0200 Subject: [PATCH 3/5] test/test_translate_song: remove unused variable "s1" --- test/test_translate_song.cxx | 6 ------ 1 file changed, 6 deletions(-) diff --git a/test/test_translate_song.cxx b/test/test_translate_song.cxx index cd4e39a5c..604e0c59b 100644 --- a/test/test_translate_song.cxx +++ b/test/test_translate_song.cxx @@ -207,7 +207,6 @@ TEST_F(TranslateSongTest, Insecure) TEST_F(TranslateSongTest, Secure) { DetachedSong song1(uri1, MakeTag1b()); - auto s1 = ToString(song1); auto se = ToString(DetachedSong(uri1, MakeTag1c())); const SongLoader loader(nullptr, nullptr); @@ -226,14 +225,12 @@ TEST_F(TranslateSongTest, InDatabase) loader)); DetachedSong song2(uri2, MakeTag2b()); - auto s1 = ToString(song2); auto se = ToString(DetachedSong(uri2, MakeTag2c())); EXPECT_TRUE(playlist_check_translate_song(song2, nullptr, loader)); EXPECT_EQ(se, ToString(song2)); DetachedSong song3("/music/foo/bar.ogg", MakeTag2b()); - s1 = ToString(song3); se = ToString(DetachedSong(uri2, MakeTag2c())); EXPECT_TRUE(playlist_check_translate_song(song3, nullptr, loader)); @@ -249,7 +246,6 @@ TEST_F(TranslateSongTest, Relative) /* map to music_directory */ DetachedSong song1("bar.ogg", MakeTag2b()); - auto s1 = ToString(song1); auto se = ToString(DetachedSong(uri2, MakeTag2c())); EXPECT_TRUE(playlist_check_translate_song(song1, "/music/foo", insecure_loader)); @@ -262,7 +258,6 @@ TEST_F(TranslateSongTest, Relative) /* legal because secure=true */ DetachedSong song3("bar.ogg", MakeTag1b()); - s1 = ToString(song3); se = ToString(DetachedSong(uri1, MakeTag1c())); EXPECT_TRUE(playlist_check_translate_song(song3, "/foo", secure_loader)); @@ -270,7 +265,6 @@ TEST_F(TranslateSongTest, Relative) /* relative to http:// */ DetachedSong song4("bar.ogg", MakeTag2a()); - s1 = ToString(song4); se = ToString(DetachedSong("http://example.com/foo/bar.ogg", MakeTag2a())); EXPECT_TRUE(playlist_check_translate_song(song4, "http://example.com/foo", insecure_loader)); From 90ea3bf985b94e1e2bc3dc77d79fc2f948c303b3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 29 Jul 2019 09:52:18 +0200 Subject: [PATCH 4/5] playlist/Song: support backslash in relative URIs Closes https://github.com/MusicPlayerDaemon/MPD/issues/607 --- NEWS | 2 ++ src/playlist/PlaylistSong.cxx | 16 ++++++++++++++++ test/test_translate_song.cxx | 20 ++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/NEWS b/NEWS index 3e81a3389..cc13617b9 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.21.12 (not yet released) +* Windows + - support backslash in relative URIs loaded from playlists ver 0.21.11 (2019/07/03) * input diff --git a/src/playlist/PlaylistSong.cxx b/src/playlist/PlaylistSong.cxx index 7d63fe76c..543d8d96f 100644 --- a/src/playlist/PlaylistSong.cxx +++ b/src/playlist/PlaylistSong.cxx @@ -66,6 +66,22 @@ playlist_check_translate_song(DetachedSong &song, const char *base_uri, base_uri = nullptr; const char *uri = song.GetURI(); + +#ifdef _WIN32 + if (!PathTraitsUTF8::IsAbsolute(uri) && strchr(uri, '\\') != nullptr) { + /* Windows uses the backslash as path separator, but + the MPD protocol uses the (forward) slash by + definition; to allow backslashes in relative URIs + loaded from playlist files, this step converts all + backslashes to (forward) slashes */ + + std::string new_uri(uri); + std::replace(new_uri.begin(), new_uri.end(), '\\', '/'); + song.SetURI(std::move(new_uri)); + uri = song.GetURI(); + } +#endif + if (base_uri != nullptr && !uri_has_scheme(uri) && !PathTraitsUTF8::IsAbsolute(uri)) song.SetURI(PathTraitsUTF8::Build(base_uri, uri)); diff --git a/test/test_translate_song.cxx b/test/test_translate_song.cxx index 604e0c59b..cac712785 100644 --- a/test/test_translate_song.cxx +++ b/test/test_translate_song.cxx @@ -270,3 +270,23 @@ TEST_F(TranslateSongTest, Relative) insecure_loader)); EXPECT_EQ(se, ToString(song4)); } + +TEST_F(TranslateSongTest, Backslash) +{ + const SongLoader loader(reinterpret_cast(1), + storage); + + DetachedSong song1("foo\\bar.ogg", MakeTag2b()); +#ifdef _WIN32 + /* on Windows, all backslashes are converted to slashes in + relative paths from playlists */ + auto se = ToString(DetachedSong(uri2, MakeTag2c())); + EXPECT_TRUE(playlist_check_translate_song(song1, nullptr, + loader)); + EXPECT_EQ(se, ToString(song1)); +#else + /* backslash only supported on Windows */ + EXPECT_FALSE(playlist_check_translate_song(song1, nullptr, + loader)); +#endif +} From b95533488283a9ea35a82084c8496715d38a0ba3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 29 Jul 2019 10:40:37 +0200 Subject: [PATCH 5/5] decoder/opus: ignore case in replay gain tag names Closes https://github.com/MusicPlayerDaemon/MPD/issues/604 --- NEWS | 2 ++ src/decoder/plugins/OpusTags.cxx | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index cc13617b9..69121ac7f 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.21.12 (not yet released) +* decoder + - opus: ignore case in replay gain tag names * Windows - support backslash in relative URIs loaded from playlists diff --git a/src/decoder/plugins/OpusTags.cxx b/src/decoder/plugins/OpusTags.cxx index c0a14fa89..76ea63e6e 100644 --- a/src/decoder/plugins/OpusTags.cxx +++ b/src/decoder/plugins/OpusTags.cxx @@ -22,12 +22,12 @@ #include "lib/xiph/XiphTags.hxx" #include "tag/Handler.hxx" #include "tag/ParseName.hxx" +#include "util/ASCII.hxx" #include "ReplayGainInfo.hxx" #include #include -#include #include gcc_pure @@ -46,7 +46,7 @@ ScanOneOpusTag(const char *name, const char *value, ReplayGainInfo *rgi, TagHandler &handler) noexcept { - if (rgi != nullptr && strcmp(name, "R128_TRACK_GAIN") == 0) { + if (rgi != nullptr && StringEqualsCaseASCII(name, "R128_TRACK_GAIN")) { /* R128_TRACK_GAIN is a Q7.8 fixed point number in dB */ @@ -54,7 +54,8 @@ ScanOneOpusTag(const char *name, const char *value, long l = strtol(value, &endptr, 10); if (endptr > value && *endptr == 0) rgi->track.gain = double(l) / 256.; - } else if (rgi != nullptr && strcmp(name, "R128_ALBUM_GAIN") == 0) { + } else if (rgi != nullptr && + StringEqualsCaseASCII(name, "R128_ALBUM_GAIN")) { /* R128_ALBUM_GAIN is a Q7.8 fixed point number in dB */