output/alsa: add attributes "dop" and "allowed_formats"

This commit is contained in:
Max Kellermann
2017-12-19 10:44:29 +01:00
parent 86a06a7acc
commit 8ac73a9eba
5 changed files with 128 additions and 6 deletions

View File

@@ -21,6 +21,7 @@
#include "AllowedFormat.hxx"
#include "AudioParser.hxx"
#include "util/IterableSplitString.hxx"
#include "util/StringBuffer.hxx"
#include <stdexcept>
@@ -65,4 +66,24 @@ AllowedFormat::ParseList(StringView s)
return list;
}
std::string
ToString(const std::forward_list<AllowedFormat> &allowed_formats) noexcept
{
std::string result;
for (const auto &i : allowed_formats) {
if (!result.empty())
result.push_back(' ');
result += ::ToString(i.format);
#ifdef ENABLE_DSD
if (i.dop)
result += "=dop";
#endif
}
return result;
}
} // namespace Alsa

View File

@@ -24,6 +24,7 @@
#include "AudioFormat.hxx"
#include <forward_list>
#include <string>
struct StringView;
@@ -54,6 +55,9 @@ struct AllowedFormat {
static std::forward_list<AllowedFormat> ParseList(StringView s);
};
std::string
ToString(const std::forward_list<AllowedFormat> &allowed_formats) noexcept;
} // namespace Alsa
#endif