TagStream: add TagBuilder overload with ScanGenericTags() fallback
This commit adds support for APE/ID3 tags from NFS/SMB files. See http://bugs.musicpd.org/view.php?id=4270
This commit is contained in:
parent
a9130cb99c
commit
3d9652ae35
1
NEWS
1
NEWS
|
@ -14,6 +14,7 @@ ver 0.20 (not yet released)
|
|||
- id3: remove the "id3v1_encoding" setting; by definition, all ID3v1 tags
|
||||
are ISO-Latin-1
|
||||
- ape: support APE replay gain on remote files
|
||||
- read ID3 tags from NFS/SMB
|
||||
* decoder
|
||||
- improved error logging
|
||||
- report I/O errors to clients
|
||||
|
|
|
@ -92,8 +92,7 @@ Song::UpdateFile(Storage &storage)
|
|||
if (path_fs.IsNull()) {
|
||||
const auto absolute_uri =
|
||||
storage.MapUTF8(relative_uri.c_str());
|
||||
if (!tag_stream_scan(absolute_uri.c_str(),
|
||||
full_tag_handler, &tag_builder))
|
||||
if (!tag_stream_scan(absolute_uri.c_str(), tag_builder))
|
||||
return false;
|
||||
} else {
|
||||
if (!tag_file_scan(path_fs, tag_builder))
|
||||
|
@ -165,8 +164,7 @@ DetachedSong::Update()
|
|||
return LoadFile(path_fs);
|
||||
} else if (IsRemote()) {
|
||||
TagBuilder tag_builder;
|
||||
if (!tag_stream_scan(uri.c_str(), full_tag_handler,
|
||||
&tag_builder))
|
||||
if (!tag_stream_scan(uri.c_str(), tag_builder))
|
||||
return false;
|
||||
|
||||
mtime = 0;
|
||||
|
|
|
@ -19,6 +19,9 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "TagStream.hxx"
|
||||
#include "tag/Generic.hxx"
|
||||
#include "tag/TagHandler.hxx"
|
||||
#include "tag/TagBuilder.hxx"
|
||||
#include "util/UriUtil.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "decoder/DecoderList.hxx"
|
||||
|
@ -72,3 +75,28 @@ tag_stream_scan(const char *uri, const TagHandler &handler, void *ctx)
|
|||
IgnoreError());
|
||||
return is && tag_stream_scan(*is, handler, ctx);
|
||||
}
|
||||
|
||||
bool
|
||||
tag_stream_scan(InputStream &is, TagBuilder &builder)
|
||||
{
|
||||
assert(is.IsReady());
|
||||
|
||||
if (!tag_stream_scan(is, full_tag_handler, &builder))
|
||||
return false;
|
||||
|
||||
if (builder.IsEmpty())
|
||||
ScanGenericTags(is, full_tag_handler, &builder);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
tag_stream_scan(const char *uri, TagBuilder &builder)
|
||||
{
|
||||
Mutex mutex;
|
||||
Cond cond;
|
||||
|
||||
auto is = InputStream::OpenReady(uri, mutex, cond,
|
||||
IgnoreError());
|
||||
return is && tag_stream_scan(*is, builder);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
|
||||
class InputStream;
|
||||
struct TagHandler;
|
||||
class TagBuilder;
|
||||
|
||||
/**
|
||||
* Scan the tags of an #InputStream. Invokes matching decoder
|
||||
|
@ -38,4 +39,18 @@ tag_stream_scan(InputStream &is, const TagHandler &handler, void *ctx);
|
|||
bool
|
||||
tag_stream_scan(const char *uri, const TagHandler &handler, void *ctx);
|
||||
|
||||
/**
|
||||
* Scan the tags of an #InputStream. Invokes matching decoder
|
||||
* plugins, and falls back to generic scanners (APE and ID3) if no
|
||||
* tags were found (but the file was recognized).
|
||||
*
|
||||
* @return true if the file was recognized (even if no metadata was
|
||||
* found)
|
||||
*/
|
||||
bool
|
||||
tag_stream_scan(InputStream &is, TagBuilder &builder);
|
||||
|
||||
bool
|
||||
tag_stream_scan(const char *uri, TagBuilder &builder);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue