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 icy; public: + template 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 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(_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(); + auto c = std::make_unique((*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(std::move(c), std::move(icy)); }