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
|
- id3: remove the "id3v1_encoding" setting; by definition, all ID3v1 tags
|
||||||
are ISO-Latin-1
|
are ISO-Latin-1
|
||||||
- ape: support APE replay gain on remote files
|
- ape: support APE replay gain on remote files
|
||||||
|
- read ID3 tags from NFS/SMB
|
||||||
* decoder
|
* decoder
|
||||||
- improved error logging
|
- improved error logging
|
||||||
- report I/O errors to clients
|
- report I/O errors to clients
|
||||||
|
|
|
@ -92,8 +92,7 @@ Song::UpdateFile(Storage &storage)
|
||||||
if (path_fs.IsNull()) {
|
if (path_fs.IsNull()) {
|
||||||
const auto absolute_uri =
|
const auto absolute_uri =
|
||||||
storage.MapUTF8(relative_uri.c_str());
|
storage.MapUTF8(relative_uri.c_str());
|
||||||
if (!tag_stream_scan(absolute_uri.c_str(),
|
if (!tag_stream_scan(absolute_uri.c_str(), tag_builder))
|
||||||
full_tag_handler, &tag_builder))
|
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
if (!tag_file_scan(path_fs, tag_builder))
|
if (!tag_file_scan(path_fs, tag_builder))
|
||||||
|
@ -165,8 +164,7 @@ DetachedSong::Update()
|
||||||
return LoadFile(path_fs);
|
return LoadFile(path_fs);
|
||||||
} else if (IsRemote()) {
|
} else if (IsRemote()) {
|
||||||
TagBuilder tag_builder;
|
TagBuilder tag_builder;
|
||||||
if (!tag_stream_scan(uri.c_str(), full_tag_handler,
|
if (!tag_stream_scan(uri.c_str(), tag_builder))
|
||||||
&tag_builder))
|
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mtime = 0;
|
mtime = 0;
|
||||||
|
|
|
@ -19,6 +19,9 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "TagStream.hxx"
|
#include "TagStream.hxx"
|
||||||
|
#include "tag/Generic.hxx"
|
||||||
|
#include "tag/TagHandler.hxx"
|
||||||
|
#include "tag/TagBuilder.hxx"
|
||||||
#include "util/UriUtil.hxx"
|
#include "util/UriUtil.hxx"
|
||||||
#include "util/Error.hxx"
|
#include "util/Error.hxx"
|
||||||
#include "decoder/DecoderList.hxx"
|
#include "decoder/DecoderList.hxx"
|
||||||
|
@ -72,3 +75,28 @@ tag_stream_scan(const char *uri, const TagHandler &handler, void *ctx)
|
||||||
IgnoreError());
|
IgnoreError());
|
||||||
return is && tag_stream_scan(*is, handler, ctx);
|
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;
|
class InputStream;
|
||||||
struct TagHandler;
|
struct TagHandler;
|
||||||
|
class TagBuilder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Scan the tags of an #InputStream. Invokes matching decoder
|
* Scan the tags of an #InputStream. Invokes matching decoder
|
||||||
|
@ -38,4 +39,18 @@ tag_stream_scan(InputStream &is, const TagHandler &handler, void *ctx);
|
||||||
bool
|
bool
|
||||||
tag_stream_scan(const char *uri, const TagHandler &handler, void *ctx);
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue