input/Plugin: pass URI as std::string_view

This commit is contained in:
Max Kellermann
2025-01-30 11:20:52 +01:00
parent aee49d1c1c
commit 715ef846b6
35 changed files with 85 additions and 92 deletions

View File

@@ -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);

View File

@@ -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<std::byte> dest) noexcept override;
void SubmitTimestamp(FloatDuration t) noexcept override;

View File

@@ -10,6 +10,7 @@
#include <cstddef>
#include <cstdint>
#include <span>
#include <string_view>
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.

View File

@@ -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<Mutex> &lock,
const char *uri)
std::string_view uri)
{
const auto suffix = uri_get_suffix(uri);

View File

@@ -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;
}