diff --git a/src/lib/alsa/AllowedFormat.cxx b/src/lib/alsa/AllowedFormat.cxx index b89efe7e9..63ae7bc74 100644 --- a/src/lib/alsa/AllowedFormat.cxx +++ b/src/lib/alsa/AllowedFormat.cxx @@ -21,24 +21,26 @@ #include "pcm/AudioParser.hxx" #include "util/IterableSplitString.hxx" #include "util/StringBuffer.hxx" +#include "util/StringCompare.hxx" #include "config.h" #include +using std::string_view_literals::operator""sv; + namespace Alsa { -AllowedFormat::AllowedFormat(StringView s) +AllowedFormat::AllowedFormat(std::string_view s) { #ifdef ENABLE_DSD - dop = s.RemoveSuffix("=dop"); + dop = RemoveSuffix(s, "=dop"sv); #endif char buffer[64]; - if (s.size >= sizeof(buffer)) + if (s.size() >= sizeof(buffer)) throw std::invalid_argument("Failed to parse audio format"); - memcpy(buffer, s.data, s.size); - buffer[s.size] = 0; + *std::copy(s.begin(), s.end(), buffer) = 0; format = ParseAudioFormat(buffer, true); diff --git a/src/lib/alsa/AllowedFormat.hxx b/src/lib/alsa/AllowedFormat.hxx index d54e91d60..cd414bee7 100644 --- a/src/lib/alsa/AllowedFormat.hxx +++ b/src/lib/alsa/AllowedFormat.hxx @@ -26,8 +26,6 @@ #include #include -struct StringView; - namespace Alsa { /** @@ -45,7 +43,7 @@ struct AllowedFormat { * * Throws std::runtime_error on error. */ - explicit AllowedFormat(StringView s); + explicit AllowedFormat(std::string_view s); /** * Parse a list of formats separated by space.