Commit 4a30c2d7 authored by Max Kellermann's avatar Max Kellermann

output/shout: use shout_set_meta()

parent 83072d6b
......@@ -229,6 +229,20 @@ ShoutOutput::Create(EventLoop &, const ConfigBlock &block)
return new ShoutOutput(block);
}
static void
SetMeta(shout_t &connection, const char *name, const char *value)
{
if (shout_set_meta(&connection, name, value) != SHOUTERR_SUCCESS)
throw std::runtime_error(shout_get_error(&connection));
}
static void
SetOptionalMeta(shout_t &connection, const char *name, const char *value)
{
if (value != nullptr)
SetMeta(connection, name, value);
}
inline void
ShoutConfig::Setup(shout_t &connection) const
{
......@@ -236,7 +250,6 @@ ShoutConfig::Setup(shout_t &connection) const
shout_set_port(&connection, port) != SHOUTERR_SUCCESS ||
shout_set_password(&connection, passwd) != SHOUTERR_SUCCESS ||
shout_set_mount(&connection, mount) != SHOUTERR_SUCCESS ||
shout_set_name(&connection, name) != SHOUTERR_SUCCESS ||
shout_set_user(&connection, user) != SHOUTERR_SUCCESS ||
shout_set_public(&connection, is_public) != SHOUTERR_SUCCESS ||
shout_set_format(&connection, format) != SHOUTERR_SUCCESS ||
......@@ -247,17 +260,13 @@ ShoutConfig::Setup(shout_t &connection) const
shout_set_agent(&connection, "MPD") != SHOUTERR_SUCCESS)
throw std::runtime_error(shout_get_error(&connection));
/* optional paramters */
if (genre != nullptr && shout_set_genre(&connection, genre))
throw std::runtime_error(shout_get_error(&connection));
SetMeta(connection, SHOUT_META_NAME, name);
if (description != nullptr &&
shout_set_description(&connection, description))
throw std::runtime_error(shout_get_error(&connection));
/* optional paramters */
if (url != nullptr && shout_set_url(&connection, url))
throw std::runtime_error(shout_get_error(&connection));
SetOptionalMeta(connection, SHOUT_META_GENRE, genre);
SetOptionalMeta(connection, SHOUT_META_DESCRIPTION, description);
SetOptionalMeta(connection, SHOUT_META_URL, url);
if (quality != nullptr)
shout_set_audio_info(&connection, SHOUT_AI_QUALITY, quality);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment