lib/alsa/AllowedFormat: pass std::string_view to constructor
This commit is contained in:
parent
9976665cc7
commit
ca90c75c61
@ -21,24 +21,26 @@
|
|||||||
#include "pcm/AudioParser.hxx"
|
#include "pcm/AudioParser.hxx"
|
||||||
#include "util/IterableSplitString.hxx"
|
#include "util/IterableSplitString.hxx"
|
||||||
#include "util/StringBuffer.hxx"
|
#include "util/StringBuffer.hxx"
|
||||||
|
#include "util/StringCompare.hxx"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
using std::string_view_literals::operator""sv;
|
||||||
|
|
||||||
namespace Alsa {
|
namespace Alsa {
|
||||||
|
|
||||||
AllowedFormat::AllowedFormat(StringView s)
|
AllowedFormat::AllowedFormat(std::string_view s)
|
||||||
{
|
{
|
||||||
#ifdef ENABLE_DSD
|
#ifdef ENABLE_DSD
|
||||||
dop = s.RemoveSuffix("=dop");
|
dop = RemoveSuffix(s, "=dop"sv);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char buffer[64];
|
char buffer[64];
|
||||||
if (s.size >= sizeof(buffer))
|
if (s.size() >= sizeof(buffer))
|
||||||
throw std::invalid_argument("Failed to parse audio format");
|
throw std::invalid_argument("Failed to parse audio format");
|
||||||
|
|
||||||
memcpy(buffer, s.data, s.size);
|
*std::copy(s.begin(), s.end(), buffer) = 0;
|
||||||
buffer[s.size] = 0;
|
|
||||||
|
|
||||||
format = ParseAudioFormat(buffer, true);
|
format = ParseAudioFormat(buffer, true);
|
||||||
|
|
||||||
|
@ -26,8 +26,6 @@
|
|||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
struct StringView;
|
|
||||||
|
|
||||||
namespace Alsa {
|
namespace Alsa {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -45,7 +43,7 @@ struct AllowedFormat {
|
|||||||
*
|
*
|
||||||
* Throws std::runtime_error on error.
|
* Throws std::runtime_error on error.
|
||||||
*/
|
*/
|
||||||
explicit AllowedFormat(StringView s);
|
explicit AllowedFormat(std::string_view s);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parse a list of formats separated by space.
|
* Parse a list of formats separated by space.
|
||||||
|
Loading…
Reference in New Issue
Block a user