diff --git a/src/RemoteTagCache.cxx b/src/RemoteTagCache.cxx index fc1bc88c9..474dd45cd 100644 --- a/src/RemoteTagCache.cxx +++ b/src/RemoteTagCache.cxx @@ -36,7 +36,7 @@ RemoteTagCache::Lookup(const std::string &uri) noexcept lock.unlock(); try { - item->scanner = InputScanTags(uri.c_str(), *item); + item->scanner = InputScanTags(uri, *item); if (!item->scanner) { /* unsupported */ lock.lock(); diff --git a/src/command/FileCommands.cxx b/src/command/FileCommands.cxx index fae16dceb..475d20894 100644 --- a/src/command/FileCommands.cxx +++ b/src/command/FileCommands.cxx @@ -146,7 +146,7 @@ find_stream_art(std::string_view directory, Mutex &mutex) std::string art_file = PathTraitsUTF8::Build(directory, name); try { - return InputStream::OpenReady(art_file.c_str(), mutex); + return InputStream::OpenReady(art_file, mutex); } catch (...) { auto e = std::current_exception(); if (!IsFileNotFound(e)) diff --git a/src/command/FingerprintCommands.cxx b/src/command/FingerprintCommands.cxx index c6f46600b..fc60e52d2 100644 --- a/src/command/FingerprintCommands.cxx +++ b/src/command/FingerprintCommands.cxx @@ -68,7 +68,7 @@ private: void DecodeFile(); /* virtual methods from class DecoderClient */ - InputStreamPtr OpenUri(const char *uri) override; + InputStreamPtr OpenUri(std::string_view uri) override; size_t Read(InputStream &is, std::span dest) noexcept override; @@ -246,14 +246,14 @@ try { if (!path.IsNull()) DecodeFile(); else - DecodeStream(*OpenUri(uri.c_str())); + DecodeStream(*OpenUri(uri)); ChromaprintDecoderClient::Finish(); } catch (StopDecoder) { } InputStreamPtr -GetChromaprintCommand::OpenUri(const char *uri2) +GetChromaprintCommand::OpenUri(std::string_view uri2) { if (cancel) throw StopDecoder(); diff --git a/src/decoder/Bridge.cxx b/src/decoder/Bridge.cxx index 0eec4a1d1..c2acf362b 100644 --- a/src/decoder/Bridge.cxx +++ b/src/decoder/Bridge.cxx @@ -372,7 +372,7 @@ DecoderBridge::SeekError() noexcept } InputStreamPtr -DecoderBridge::OpenUri(const char *uri) +DecoderBridge::OpenUri(std::string_view uri) { assert(dc.state == DecoderState::START || dc.state == DecoderState::DECODE); diff --git a/src/decoder/Bridge.hxx b/src/decoder/Bridge.hxx index 663fd1a1a..403b5f3b8 100644 --- a/src/decoder/Bridge.hxx +++ b/src/decoder/Bridge.hxx @@ -158,7 +158,7 @@ public: SongTime GetSeekTime() noexcept override; uint64_t GetSeekFrame() noexcept override; void SeekError() noexcept override; - InputStreamPtr OpenUri(const char *uri) override; + InputStreamPtr OpenUri(std::string_view uri) override; size_t Read(InputStream &is, std::span dest) noexcept override; void SubmitTimestamp(FloatDuration t) noexcept override; diff --git a/src/decoder/Client.hxx b/src/decoder/Client.hxx index 775b3d227..80156a8c5 100644 --- a/src/decoder/Client.hxx +++ b/src/decoder/Client.hxx @@ -10,6 +10,7 @@ #include #include #include +#include struct AudioFormat; struct Tag; @@ -80,7 +81,7 @@ public: * * Throws std::runtime_error on error. */ - virtual InputStreamPtr OpenUri(const char *uri) = 0; + virtual InputStreamPtr OpenUri(std::string_view uri) = 0; /** * Blocking read from the input stream. diff --git a/src/decoder/Thread.cxx b/src/decoder/Thread.cxx index 0e5518d8f..60ff299f5 100644 --- a/src/decoder/Thread.cxx +++ b/src/decoder/Thread.cxx @@ -227,7 +227,7 @@ decoder_run_stream_plugin(DecoderBridge &bridge, InputStream &is, static DecodeResult decoder_run_stream_locked(DecoderBridge &bridge, InputStream &is, std::unique_lock &lock, - const char *uri) + std::string_view uri) { const auto suffix = uri_get_suffix(uri); diff --git a/src/decoder/plugins/WavpackDecoderPlugin.cxx b/src/decoder/plugins/WavpackDecoderPlugin.cxx index a7cbb4085..95d8a19b5 100644 --- a/src/decoder/plugins/WavpackDecoderPlugin.cxx +++ b/src/decoder/plugins/WavpackDecoderPlugin.cxx @@ -11,7 +11,6 @@ #include "fs/Path.hxx" #include "lib/fmt/PathFormatter.hxx" #include "lib/fmt/RuntimeError.hxx" -#include "util/AllocatedString.hxx" #include "util/Math.hxx" #include "util/ScopeExit.hxx" @@ -407,10 +406,8 @@ static constexpr WavpackStreamReader64 mpd_is_reader = { static InputStreamPtr wavpack_open_wvc(DecoderClient &client, std::string_view uri) { - const AllocatedString wvc_url{uri, "c"sv}; - try { - return client.OpenUri(wvc_url.c_str()); + return client.OpenUri(fmt::format("{}c", uri)); } catch (...) { return nullptr; } diff --git a/src/input/InputPlugin.cxx b/src/input/InputPlugin.cxx index cddcccce9..89e539fe7 100644 --- a/src/input/InputPlugin.cxx +++ b/src/input/InputPlugin.cxx @@ -9,7 +9,7 @@ #include bool -InputPlugin::SupportsUri(const char *uri) const noexcept +InputPlugin::SupportsUri(std::string_view uri) const noexcept { assert(prefixes || protocols); if (prefixes != nullptr) { diff --git a/src/input/InputPlugin.hxx b/src/input/InputPlugin.hxx index 742618e55..31dfe9911 100644 --- a/src/input/InputPlugin.hxx +++ b/src/input/InputPlugin.hxx @@ -47,7 +47,7 @@ struct InputPlugin { * * Throws std::runtime_error on error. */ - InputStreamPtr (*open)(const char *uri, Mutex &mutex); + InputStreamPtr (*open)(std::string_view uri, Mutex &mutex); /** * return a set of supported protocols @@ -63,11 +63,11 @@ struct InputPlugin { * * @return nullptr if the given URI is not supported. */ - std::unique_ptr (*scan_tags)(const char *uri, + std::unique_ptr (*scan_tags)(std::string_view uri, RemoteTagHandler &handler) = nullptr; [[gnu::pure]] - bool SupportsUri(const char *uri) const noexcept; + bool SupportsUri(std::string_view uri) const noexcept; template void ForeachSupportedUri(F lambda) const noexcept { diff --git a/src/input/InputStream.cxx b/src/input/InputStream.cxx index 3b9fa6a47..81844ac74 100644 --- a/src/input/InputStream.cxx +++ b/src/input/InputStream.cxx @@ -4,7 +4,7 @@ #include "InputStream.hxx" #include "Handler.hxx" #include "tag/Tag.hxx" -#include "util/ASCII.hxx" +#include "util/StringCompare.hxx" #include #include @@ -38,17 +38,17 @@ InputStream::SetReady() noexcept */ [[gnu::pure]] static bool -ExpensiveSeeking(const char *uri) noexcept +ExpensiveSeeking(std::string_view uri) noexcept { - return StringStartsWithCaseASCII(uri, "http://") || - StringStartsWithCaseASCII(uri, "qobuz://") || - StringStartsWithCaseASCII(uri, "https://"); + return StringStartsWithIgnoreCase(uri, "http://") || + StringStartsWithIgnoreCase(uri, "qobuz://") || + StringStartsWithIgnoreCase(uri, "https://"); } bool InputStream::CheapSeeking() const noexcept { - return IsSeekable() && !ExpensiveSeeking(uri.c_str()); + return IsSeekable() && !ExpensiveSeeking(uri); } //[[noreturn]] diff --git a/src/input/InputStream.hxx b/src/input/InputStream.hxx index d35ceb9d9..a56545483 100644 --- a/src/input/InputStream.hxx +++ b/src/input/InputStream.hxx @@ -111,14 +111,14 @@ public: * @return an #InputStream object on success */ [[nodiscard]] - static InputStreamPtr Open(const char *uri, Mutex &mutex); + static InputStreamPtr Open(std::string_view uri, Mutex &mutex); /** * Just like Open(), but waits for the stream to become ready. * It is a wrapper for Open(), WaitReady() and Check(). */ [[nodiscard]] - static InputStreamPtr OpenReady(const char *uri, Mutex &mutex); + static InputStreamPtr OpenReady(std::string_view uri, Mutex &mutex); /** * Install a new handler. diff --git a/src/input/Open.cxx b/src/input/Open.cxx index b5656688b..af3aba617 100644 --- a/src/input/Open.cxx +++ b/src/input/Open.cxx @@ -13,7 +13,7 @@ #include InputStreamPtr -InputStream::Open(const char *url, Mutex &mutex) +InputStream::Open(std::string_view url, Mutex &mutex) { if (PathTraitsUTF8::IsAbsolute(url)) { const auto path = AllocatedPath::FromUTF8Throw(url); @@ -32,7 +32,7 @@ InputStream::Open(const char *url, Mutex &mutex) } InputStreamPtr -InputStream::OpenReady(const char *uri, Mutex &mutex) +InputStream::OpenReady(std::string_view uri, Mutex &mutex) { auto is = Open(uri, mutex); LockWaitReady(*is); diff --git a/src/input/ProxyInputStream.hxx b/src/input/ProxyInputStream.hxx index 93c7959bd..b928e4fe6 100644 --- a/src/input/ProxyInputStream.hxx +++ b/src/input/ProxyInputStream.hxx @@ -1,8 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The Music Player Daemon Project -#ifndef MPD_PROXY_INPUT_STREAM_HXX -#define MPD_PROXY_INPUT_STREAM_HXX +#pragma once #include "InputStream.hxx" #include "Ptr.hxx" @@ -26,15 +25,17 @@ protected: InputStreamPtr input; public: + [[nodiscard]] explicit ProxyInputStream(InputStreamPtr _input) noexcept; /** * Construct an instance without an #InputStream instance. * Once that instance becomes available, call SetInput(). */ - ProxyInputStream(const char *_uri, - Mutex &_mutex) noexcept - :InputStream(_uri, _mutex) {} + template + [[nodiscard]] + ProxyInputStream(U &&_uri, Mutex &_mutex) noexcept + :InputStream(std::forward(_uri), _mutex) {} ~ProxyInputStream() noexcept override; @@ -78,5 +79,3 @@ protected: InvokeOnAvailable(); } }; - -#endif diff --git a/src/input/Registry.cxx b/src/input/Registry.cxx index a574592e7..f642d0cae 100644 --- a/src/input/Registry.cxx +++ b/src/input/Registry.cxx @@ -70,7 +70,7 @@ static constexpr std::size_t n_input_plugins = std::size(input_plugins) - 1; bool input_plugins_enabled[std::max(n_input_plugins, std::size_t(1))]; bool -HasRemoteTagScanner(const char *uri) noexcept +HasRemoteTagScanner(std::string_view uri) noexcept { for (const auto &plugin : GetEnabledInputPlugins()) { if (plugin.scan_tags != nullptr && diff --git a/src/input/Registry.hxx b/src/input/Registry.hxx index f17934b4e..8dacf99c8 100644 --- a/src/input/Registry.hxx +++ b/src/input/Registry.hxx @@ -7,6 +7,8 @@ #include "util/FilteredContainer.hxx" #include "util/TerminatedArray.hxx" +#include + /** * NULL terminated list of all input plugins which were enabled at * compile time. @@ -30,4 +32,4 @@ GetEnabledInputPlugins() noexcept [[gnu::pure]] bool -HasRemoteTagScanner(const char *uri) noexcept; +HasRemoteTagScanner(std::string_view uri) noexcept; diff --git a/src/input/ScanTags.cxx b/src/input/ScanTags.cxx index 224c22c2b..ffc717ab3 100644 --- a/src/input/ScanTags.cxx +++ b/src/input/ScanTags.cxx @@ -7,7 +7,7 @@ #include "Registry.hxx" std::unique_ptr -InputScanTags(const char *uri, RemoteTagHandler &handler) +InputScanTags(std::string_view uri, RemoteTagHandler &handler) { for (const auto &plugin : GetEnabledInputPlugins()) { if (plugin.scan_tags == nullptr || !plugin.SupportsUri(uri)) diff --git a/src/input/ScanTags.hxx b/src/input/ScanTags.hxx index f5a6420b9..bd7e11bab 100644 --- a/src/input/ScanTags.hxx +++ b/src/input/ScanTags.hxx @@ -1,10 +1,10 @@ // SPDX-License-Identifier: GPL-2.0-or-later // Copyright The Music Player Daemon Project -#ifndef MPD_INPUT_SCAN_TAGS_HXX -#define MPD_INPUT_SCAN_TAGS_HXX +#pragma once #include +#include class RemoteTagScanner; class RemoteTagHandler; @@ -19,6 +19,4 @@ class RemoteTagHandler; * by any (enabled) plugin */ std::unique_ptr -InputScanTags(const char *uri, RemoteTagHandler &handler); - -#endif +InputScanTags(std::string_view uri, RemoteTagHandler &handler); diff --git a/src/input/ThreadInputStream.cxx b/src/input/ThreadInputStream.cxx index bb3b0c82e..9519b1acc 100644 --- a/src/input/ThreadInputStream.cxx +++ b/src/input/ThreadInputStream.cxx @@ -9,7 +9,7 @@ #include ThreadInputStream::ThreadInputStream(const char *_plugin, - const char *_uri, + std::string_view _uri, Mutex &_mutex, size_t _buffer_size) noexcept :InputStream(_uri, _mutex), diff --git a/src/input/ThreadInputStream.hxx b/src/input/ThreadInputStream.hxx index f74cd1b00..e650f7a6e 100644 --- a/src/input/ThreadInputStream.hxx +++ b/src/input/ThreadInputStream.hxx @@ -62,7 +62,7 @@ class ThreadInputStream : public InputStream { public: ThreadInputStream(const char *_plugin, - const char *_uri, Mutex &_mutex, + std::string_view _uri, Mutex &_mutex, size_t _buffer_size) noexcept; #ifndef NDEBUG diff --git a/src/input/plugins/AlsaInputPlugin.cxx b/src/input/plugins/AlsaInputPlugin.cxx index 39aa6abd3..f8099686c 100644 --- a/src/input/plugins/AlsaInputPlugin.cxx +++ b/src/input/plugins/AlsaInputPlugin.cxx @@ -90,7 +90,7 @@ public: AlsaInputStream(const AlsaInputStream &) = delete; AlsaInputStream &operator=(const AlsaInputStream &) = delete; - static InputStreamPtr Create(EventLoop &event_loop, const char *uri, + static InputStreamPtr Create(EventLoop &event_loop, std::string_view uri, Mutex &mutex); protected: @@ -194,11 +194,9 @@ AlsaInputStream::AlsaInputStream(EventLoop &_loop, } inline InputStreamPtr -AlsaInputStream::Create(EventLoop &event_loop, const char *uri, +AlsaInputStream::Create(EventLoop &event_loop, std::string_view uri, Mutex &mutex) { - assert(uri != nullptr); - AlsaInputStream::SourceSpec spec(uri); if (!spec.IsValidScheme()) return nullptr; @@ -451,7 +449,7 @@ alsa_input_init(EventLoop &event_loop, const ConfigBlock &block) } static InputStreamPtr -alsa_input_open(const char *uri, Mutex &mutex) +alsa_input_open(std::string_view uri, Mutex &mutex) { return AlsaInputStream::Create(*global_config.event_loop, uri, mutex); diff --git a/src/input/plugins/CdioParanoiaInputPlugin.cxx b/src/input/plugins/CdioParanoiaInputPlugin.cxx index 94021befa..2d341193f 100644 --- a/src/input/plugins/CdioParanoiaInputPlugin.cxx +++ b/src/input/plugins/CdioParanoiaInputPlugin.cxx @@ -47,7 +47,7 @@ class CdioParanoiaInputStream final : public InputStream { lsn_t buffer_lsn; public: - CdioParanoiaInputStream(const char *_uri, Mutex &_mutex, + CdioParanoiaInputStream(std::string_view _uri, Mutex &_mutex, cdrom_drive_t *_drv, CdIo_t *_cdio, bool reverse_endian, lsn_t _lsn_from, lsn_t lsn_to) @@ -171,7 +171,7 @@ cdio_detect_device() } static InputStreamPtr -input_cdio_open(const char *uri, +input_cdio_open(std::string_view uri, Mutex &mutex) { const auto parsed_uri = parse_cdio_uri(uri); diff --git a/src/input/plugins/CurlInputPlugin.cxx b/src/input/plugins/CurlInputPlugin.cxx index e9a22794d..fcee9135d 100644 --- a/src/input/plugins/CurlInputPlugin.cxx +++ b/src/input/plugins/CurlInputPlugin.cxx @@ -19,9 +19,9 @@ #include "lib/fmt/ToBuffer.hxx" #include "event/Call.hxx" #include "event/Loop.hxx" -#include "util/ASCII.hxx" #include "util/CNumberParser.hxx" #include "util/Domain.hxx" +#include "util/StringCompare.hxx" #include "Log.hxx" #include "PluginUnavailable.hxx" #include "config.h" @@ -42,6 +42,8 @@ #include +using std::string_view_literals::operator""sv; + /** * Do not buffer more than this number of bytes. It should be a * reasonable limit that doesn't make low-end machines suffer too @@ -596,10 +598,10 @@ OpenCurlInputStream(std::string_view uri, const Curl::Headers &headers, } static InputStreamPtr -input_curl_open(const char *url, Mutex &mutex) +input_curl_open(std::string_view url, Mutex &mutex) { - if (!StringStartsWithCaseASCII(url, "http://") && - !StringStartsWithCaseASCII(url, "https://")) + if (!StringStartsWithIgnoreCase(url, "http://"sv) && + !StringStartsWithIgnoreCase(url, "https://"sv)) return nullptr; return CurlInputStream::Open(url, {}, mutex); diff --git a/src/input/plugins/FfmpegInputPlugin.cxx b/src/input/plugins/FfmpegInputPlugin.cxx index 3f9c69a7d..1d7cbc17a 100644 --- a/src/input/plugins/FfmpegInputPlugin.cxx +++ b/src/input/plugins/FfmpegInputPlugin.cxx @@ -18,7 +18,7 @@ class FfmpegInputStream final : public ThreadInputStream { Ffmpeg::IOContext io; public: - FfmpegInputStream(const char *_uri, Mutex &_mutex) + FfmpegInputStream(std::string_view _uri, Mutex &_mutex) :ThreadInputStream("ffmpeg", _uri, _mutex, BUFFER_SIZE) { Start(); @@ -82,8 +82,7 @@ input_ffmpeg_protocols() noexcept } static InputStreamPtr -input_ffmpeg_open(const char *uri, - Mutex &mutex) +input_ffmpeg_open(std::string_view uri, Mutex &mutex) { return std::make_unique(uri, mutex); } diff --git a/src/input/plugins/MmsInputPlugin.cxx b/src/input/plugins/MmsInputPlugin.cxx index 2cd340a3a..5941d5c9e 100644 --- a/src/input/plugins/MmsInputPlugin.cxx +++ b/src/input/plugins/MmsInputPlugin.cxx @@ -16,7 +16,7 @@ class MmsInputStream final : public ThreadInputStream { mmsx_t *mms; public: - MmsInputStream(const char *_uri, Mutex &_mutex) + MmsInputStream(std::string_view _uri, Mutex &_mutex) :ThreadInputStream(input_plugin_mms.name, _uri, _mutex, BUFFER_SIZE) { @@ -56,8 +56,7 @@ MmsInputStream::Open() } static InputStreamPtr -input_mms_open(const char *url, - Mutex &mutex) +input_mms_open(std::string_view url, Mutex &mutex) { return std::make_unique(url, mutex); } diff --git a/src/input/plugins/NfsInputPlugin.cxx b/src/input/plugins/NfsInputPlugin.cxx index 2fccc4d14..ef7d91887 100644 --- a/src/input/plugins/NfsInputPlugin.cxx +++ b/src/input/plugins/NfsInputPlugin.cxx @@ -213,7 +213,7 @@ input_nfs_finish() noexcept } static InputStreamPtr -input_nfs_open(const char *uri, +input_nfs_open(std::string_view uri, Mutex &mutex) { auto is = std::make_unique(uri, mutex); diff --git a/src/input/plugins/QobuzInputPlugin.cxx b/src/input/plugins/QobuzInputPlugin.cxx index ce3e739bf..0635bd972 100644 --- a/src/input/plugins/QobuzInputPlugin.cxx +++ b/src/input/plugins/QobuzInputPlugin.cxx @@ -17,6 +17,8 @@ #include +using std::string_view_literals::operator""sv; + static QobuzClient *qobuz_client; class QobuzInputStream final @@ -29,7 +31,7 @@ class QobuzInputStream final std::exception_ptr error; public: - QobuzInputStream(const char *_uri, const char *_track_id, + QobuzInputStream(std::string_view _uri, std::string_view _track_id, Mutex &_mutex) noexcept :ProxyInputStream(_uri, _mutex), track_id(_track_id) @@ -151,27 +153,23 @@ FinishQobuzInput() noexcept } [[gnu::pure]] -static const char * -ExtractQobuzTrackId(const char *uri) +static std::string_view +ExtractQobuzTrackId(std::string_view uri) noexcept { // TODO: what's the standard "qobuz://" URI syntax? - const char *track_id = StringAfterPrefix(uri, "qobuz://track/"); - if (track_id == nullptr) - return nullptr; + if (SkipPrefix(uri, "qobuz://track/"sv)) + return uri; - if (*track_id == 0) - return nullptr; - - return track_id; + return {}; } static InputStreamPtr -OpenQobuzInput(const char *uri, Mutex &mutex) +OpenQobuzInput(std::string_view uri, Mutex &mutex) { assert(qobuz_client != nullptr); - const char *track_id = ExtractQobuzTrackId(uri); - if (track_id == nullptr) + const auto track_id = ExtractQobuzTrackId(uri); + if (track_id.empty()) return nullptr; // TODO: validate track_id @@ -180,12 +178,12 @@ OpenQobuzInput(const char *uri, Mutex &mutex) } static std::unique_ptr -ScanQobuzTags(const char *uri, RemoteTagHandler &handler) +ScanQobuzTags(std::string_view uri, RemoteTagHandler &handler) { assert(qobuz_client != nullptr); - const char *track_id = ExtractQobuzTrackId(uri); - if (track_id == nullptr) + const auto track_id = ExtractQobuzTrackId(uri); + if (track_id.empty()) return nullptr; return std::make_unique(*qobuz_client, track_id, diff --git a/src/input/plugins/QobuzTagScanner.cxx b/src/input/plugins/QobuzTagScanner.cxx index ffc3b4edc..90ed69c43 100644 --- a/src/input/plugins/QobuzTagScanner.cxx +++ b/src/input/plugins/QobuzTagScanner.cxx @@ -61,16 +61,16 @@ public: }; static std::string -MakeTrackUrl(QobuzClient &client, const char *track_id) +MakeTrackUrl(QobuzClient &client, std::string_view track_id) { return client.MakeUrl("track", "get", { - {"track_id", track_id}, + {"track_id", std::string{track_id}}, }); } QobuzTagScanner::QobuzTagScanner(QobuzClient &client, - const char *track_id, + std::string_view track_id, RemoteTagHandler &_handler) :request(client.GetCurl(), MakeTrackUrl(client, track_id).c_str(), diff --git a/src/input/plugins/QobuzTagScanner.hxx b/src/input/plugins/QobuzTagScanner.hxx index 2da7a260f..8b78df239 100644 --- a/src/input/plugins/QobuzTagScanner.hxx +++ b/src/input/plugins/QobuzTagScanner.hxx @@ -21,7 +21,7 @@ public: class ResponseParser; QobuzTagScanner(QobuzClient &client, - const char *track_id, + std::string_view track_id, RemoteTagHandler &_handler); ~QobuzTagScanner() noexcept override; diff --git a/src/input/plugins/SmbclientInputPlugin.cxx b/src/input/plugins/SmbclientInputPlugin.cxx index 70333df17..1fead3720 100644 --- a/src/input/plugins/SmbclientInputPlugin.cxx +++ b/src/input/plugins/SmbclientInputPlugin.cxx @@ -17,7 +17,7 @@ class SmbclientInputStream final : public InputStream { SMBCFILE *const handle; public: - SmbclientInputStream(const char *_uri, + SmbclientInputStream(std::string &&_uri, Mutex &_mutex, SmbclientContext &&_ctx, SMBCFILE *_handle, const struct stat &st) @@ -64,12 +64,13 @@ input_smbclient_init(EventLoop &, const ConfigBlock &) } static InputStreamPtr -input_smbclient_open(const char *uri, +input_smbclient_open(std::string_view _uri, Mutex &mutex) { auto ctx = SmbclientContext::New(); - SMBCFILE *handle = ctx.OpenReadOnly(uri); + std::string uri{_uri}; + SMBCFILE *handle = ctx.OpenReadOnly(uri.c_str()); if (handle == nullptr) throw MakeErrno("smbc_open() failed"); @@ -81,7 +82,7 @@ input_smbclient_open(const char *uri, } return std::make_unique - (std::make_unique(uri, mutex, + (std::make_unique(std::move(uri), mutex, std::move(ctx), handle, st)); } diff --git a/src/lib/chromaprint/DecoderClient.hxx b/src/lib/chromaprint/DecoderClient.hxx index f5385ca5c..a294af65f 100644 --- a/src/lib/chromaprint/DecoderClient.hxx +++ b/src/lib/chromaprint/DecoderClient.hxx @@ -71,7 +71,7 @@ public: void SeekError() noexcept override {} - //InputStreamPtr OpenUri(const char *) override; + //InputStreamPtr OpenUri(std::string_view uri) override; size_t Read(InputStream &is, std::span dest) noexcept override; diff --git a/src/storage/plugins/SmbclientStorage.cxx b/src/storage/plugins/SmbclientStorage.cxx index c5c7f410e..f63d0f66d 100644 --- a/src/storage/plugins/SmbclientStorage.cxx +++ b/src/storage/plugins/SmbclientStorage.cxx @@ -119,8 +119,7 @@ SmbclientStorage::GetInfo(std::string_view uri_utf8, [[maybe_unused]] bool follo InputStreamPtr SmbclientStorage::OpenFile(std::string_view uri_utf8, Mutex &file_mutex) { - auto uri = MapUTF8(uri_utf8); - return InputStream::Open(uri.c_str(), file_mutex); + return InputStream::Open(MapUTF8(uri_utf8), file_mutex); } std::unique_ptr diff --git a/test/DumpDecoderClient.cxx b/test/DumpDecoderClient.cxx index 809af22c0..e9bc4a17b 100644 --- a/test/DumpDecoderClient.cxx +++ b/test/DumpDecoderClient.cxx @@ -54,7 +54,7 @@ DumpDecoderClient::SeekError() noexcept } InputStreamPtr -DumpDecoderClient::OpenUri(const char *uri) +DumpDecoderClient::OpenUri(std::string_view uri) { return InputStream::OpenReady(uri, mutex); } diff --git a/test/DumpDecoderClient.hxx b/test/DumpDecoderClient.hxx index 828a5b73b..d35fd60ee 100644 --- a/test/DumpDecoderClient.hxx +++ b/test/DumpDecoderClient.hxx @@ -31,7 +31,7 @@ public: SongTime GetSeekTime() noexcept override; uint64_t GetSeekFrame() noexcept override; void SeekError() noexcept override; - InputStreamPtr OpenUri(const char *uri) override; + InputStreamPtr OpenUri(std::string_view uri) override; size_t Read(InputStream &is, std::span dest) noexcept override; void SubmitTimestamp(FloatDuration t) noexcept override; diff --git a/test/RunChromaprint.cxx b/test/RunChromaprint.cxx index 3560fd5a0..e17dc534e 100644 --- a/test/RunChromaprint.cxx +++ b/test/RunChromaprint.cxx @@ -90,7 +90,7 @@ public: class MyChromaprintDecoderClient final : public ChromaprintDecoderClient { public: - InputStreamPtr OpenUri(const char *) override { + InputStreamPtr OpenUri(std::string_view) override { throw std::runtime_error("Not implemented"); } };