SongFilter: use ApplyTagFallback()

This commit is contained in:
Max Kellermann 2018-10-22 10:41:39 +02:00
parent 0340b01392
commit 21adc78713
1 changed files with 18 additions and 8 deletions

View File

@ -22,6 +22,7 @@
#include "db/LightSong.hxx" #include "db/LightSong.hxx"
#include "DetachedSong.hxx" #include "DetachedSong.hxx"
#include "tag/Tag.hxx" #include "tag/Tag.hxx"
#include "tag/Fallback.hxx"
#include "util/ConstBuffer.hxx" #include "util/ConstBuffer.hxx"
#include "util/StringAPI.hxx" #include "util/StringAPI.hxx"
#include "util/StringCompare.hxx" #include "util/StringCompare.hxx"
@ -118,16 +119,25 @@ SongFilter::Item::Match(const Tag &_tag) const noexcept
if (value.empty()) if (value.empty())
return true; return true;
if (tag == TAG_ALBUM_ARTIST && visited_types[TAG_ARTIST]) { bool result = false;
/* if we're looking for "album artist", but if (ApplyTagFallback(TagType(tag),
only "artist" exists, use that */ [&](TagType tag2) {
for (const auto &item : _tag) if (!visited_types[tag2])
if (item.type == TAG_ARTIST && return false;
StringMatch(item.value))
return true; for (const auto &item : _tag) {
if (item.type == tag2 &&
StringMatch(item.value)) {
result = true;
break;
} }
} }
return true;
}))
return result;
}
return false; return false;
} }