output/shout: use libfmt
This commit is contained in:
parent
17f2c0ae88
commit
149d1a2f47
|
@ -19,8 +19,6 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
class ShoutConfig {
|
class ShoutConfig {
|
||||||
const char *const host;
|
const char *const host;
|
||||||
const char *const mount;
|
const char *const mount;
|
||||||
|
@ -417,13 +415,13 @@ ShoutOutput::Pause()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static std::string
|
||||||
shout_tag_to_metadata(const Tag &tag, char *dest, size_t size) noexcept
|
shout_tag_to_metadata(const Tag &tag) noexcept
|
||||||
{
|
{
|
||||||
const char *artist = tag.GetValue(TAG_ARTIST);
|
const char *artist = tag.GetValue(TAG_ARTIST);
|
||||||
const char *title = tag.GetValue(TAG_TITLE);
|
const char *title = tag.GetValue(TAG_TITLE);
|
||||||
|
|
||||||
snprintf(dest, size, "%s - %s",
|
return fmt::format("{} - {}",
|
||||||
artist != nullptr ? artist : "",
|
artist != nullptr ? artist : "",
|
||||||
title != nullptr ? title : "");
|
title != nullptr ? title : "");
|
||||||
}
|
}
|
||||||
|
@ -443,10 +441,9 @@ ShoutOutput::SendTag(const Tag &tag)
|
||||||
const auto meta = shout_metadata_new();
|
const auto meta = shout_metadata_new();
|
||||||
AtScopeExit(meta) { shout_metadata_free(meta); };
|
AtScopeExit(meta) { shout_metadata_free(meta); };
|
||||||
|
|
||||||
char song[1024];
|
const auto song = shout_tag_to_metadata(tag);
|
||||||
shout_tag_to_metadata(tag, song, sizeof(song));
|
|
||||||
|
|
||||||
if (SHOUTERR_SUCCESS != shout_metadata_add(meta, "song", song) ||
|
if (SHOUTERR_SUCCESS != shout_metadata_add(meta, "song", song.c_str()) ||
|
||||||
#ifdef SHOUT_FORMAT_TEXT
|
#ifdef SHOUT_FORMAT_TEXT
|
||||||
/* since libshout 2.4.6 */
|
/* since libshout 2.4.6 */
|
||||||
SHOUTERR_SUCCESS != shout_set_metadata_utf8(shout_conn, meta)
|
SHOUTERR_SUCCESS != shout_set_metadata_utf8(shout_conn, meta)
|
||||||
|
|
Loading…
Reference in New Issue