input/async: pass std::string_view to constructor

This commit is contained in:
Max Kellermann 2024-05-13 10:11:18 +02:00
parent 4800f1d8f2
commit 6d5dab38dd
6 changed files with 14 additions and 18 deletions

View File

@ -12,7 +12,7 @@
#include <string.h>
AsyncInputStream::AsyncInputStream(EventLoop &event_loop, const char *_url,
AsyncInputStream::AsyncInputStream(EventLoop &event_loop, std::string_view _url,
Mutex &_mutex,
size_t _buffer_size,
size_t _resume_at) noexcept

View File

@ -1,8 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#ifndef MPD_ASYNC_INPUT_STREAM_HXX
#define MPD_ASYNC_INPUT_STREAM_HXX
#pragma once
#include "InputStream.hxx"
#include "event/InjectEvent.hxx"
@ -54,7 +53,7 @@ protected:
std::exception_ptr postponed_exception;
public:
AsyncInputStream(EventLoop &event_loop, const char *_url,
AsyncInputStream(EventLoop &event_loop, std::string_view _url,
Mutex &_mutex,
size_t _buffer_size,
size_t _resume_at) noexcept;
@ -155,5 +154,3 @@ private:
void DeferredResume() noexcept;
void DeferredSeek() noexcept;
};
#endif

View File

@ -66,7 +66,7 @@ class CurlInputStream final : public AsyncInputStream, CurlResponseHandler {
public:
template<typename I>
CurlInputStream(EventLoop &event_loop, const char *_url,
CurlInputStream(EventLoop &event_loop, std::string_view _url,
const Curl::Headers &headers,
I &&_icy,
Mutex &_mutex);
@ -76,7 +76,7 @@ public:
CurlInputStream(const CurlInputStream &) = delete;
CurlInputStream &operator=(const CurlInputStream &) = delete;
static InputStreamPtr Open(const char *url,
static InputStreamPtr Open(std::string_view url,
const Curl::Headers &headers,
Mutex &mutex);
@ -435,7 +435,7 @@ input_curl_finish() noexcept
template<typename I>
inline
CurlInputStream::CurlInputStream(EventLoop &event_loop, const char *_url,
CurlInputStream::CurlInputStream(EventLoop &event_loop, std::string_view _url,
const Curl::Headers &headers,
I &&_icy,
Mutex &_mutex)
@ -568,7 +568,7 @@ CurlInputStream::DoSeek(offset_type new_offset)
}
inline InputStreamPtr
CurlInputStream::Open(const char *url,
CurlInputStream::Open(std::string_view url,
const Curl::Headers &headers,
Mutex &mutex)
{
@ -588,7 +588,7 @@ CurlInputStream::Open(const char *url,
}
InputStreamPtr
OpenCurlInputStream(const char *uri, const Curl::Headers &headers,
OpenCurlInputStream(std::string_view uri, const Curl::Headers &headers,
Mutex &mutex)
{
return CurlInputStream::Open(uri, headers, mutex);

View File

@ -1,13 +1,14 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project
#ifndef MPD_INPUT_CURL_HXX
#define MPD_INPUT_CURL_HXX
#pragma once
#include "lib/curl/Headers.hxx"
#include "input/Ptr.hxx"
#include "thread/Mutex.hxx"
#include <string_view>
extern const struct InputPlugin input_plugin_curl;
/**
@ -18,7 +19,5 @@ extern const struct InputPlugin input_plugin_curl;
* Throws on error.
*/
InputStreamPtr
OpenCurlInputStream(const char *uri, const Curl::Headers &headers,
OpenCurlInputStream(std::string_view uri, const Curl::Headers &headers,
Mutex &mutex);
#endif

View File

@ -25,7 +25,7 @@ class NfsInputStream final : NfsFileReader, public AsyncInputStream {
bool reconnect_on_resume = false, reconnecting = false;
public:
NfsInputStream(const char *_uri, Mutex &_mutex)
NfsInputStream(std::string_view _uri, Mutex &_mutex) noexcept
:AsyncInputStream(NfsFileReader::GetEventLoop(),
_uri, _mutex,
NFS_MAX_BUFFERED,

View File

@ -45,7 +45,7 @@ class UringInputStream final : public AsyncInputStream, Uring::ReadHandler {
public:
UringInputStream(EventLoop &event_loop, Uring::Queue &_uring,
const char *path,
std::string_view path,
UniqueFileDescriptor &&_fd,
offset_type _size, Mutex &_mutex)
:AsyncInputStream(event_loop,