summaryrefslogtreecommitdiff
path: root/src/input/plugins/CurlInputPlugin.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-01-11 14:58:42 +0100
committerMax Kellermann <max@musicpd.org>2018-01-11 15:32:19 +0100
commit3fe5b42b2babeb10309c3f7359830833b08fadb0 (patch)
tree39ba4811b2e38b67bc0787083c543db1484945e0 /src/input/plugins/CurlInputPlugin.cxx
parent70c4b621cf20bb5b90b3fb6aa54d5adf20d34faf (diff)
input/curl: pass IcyMetaDataParser to constructor
Allows the caller to decide whether to enable the feature.
Diffstat (limited to 'src/input/plugins/CurlInputPlugin.cxx')
-rw-r--r--src/input/plugins/CurlInputPlugin.cxx13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx
index 63c6e7eb1..6c2afbc49 100644
--- a/src/input/plugins/CurlInputPlugin.cxx
+++ b/src/input/plugins/CurlInputPlugin.cxx
@@ -76,7 +76,9 @@ class CurlInputStream final : public AsyncInputStream, CurlResponseHandler {
std::shared_ptr<IcyMetaDataParser> icy;
public:
+ template<typename I>
CurlInputStream(EventLoop &event_loop, const char *_url,
+ I &&_icy,
Mutex &_mutex, Cond &_cond);
~CurlInputStream() noexcept;
@@ -339,13 +341,15 @@ input_curl_finish() noexcept
http_200_aliases = nullptr;
}
+template<typename I>
inline
CurlInputStream::CurlInputStream(EventLoop &event_loop, const char *_url,
+ I &&_icy,
Mutex &_mutex, Cond &_cond)
:AsyncInputStream(event_loop, _url, _mutex, _cond,
CURL_MAX_BUFFERED,
CURL_RESUME_AT),
- icy(new IcyMetaDataParser())
+ icy(std::forward<I>(_icy))
{
request_headers.Append("Icy-Metadata: 1");
}
@@ -440,15 +444,18 @@ CurlInputStream::DoSeek(offset_type new_offset)
inline InputStreamPtr
CurlInputStream::Open(const char *url, Mutex &mutex, Cond &cond)
{
+ auto icy = std::make_shared<IcyMetaDataParser>();
+
auto c = std::make_unique<CurlInputStream>((*curl_init)->GetEventLoop(),
- url, mutex, cond);
+ url,
+ icy,
+ mutex, cond);
BlockingCall(c->GetEventLoop(), [&c](){
c->InitEasy();
c->StartRequest();
});
- auto icy = c->icy;
return std::make_unique<IcyInputStream>(std::move(c), std::move(icy));
}