From 228cdbe6afa927a423f6d40d3151d5d7af24fcda Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Tue, 22 Nov 2016 12:19:37 +0100
Subject: [PATCH] decoder/gme: provide the TRACK tag

---
 NEWS                                     | 1 +
 src/decoder/plugins/GmeDecoderPlugin.cxx | 6 ++++++
 2 files changed, 7 insertions(+)

diff --git a/NEWS b/NEWS
index 6dafc9241..d4ec29560 100644
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ ver 0.20 (not yet released)
   - ffmpeg: support ReplayGain and MixRamp
   - ffmpeg: support stream tags
   - gme: add option "accuracy"
+  - gme: provide the TRACK tag
   - gme: faster scanning
   - mad: reduce memory usage while scanning tags
   - mpcdec: read the bit rate
diff --git a/src/decoder/plugins/GmeDecoderPlugin.cxx b/src/decoder/plugins/GmeDecoderPlugin.cxx
index 9ae95cd9e..70cb955d8 100644
--- a/src/decoder/plugins/GmeDecoderPlugin.cxx
+++ b/src/decoder/plugins/GmeDecoderPlugin.cxx
@@ -221,6 +221,12 @@ ScanGmeInfo(const gme_info_t &info, unsigned song_num, int track_count,
 		tag_handler_invoke_duration(handler, handler_ctx,
 					    SongTime::FromMS(info.play_length));
 
+	if (track_count > 1) {
+		char track[16];
+		sprintf(track, "%u", song_num + 1);
+		tag_handler_invoke_tag(handler, handler_ctx, TAG_TRACK, track);
+	}
+
 	if (info.song != nullptr) {
 		if (track_count > 1) {
 			/* start numbering subtunes from 1 */