Merge branch 'v0.22.x'

This commit is contained in:
Max Kellermann 2021-05-26 13:15:29 +02:00
commit 4ee0a06e18
3 changed files with 66 additions and 17 deletions

4
NEWS
View File

@ -15,6 +15,10 @@ ver 0.23 (not yet released)
* new build-time dependency: libfmt
ver 0.22.9 (not yet released)
* database
- simple: load all .mpdignore files of all parent directories
* decoder
- ffmpeg: support the tags "sort_album", "album-sort", "artist-sort"
* Windows
- fix build failure with SQLite

View File

@ -312,6 +312,29 @@ UpdateWalk::SkipSymlink(const Directory *directory,
#endif
}
static void
LoadExcludeListOrThrow(const Storage &storage, const Directory &directory,
ExcludeList &exclude_list)
{
Mutex mutex;
auto is = InputStream::OpenReady(storage.MapUTF8(PathTraitsUTF8::Build(directory.GetPath(),
".mpdignore")).c_str(),
mutex);
exclude_list.Load(std::move(is));
}
static void
LoadExcludeListOrLog(const Storage &storage, const Directory &directory,
ExcludeList &exclude_list) noexcept
{
try {
LoadExcludeListOrThrow(storage, directory, exclude_list);
} catch (...) {
if (!IsFileNotFound(std::current_exception()))
LogError(std::current_exception());
}
}
bool
UpdateWalk::UpdateDirectory(Directory &directory,
const ExcludeList &exclude_list,
@ -331,17 +354,7 @@ UpdateWalk::UpdateDirectory(Directory &directory,
}
ExcludeList child_exclude_list(exclude_list);
try {
Mutex mutex;
auto is = InputStream::OpenReady(storage.MapUTF8(PathTraitsUTF8::Build(directory.GetPath(),
".mpdignore")).c_str(),
mutex);
child_exclude_list.Load(std::move(is));
} catch (...) {
if (!IsFileNotFound(std::current_exception()))
LogError(std::current_exception());
}
LoadExcludeListOrLog(storage, directory, child_exclude_list);
if (!child_exclude_list.IsEmpty())
RemoveExcludedFromDirectory(directory, child_exclude_list);
@ -445,6 +458,28 @@ UpdateWalk::DirectoryMakeUriParentChecked(Directory &root,
return directory;
}
static void
LoadExcludeLists(std::forward_list<ExcludeList> &lists,
const Storage &storage, const Directory &directory) noexcept
{
assert(!lists.empty());
if (!directory.IsRoot())
LoadExcludeLists(lists, storage, *directory.parent);
lists.emplace_front();
LoadExcludeListOrLog(storage, directory, lists.front());
}
static auto
LoadExcludeLists(const Storage &storage, const Directory &directory) noexcept
{
std::forward_list<ExcludeList> lists;
lists.emplace_front();
LoadExcludeLists(lists, storage, directory);
return lists;
}
inline void
UpdateWalk::UpdateUri(Directory &root, const char *uri) noexcept
try {
@ -465,9 +500,8 @@ try {
return;
}
ExcludeList exclude_list;
UpdateDirectoryChild(*parent, exclude_list, name, info);
const auto exclude_lists = LoadExcludeLists(storage, *parent);
UpdateDirectoryChild(*parent, exclude_lists.front(), name, info);
} catch (...) {
LogError(std::current_exception());
}

View File

@ -30,11 +30,22 @@ extern "C" {
#include <libavutil/dict.h>
}
/**
* FFmpeg specific tag name mappings, as supported by
* libavformat/id3v2.c, libavformat/mov.c and others.
*/
static constexpr struct tag_table ffmpeg_tags[] = {
{ "year", TAG_DATE },
{ "author-sort", TAG_ARTIST_SORT },
/* from libavformat/id3v2.c, libavformat/mov.c */
{ "album_artist", TAG_ALBUM_ARTIST },
{ "album_artist-sort", TAG_ALBUM_ARTIST_SORT },
/* from libavformat/id3v2.c */
{ "album-sort", TAG_ALBUM_SORT },
{ "artist-sort", TAG_ARTIST_SORT },
/* from libavformat/mov.c */
{ "sort_album_artist", TAG_ALBUM_ARTIST_SORT },
{ "sort_album", TAG_ALBUM_SORT },
{ "sort_artist", TAG_ARTIST_SORT },
/* sentinel */
{ nullptr, TAG_NUM_OF_ITEM_TYPES }