summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-07-06 22:46:03 +0200
committerMax Kellermann <max@musicpd.org>2018-07-06 22:46:03 +0200
commitc05bca6f2ce3efc57f903577697717f5ee1784cf (patch)
tree006c6795a65cb92389444146f73b09f629d304f5
parent73c95d1fb2fd239fd172dbd170123ab85a511ae0 (diff)
tag/Handler: implement FullTagHandler::OnAudioFormat()
-rw-r--r--src/TagFile.cxx5
-rw-r--r--src/TagFile.hxx4
-rw-r--r--src/TagStream.cxx10
-rw-r--r--src/TagStream.hxx7
-rw-r--r--src/tag/Handler.cxx6
-rw-r--r--src/tag/Handler.hxx16
6 files changed, 35 insertions, 13 deletions
diff --git a/src/TagFile.cxx b/src/TagFile.cxx
index aee2af629..f7f39638f 100644
--- a/src/TagFile.cxx
+++ b/src/TagFile.cxx
@@ -100,9 +100,10 @@ ScanFileTagsNoGeneric(Path path_fs, TagHandler &handler) noexcept
}
bool
-ScanFileTagsWithGeneric(Path path, TagBuilder &builder) noexcept
+ScanFileTagsWithGeneric(Path path, TagBuilder &builder,
+ AudioFormat *audio_format) noexcept
{
- FullTagHandler h(builder);
+ FullTagHandler h(builder, audio_format);
if (!ScanFileTagsNoGeneric(path, h))
return false;
diff --git a/src/TagFile.hxx b/src/TagFile.hxx
index 7f10d31ed..61b1a92c6 100644
--- a/src/TagFile.hxx
+++ b/src/TagFile.hxx
@@ -22,6 +22,7 @@
#include "check.h"
+struct AudioFormat;
class Path;
class TagHandler;
class TagBuilder;
@@ -46,6 +47,7 @@ ScanFileTagsNoGeneric(Path path, TagHandler &handler) noexcept;
* found)
*/
bool
-ScanFileTagsWithGeneric(Path path, TagBuilder &builder) noexcept;
+ScanFileTagsWithGeneric(Path path, TagBuilder &builder,
+ AudioFormat *audio_format=nullptr) noexcept;
#endif
diff --git a/src/TagStream.cxx b/src/TagStream.cxx
index c4ceb736e..8053679d5 100644
--- a/src/TagStream.cxx
+++ b/src/TagStream.cxx
@@ -85,11 +85,12 @@ try {
}
bool
-tag_stream_scan(InputStream &is, TagBuilder &builder) noexcept
+tag_stream_scan(InputStream &is, TagBuilder &builder,
+ AudioFormat *audio_format) noexcept
{
assert(is.IsReady());
- FullTagHandler h(builder);
+ FullTagHandler h(builder, audio_format);
if (!tag_stream_scan(is, h))
return false;
@@ -101,12 +102,13 @@ tag_stream_scan(InputStream &is, TagBuilder &builder) noexcept
}
bool
-tag_stream_scan(const char *uri, TagBuilder &builder) noexcept
+tag_stream_scan(const char *uri, TagBuilder &builder,
+ AudioFormat *audio_format) noexcept
try {
Mutex mutex;
auto is = InputStream::OpenReady(uri, mutex);
- return tag_stream_scan(*is, builder);
+ return tag_stream_scan(*is, builder, audio_format);
} catch (const std::exception &e) {
return false;
}
diff --git a/src/TagStream.hxx b/src/TagStream.hxx
index 136b380a5..fbf180849 100644
--- a/src/TagStream.hxx
+++ b/src/TagStream.hxx
@@ -22,6 +22,7 @@
#include "check.h"
+struct AudioFormat;
class InputStream;
class TagHandler;
class TagBuilder;
@@ -48,9 +49,11 @@ tag_stream_scan(const char *uri, TagHandler &handler) noexcept;
* found)
*/
bool
-tag_stream_scan(InputStream &is, TagBuilder &builder) noexcept;
+tag_stream_scan(InputStream &is, TagBuilder &builder,
+ AudioFormat *audio_format=nullptr) noexcept;
bool
-tag_stream_scan(const char *uri, TagBuilder &builder) noexcept;
+tag_stream_scan(const char *uri, TagBuilder &builder,
+ AudioFormat *audio_format=nullptr) noexcept;
#endif
diff --git a/src/tag/Handler.cxx b/src/tag/Handler.cxx
index 78b81763d..7c2a50309 100644
--- a/src/tag/Handler.cxx
+++ b/src/tag/Handler.cxx
@@ -57,3 +57,9 @@ FullTagHandler::OnPair(const char *name, gcc_unused const char *value) noexcept
tag.SetHasPlaylist(true);
}
+void
+FullTagHandler::OnAudioFormat(AudioFormat af) noexcept
+{
+ if (audio_format != nullptr)
+ *audio_format = af;
+}
diff --git a/src/tag/Handler.hxx b/src/tag/Handler.hxx
index 6b0342d80..04c501101 100644
--- a/src/tag/Handler.hxx
+++ b/src/tag/Handler.hxx
@@ -140,15 +140,23 @@ public:
* attribute.
*/
class FullTagHandler : public AddTagHandler {
+ AudioFormat *const audio_format;
+
protected:
- FullTagHandler(unsigned _want_mask, TagBuilder &_builder) noexcept
- :AddTagHandler(WANT_PAIR|_want_mask, _builder) {}
+ FullTagHandler(unsigned _want_mask, TagBuilder &_builder,
+ AudioFormat *_audio_format) noexcept
+ :AddTagHandler(WANT_PAIR|_want_mask
+ |(_audio_format ? WANT_AUDIO_FORMAT : 0),
+ _builder),
+ audio_format(_audio_format) {}
public:
- explicit FullTagHandler(TagBuilder &_builder) noexcept
- :FullTagHandler(0, _builder) {}
+ explicit FullTagHandler(TagBuilder &_builder,
+ AudioFormat *_audio_format=nullptr) noexcept
+ :FullTagHandler(0, _builder, _audio_format) {}
void OnPair(const char *key, const char *value) noexcept override;
+ void OnAudioFormat(AudioFormat af) noexcept override;
};
#endif