From ab830f9afd09969e566db934980322adc6d333a0 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 9 Aug 2019 15:38:01 +0200 Subject: [PATCH 1/4] increment version number to 0.21.14 --- 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 157fd861a..febee603b 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ +ver 0.21.14 (not yet released) + ver 0.21.13 (2019/08/06) * input - cdio_paranoia: require libcdio-paranoia 10.2+0.93+1 diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index 9dc417f71..dbf63165a 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -2,8 +2,8 @@ + android:versionCode="37" + android:versionName="0.21.14"> diff --git a/doc/conf.py b/doc/conf.py index 878f886b9..71294b46b 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.13' +version = '0.21.14' # The full version, including alpha/beta/rc tags. release = version diff --git a/meson.build b/meson.build index 0f00d4bbb..842c074f3 100644 --- a/meson.build +++ b/meson.build @@ -1,7 +1,7 @@ project( 'mpd', ['c', 'cpp'], - version: '0.21.13', + version: '0.21.14', meson_version: '>= 0.49.0', default_options: [ 'c_std=c99', From 0ed10542cc0ef7c590e3b8b9717ae26309dd494a Mon Sep 17 00:00:00 2001 From: Fredrik Noring Date: Sun, 4 Aug 2019 20:17:03 +0200 Subject: [PATCH 2/4] decoder/sidplay: Fix song length initialisation during container scan The song length was previously undetermined. --- NEWS | 2 ++ src/decoder/plugins/SidplayDecoderPlugin.cxx | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/NEWS b/NEWS index febee603b..192c37357 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ ver 0.21.14 (not yet released) +* decoder + - sidplay: show track durations in database ver 0.21.13 (2019/08/06) * input diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index 90d762dae..d38010872 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -547,6 +547,10 @@ sidplay_container_scan(Path path_fs) AddTagHandler h(tag_builder); ScanSidTuneInfo(info, i, n_tracks, h); + const SignedSongTime duration = get_song_length(tune); + if (!duration.IsNegative()) + h.OnDuration(SongTime(duration)); + char track_name[32]; /* Construct container/tune path names, eg. Delta.sid/tune_001.sid */ From 7723c481db66f089f5ccde941a0a952cb1b16e2e Mon Sep 17 00:00:00 2001 From: Fredrik Noring Date: Sun, 4 Aug 2019 08:07:42 +0200 Subject: [PATCH 3/4] decoder/sidplay: Fix windows-1252 to utf-8 string conversion High Voltage SID Collection (HVSC) metadata fields are encoded in windows-1252, as described in DOCUMENTS/SID_file_format.txt: https://www.hvsc.c64.org/download/C64Music/DOCUMENTS/SID_file_format.txt If utf-8 transcoding fails, or the ICU library is unavailable, fall back to plain ASCII and replace other characters with '?'. --- NEWS | 1 + src/decoder/plugins/SidplayDecoderPlugin.cxx | 62 ++++++++++++++------ 2 files changed, 46 insertions(+), 17 deletions(-) diff --git a/NEWS b/NEWS index 192c37357..1ca3a3123 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,7 @@ ver 0.21.14 (not yet released) * decoder - sidplay: show track durations in database + - sidplay: convert tag values from Windows-1252 charset ver 0.21.13 (2019/08/06) * input diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index d38010872..619ef38f6 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -25,6 +25,7 @@ #include "song/DetachedSong.hxx" #include "fs/Path.hxx" #include "fs/AllocatedPath.hxx" +#include "lib/icu/Converter.hxx" #ifdef HAVE_SIDPLAYFP #include "fs/io/FileReader.hxx" #include "util/RuntimeError.hxx" @@ -32,6 +33,8 @@ #include "util/Macros.hxx" #include "util/StringFormat.hxx" #include "util/Domain.hxx" +#include "util/AllocatedString.hxx" +#include "util/CharUtil.hxx" #include "system/ByteOrder.hxx" #include "Log.hxx" @@ -432,19 +435,46 @@ sidplay_file_decode(DecoderClient &client, Path path_fs) } while (cmd != DecoderCommand::STOP); } +static AllocatedString +Windows1252ToUTF8(const char *s) noexcept +{ +#ifdef HAVE_ICU_CONVERTER + try { + std::unique_ptr + converter(IcuConverter::Create("windows-1252")); + + return converter->ToUTF8(s); + } catch (...) { } +#endif + + /* + * Fallback to not transcoding windows-1252 to utf-8, that may result + * in invalid utf-8 unless nonprintable characters are replaced. + */ + auto t = AllocatedString::Duplicate(s); + + for (size_t i = 0; t[i] != AllocatedString::SENTINEL; i++) + if (!IsPrintableASCII(t[i])) + t[i] = '?'; + + return t; +} + gcc_pure -static const char * +static AllocatedString GetInfoString(const SidTuneInfo &info, unsigned i) noexcept { #ifdef HAVE_SIDPLAYFP - return info.numberOfInfoStrings() > i + const char *s = info.numberOfInfoStrings() > i ? info.infoString(i) - : nullptr; + : ""; #else - return info.numberOfInfoStrings > i + const char *s = info.numberOfInfoStrings > i ? info.infoString[i] - : nullptr; + : ""; #endif + + return Windows1252ToUTF8(s); } static void @@ -452,27 +482,25 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks, TagHandler &handler) noexcept { /* title */ - const char *title = GetInfoString(info, 0); - if (title == nullptr) - title = ""; + const auto title = GetInfoString(info, 0); if (n_tracks > 1) { const auto tag_title = StringFormat<1024>("%s (%u/%u)", - title, track, n_tracks); - handler.OnTag(TAG_TITLE, tag_title); + title.c_str(), track, n_tracks); + handler.OnTag(TAG_TITLE, tag_title.c_str()); } else - handler.OnTag(TAG_TITLE, title); + handler.OnTag(TAG_TITLE, title.c_str()); /* artist */ - const char *artist = GetInfoString(info, 1); - if (artist != nullptr) - handler.OnTag(TAG_ARTIST, artist); + const auto artist = GetInfoString(info, 1); + if (!artist.empty()) + handler.OnTag(TAG_ARTIST, artist.c_str()); /* date */ - const char *date = GetInfoString(info, 2); - if (date != nullptr) - handler.OnTag(TAG_DATE, date); + const auto date = GetInfoString(info, 2); + if (!date.empty()) + handler.OnTag(TAG_DATE, date.c_str()); /* track */ handler.OnTag(TAG_TRACK, StringFormat<16>("%u", track)); From 2d61e526deaa13a835a1307dc6fc701162495932 Mon Sep 17 00:00:00 2001 From: Fredrik Noring Date: Mon, 5 Aug 2019 10:50:47 +0200 Subject: [PATCH 4/4] decoder/sidplay: Fix date field to have year but not company or author Field 2 is called , formerly used as [1][2]. It is formatted , where may be , , or , for example "1987", "199?", "19??" or "1985-87". The may be for example Rob Hubbard. A full field may be for example "1987 Rob Hubbard". This change splits the field at the first , to retain the part. The 51823 SID files in High Voltage SID Collection (HVSC) version 71 have the following distribution of dates: 333 19?? 11 1990-92 6 1995-99 2 2006-08 827 198? 88 1990-93 2140 1996 530 2007 32 1982 69 1990-94 9 1996-97 15 2007-08 1 1982-83 49 1990-95 2 1996-98 2 2007-09 255 1983 3467 1991 5 1996-99 1 2007-10 677 1984 75 1991-92 1840 1997 430 2008 775 1985 65 1991-93 4 1997-98 23 2008-09 3 1985-86 10 1991-94 1276 1998 1 2008-12 10 1985-87 35 1991-97 4 1998-99 631 2009 943 1986 3320 1992 865 1999 1 2009-10 12 1986-87 26 1992-93 24 200? 645 2010 5 1986-89 59 1992-94 590 2000 1 2010-12 2083 1987 1 1992-96 4 2000-01 538 2011 31 1987-88 2996 1993 727 2001 1 2011-12 44 1987-89 42 1993-94 875 2002 651 2012 2510 1988 12 1993-95 2 2002-04 811 2013 129 1988-89 2 1993-97 844 2003 790 2014 91 1988-90 2737 1994 3 2003-05 740 2015 58 1988-91 16 1994-95 842 2004 792 2016 3466 1989 20 1994-96 2 2004-05 775 2017 95 1989-90 17 1994-97 707 2005 638 2018 150 1989-91 2271 1995 1 2005-06 284 2019 1077 199? 2 1995-96 2 2005-07 2834 1990 4 1995-97 785 2006 119 1990-91 2 1995-98 6 2006-07 References: [1] https://www.hvsc.c64.org/download/C64Music/DOCUMENTS/SID_file_format.txt [2] https://hvsc.c64.org/info --- NEWS | 1 + src/decoder/plugins/SidplayDecoderPlugin.cxx | 26 +++++++++++++++++++- 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/NEWS b/NEWS index 1ca3a3123..acc735d2e 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,7 @@ ver 0.21.14 (not yet released) * decoder - sidplay: show track durations in database - sidplay: convert tag values from Windows-1252 charset + - sidplay: strip text from "Date" tag ver 0.21.13 (2019/08/06) * input diff --git a/src/decoder/plugins/SidplayDecoderPlugin.cxx b/src/decoder/plugins/SidplayDecoderPlugin.cxx index 619ef38f6..8a22e0817 100644 --- a/src/decoder/plugins/SidplayDecoderPlugin.cxx +++ b/src/decoder/plugins/SidplayDecoderPlugin.cxx @@ -477,6 +477,30 @@ GetInfoString(const SidTuneInfo &info, unsigned i) noexcept return Windows1252ToUTF8(s); } +gcc_pure +static AllocatedString +GetDateString(const SidTuneInfo &info) noexcept +{ + /* + * Field 2 is called , previously used as . + * It is formatted , + * where may be , , or , for + * example "1987", "199?", "19??" or "1985-87". The may be for example Rob Hubbard. A full field + * may be for example "1987 Rob Hubbard". + */ + AllocatedString release = GetInfoString(info, 2); + + /* Keep the part only for the date. */ + for (size_t i = 0; release[i] != AllocatedString::SENTINEL; i++) + if (std::isspace(release[i])) { + release[i] = AllocatedString::SENTINEL; + break; + } + + return release; +} + static void ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks, TagHandler &handler) noexcept @@ -498,7 +522,7 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks, handler.OnTag(TAG_ARTIST, artist.c_str()); /* date */ - const auto date = GetInfoString(info, 2); + const auto date = GetDateString(info); if (!date.empty()) handler.OnTag(TAG_DATE, date.c_str());