Package: mpd Version: 0.14-1 Severity: wishlist Tags: patch My music files are tagged with both artist (i.e. "Eric Clapton") and artistsort (i.e., "Clapton, Eric"). Since mpd clients aren't aware of the extra information, I wrote a small patch to make mpd itself use the artistsort value, if available, when supplying the artist metadata to clients. I've only implemented it for FLAC and MP3 files.
It's controlled by a new boolean config param, "use_artistsort", which defaults to false for the current mpd behavior. -- System Information: Debian Release: 5.0 APT prefers testing APT policy: (990, 'testing'), (500, 'stable'), (400, 'unstable'), (1, 'experimental') Architecture: i386 (i686) Kernel: Linux 2.6.26-1-686 (SMP w/2 CPU cores) Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Versions of packages mpd depends on: ii adduser 3.110 add and remove users and groups ii libao2 0.8.8-4 Cross Platform Audio Output Librar ii libasound2 1.0.16-2 ALSA library ii libaudiofile0 0.2.6-7 Open-source version of SGI's audio ii libavahi-client3 0.6.22-3 Avahi client library ii libavahi-common3 0.6.22-3 Avahi common library ii libc6 2.7-18 GNU C Library: Shared libraries ii libcurl3-gnutls 7.18.2-8 Multi-protocol file transfer libra ii libfaad0 2.6.1-3.1 freeware Advanced Audio Decoder - ii libflac8 1.2.1-1.2 Free Lossless Audio Codec - runtim ii libglib2.0-0 2.16.6-1 The GLib library of C routines ii libid3tag0 0.15.1b-10 ID3 tag reading library from the M ii libjack0 0.116.1-3 JACK Audio Connection Kit (librari ii libmad0 0.15.1b-4 MPEG audio decoder library ii libmpcdec3 1.2.2-1 Musepack (MPC) format library ii libogg0 1.1.3-4 Ogg Bitstream Library ii libpulse0 0.9.10-3 PulseAudio client libraries ii libsamplerate0 0.1.4-1 audio rate conversion library ii libshout3 2.2.2-5 MP3/Ogg Vorbis broadcast streaming ii libvorbis0a 1.2.0.dfsg-3.1 The Vorbis General Audio Compressi ii libvorbisenc2 1.2.0.dfsg-3.1 The Vorbis General Audio Compressi ii libvorbisfile3 1.2.0.dfsg-3.1 The Vorbis General Audio Compressi ii libwavpack1 4.50.1-1 an audio codec (lossy and lossless mpd recommends no packages. Versions of packages mpd suggests: ii ario [mpd-client] 1.1-1 GTK+ client for the Music Player D pn avahi-daemon <none> (no description available) pn icecast2 <none> (no description available) ii mpc [mpd-client] 0.12.1-1 A command-line tool to interface M ii ncmpc [mpd-client] 0.11.1+svn-r3965-2 text based audio player pn pulseaudio <none> (no description available) ii sonata [mpd-client] 1.5.2-2 GTK+ client for the Music Player D -- no debconf information
>From 36ba0eca3ff649319953f415aa65eb98bccb5dfc Mon Sep 17 00:00:00 2001 From: Eric Cooper <[email protected]> Date: Tue, 27 Jan 2009 11:19:19 -0500 Subject: [PATCH] add "use_artistsort" configuration parameter --- debian/changelog | 6 ++++++ src/conf.c | 1 + src/conf.h | 1 + src/decoder/_flac_common.c | 19 +++++++++++++++++-- src/tag.c | 4 ++++ src/tag.h | 2 ++ src/tag_id3.c | 6 +++++- 7 files changed, 36 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 679b137..4b28a15 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mpd (0.14-999) UNRELEASED; urgency=low + + * Experimental version with "use_artistsort" configuration option + + -- Eric Cooper <[email protected]> Mon, 26 Jan 2009 18:15:25 -0500 + mpd (0.14-1) unstable; urgency=low * New upstream release diff --git a/src/conf.c b/src/conf.c index 680a5fb..c111b40 100644 --- a/src/conf.c +++ b/src/conf.c @@ -185,6 +185,7 @@ void initConf(void) registerConfigParam(CONF_METADATA_TO_USE, 0, 0); registerConfigParam(CONF_SAVE_ABSOLUTE_PATHS, 0, 0); registerConfigParam(CONF_GAPLESS_MP3_PLAYBACK, 0, 0); + registerConfigParam(CONF_USE_ARTISTSORT, 0, 0); } static void addBlockParam(ConfigParam * param, char *name, char *value, diff --git a/src/conf.h b/src/conf.h index 2b73bb6..b21a0c8 100644 --- a/src/conf.h +++ b/src/conf.h @@ -63,6 +63,7 @@ #define CONF_METADATA_TO_USE "metadata_to_use" #define CONF_SAVE_ABSOLUTE_PATHS "save_absolute_paths_in_playlists" #define CONF_GAPLESS_MP3_PLAYBACK "gapless_mp3_playback" +#define CONF_USE_ARTISTSORT "use_artistsort" #define CONF_BOOL_UNSET -1 #define CONF_BOOL_INVALID -2 diff --git a/src/decoder/_flac_common.c b/src/decoder/_flac_common.c index 5fea917..8b0d313 100644 --- a/src/decoder/_flac_common.c +++ b/src/decoder/_flac_common.c @@ -92,11 +92,14 @@ static void flacParseReplayGain(const FLAC__StreamMetadata * block, * tag names match */ static const char *VORBIS_COMMENT_TRACK_KEY = "tracknumber"; static const char *VORBIS_COMMENT_DISC_KEY = "discnumber"; +static const char *VORBIS_COMMENT_ARTISTSORT_KEY = "artistsort"; +static const char *VORBIS_COMMENT_ARTIST_KEY = "artist"; static unsigned int commentMatchesAddToTag(const FLAC__StreamMetadata_VorbisComment_Entry * entry, unsigned int itemType, - struct tag ** tag) + struct tag ** tag, + bool sort) { const char *str; size_t slen; @@ -109,6 +112,9 @@ static unsigned int commentMatchesAddToTag(const case TAG_ITEM_DISC: str = VORBIS_COMMENT_DISC_KEY; break; + case TAG_ITEM_ARTIST: + str = sort ? VORBIS_COMMENT_ARTISTSORT_KEY : VORBIS_COMMENT_ARTIST_KEY; + break; default: str = mpdTagItemKeys[itemType]; } @@ -139,12 +145,21 @@ struct tag *copyVorbisCommentBlockToMpdTag(const FLAC__StreamMetadata * block, for (i = block->data.vorbis_comment.num_comments; i != 0; --i) { for (j = TAG_NUM_OF_ITEM_TYPES; j--;) { - if (commentMatchesAddToTag(comments, j, &tag)) + if (commentMatchesAddToTag(comments, j, &tag, use_artistsort)) break; } comments++; } + if (use_artistsort && !tag_has_type(tag, TAG_ITEM_ARTIST)) { + comments = block->data.vorbis_comment.comments; + for (i = block->data.vorbis_comment.num_comments; i != 0; --i) { + if (commentMatchesAddToTag(comments, TAG_ITEM_ARTIST, &tag, false)) + break; + comments++; + } + } + return tag; } diff --git a/src/tag.c b/src/tag.c index 5e2a362..93b9db3 100644 --- a/src/tag.c +++ b/src/tag.c @@ -56,6 +56,8 @@ const char *mpdTagItemKeys[TAG_NUM_OF_ITEM_TYPES] = { "Disc" }; +bool use_artistsort = false; + int8_t ignoreTagItems[TAG_NUM_OF_ITEM_TYPES]; static size_t items_size(const struct tag *tag) @@ -72,6 +74,8 @@ void tag_lib_init(void) ConfigParam *param; int i; + use_artistsort = config_get_bool(CONF_USE_ARTISTSORT, false); + /* parse the "metadata_to_use" config parameter below */ memset(ignoreTagItems, 0, TAG_NUM_OF_ITEM_TYPES); diff --git a/src/tag.h b/src/tag.h index c1c7d7e..af26b79 100644 --- a/src/tag.h +++ b/src/tag.h @@ -43,6 +43,8 @@ enum tag_type { extern const char *mpdTagItemKeys[]; +extern bool use_artistsort; + struct tag_item { enum tag_type type; char value[sizeof(long)]; diff --git a/src/tag_id3.c b/src/tag_id3.c index 83e7bac..448cc5f 100644 --- a/src/tag_id3.c +++ b/src/tag_id3.c @@ -35,6 +35,9 @@ # ifndef ID3_FRAME_DISC # define ID3_FRAME_DISC "TPOS" # endif +# ifndef ID3_FRAME_ARTISTSORT +# define ID3_FRAME_ARTISTSORT "TSOP" +# endif /* This will try to convert a string to utf-8, */ @@ -198,7 +201,8 @@ struct tag *tag_id3_import(struct id3_tag * tag) { struct tag *ret = NULL; - ret = getID3Info(tag, ID3_FRAME_ARTIST, TAG_ITEM_ARTIST, ret); + if (!use_artistsort || (ret = getID3Info(tag, ID3_FRAME_ARTISTSORT, TAG_ITEM_ARTIST, NULL)) == NULL) + ret = getID3Info(tag, ID3_FRAME_ARTIST, TAG_ITEM_ARTIST, NULL); ret = getID3Info(tag, ID3_FRAME_TITLE, TAG_ITEM_TITLE, ret); ret = getID3Info(tag, ID3_FRAME_ALBUM, TAG_ITEM_ALBUM, ret); ret = getID3Info(tag, ID3_FRAME_TRACK, TAG_ITEM_TRACK, ret); -- 1.5.6.5

