From ebed7e214752b7aafad35113fc35e37b608e8837 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 24 Feb 2018 21:29:16 +0100 Subject: [PATCH] playlist/cue/Parser: parse tags after "INDEX 01" Instead of setting state=IGNORE_TRACK, ignore only the following "INDEX" lines. Correction for commit 8461d71b520. Closes #227 --- src/playlist/cue/CueParser.cxx | 7 ++++++- src/playlist/cue/CueParser.hxx | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/playlist/cue/CueParser.cxx b/src/playlist/cue/CueParser.cxx index acdd55483..c61fb09d0 100644 --- a/src/playlist/cue/CueParser.cxx +++ b/src/playlist/cue/CueParser.cxx @@ -229,6 +229,8 @@ CueParser::Feed2(char *p) noexcept } state = TRACK; + ignore_index = false; + current.reset(new DetachedSong(filename)); assert(!current->GetTag().IsDefined()); @@ -238,6 +240,9 @@ CueParser::Feed2(char *p) noexcept } else if (state == IGNORE_TRACK) { return; } else if (state == TRACK && strcmp(command, "INDEX") == 0) { + if (ignore_index) + return; + const char *nr = cue_next_token(&p); if (nr == nullptr) return; @@ -255,7 +260,7 @@ CueParser::Feed2(char *p) noexcept current->SetStartTime(SongTime::FromMS(position_ms)); if(strcmp(nr, "00") != 0 || previous == nullptr) - state = IGNORE_TRACK; + ignore_index = true; } } diff --git a/src/playlist/cue/CueParser.hxx b/src/playlist/cue/CueParser.hxx index 6c84ddd4f..fd368c605 100644 --- a/src/playlist/cue/CueParser.hxx +++ b/src/playlist/cue/CueParser.hxx @@ -87,6 +87,13 @@ class CueParser { */ std::unique_ptr finished; + /** + * Ignore "INDEX" lines? Only up the first one after "00" is + * used. If there is a pregap (INDEX 00..01), it is assigned + * to the previous song. + */ + bool ignore_index; + /** * Tracks whether Finish() has been called. If true, then all * remaining (partial) results will be delivered by Get().