From 3560dc4be60e6e3c47c687b9702a62a610909546 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@duempel.org>
Date: Mon, 29 Sep 2014 18:55:59 +0200
Subject: [PATCH] Tag: support "AlbumSort"

The new tag is supported by all decoders that use the tag name table,
and the ID3v2 tag "TSOA" maps to it.
---
 NEWS               | 2 +-
 src/tag/TagId3.cxx | 3 +++
 src/tag/TagNames.c | 1 +
 src/tag/TagType.h  | 1 +
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/NEWS b/NEWS
index 6808dabac..c521ed060 100644
--- a/NEWS
+++ b/NEWS
@@ -67,7 +67,7 @@ ver 0.19 (not yet released)
 * configuration
   - allow playlist directory without music directory
   - use XDG to auto-detect "music_directory" and "db_file"
-* add tag "MUSICBRAINZ_RELEASETRACKID"
+* add tags "AlbumSort", "MUSICBRAINZ_RELEASETRACKID"
 * new resampler option using libsoxr
 * ARM NEON optimizations
 * install systemd unit for socket activation
diff --git a/src/tag/TagId3.cxx b/src/tag/TagId3.cxx
index c179d6996..02dc58364 100644
--- a/src/tag/TagId3.cxx
+++ b/src/tag/TagId3.cxx
@@ -350,6 +350,9 @@ scan_id3_tag(struct id3_tag *tag,
 			    TAG_ALBUM_ARTIST, handler, handler_ctx);
 	tag_id3_import_text(tag, ID3_FRAME_ARTIST_SORT,
 			    TAG_ARTIST_SORT, handler, handler_ctx);
+
+	tag_id3_import_text(tag, "TSOA", TAG_ALBUM_SORT, handler, handler_ctx);
+
 	tag_id3_import_text(tag, ID3_FRAME_ALBUM_ARTIST_SORT,
 			    TAG_ALBUM_ARTIST_SORT, handler, handler_ctx);
 	tag_id3_import_text(tag, ID3_FRAME_TITLE, TAG_TITLE,
diff --git a/src/tag/TagNames.c b/src/tag/TagNames.c
index fb4f5bbc2..e051c5863 100644
--- a/src/tag/TagNames.c
+++ b/src/tag/TagNames.c
@@ -24,6 +24,7 @@ const char *const tag_item_names[TAG_NUM_OF_ITEM_TYPES] = {
 	[TAG_ARTIST] = "Artist",
 	[TAG_ARTIST_SORT] = "ArtistSort",
 	[TAG_ALBUM] = "Album",
+	[TAG_ALBUM_SORT] = "AlbumSort",
 	[TAG_ALBUM_ARTIST] = "AlbumArtist",
 	[TAG_ALBUM_ARTIST_SORT] = "AlbumArtistSort",
 	[TAG_TITLE] = "Title",
diff --git a/src/tag/TagType.h b/src/tag/TagType.h
index 5fd07d2e8..0aa6b4a51 100644
--- a/src/tag/TagType.h
+++ b/src/tag/TagType.h
@@ -38,6 +38,7 @@ enum TagType
 	TAG_ARTIST,
 	TAG_ARTIST_SORT,
 	TAG_ALBUM,
+	TAG_ALBUM_SORT,
 	TAG_ALBUM_ARTIST,
 	TAG_ALBUM_ARTIST_SORT,
 	TAG_TITLE,