use more libfmt instead of sprintf()
This commit is contained in:
parent
02d108774c
commit
415de497d3
|
@ -17,9 +17,10 @@
|
||||||
#include "storage/FileInfo.hxx"
|
#include "storage/FileInfo.hxx"
|
||||||
#include "storage/StorageInterface.hxx"
|
#include "storage/StorageInterface.hxx"
|
||||||
#include "fs/Traits.hxx"
|
#include "fs/Traits.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
|
#include <fmt/core.h>
|
||||||
|
|
||||||
inline void
|
inline void
|
||||||
UpdateWalk::UpdatePlaylistFile(Directory &directory,
|
UpdateWalk::UpdatePlaylistFile(Directory &directory,
|
||||||
SongEnumerator &contents) noexcept
|
SongEnumerator &contents) noexcept
|
||||||
|
@ -41,8 +42,7 @@ UpdateWalk::UpdatePlaylistFile(Directory &directory,
|
||||||
the virtual directory (DEVICE_PLAYLIST) to
|
the virtual directory (DEVICE_PLAYLIST) to
|
||||||
the containing directory */
|
the containing directory */
|
||||||
: "../" + db_song->filename;
|
: "../" + db_song->filename;
|
||||||
db_song->filename = StringFormat<64>("track%04u",
|
db_song->filename = fmt::format("track{:04}", ++track);
|
||||||
++track);
|
|
||||||
|
|
||||||
{
|
{
|
||||||
const ScopeDatabaseLock protect;
|
const ScopeDatabaseLock protect;
|
||||||
|
|
|
@ -54,7 +54,7 @@ DecoderUriDecode(const DecoderPlugin &plugin,
|
||||||
{
|
{
|
||||||
const ScopeUnlock unlock(bridge.dc.mutex);
|
const ScopeUnlock unlock(bridge.dc.mutex);
|
||||||
|
|
||||||
FormatThreadName("decoder:%s", plugin.name);
|
FmtThreadName("decoder:{}", plugin.name);
|
||||||
|
|
||||||
plugin.UriDecode(bridge, uri);
|
plugin.UriDecode(bridge, uri);
|
||||||
|
|
||||||
|
@ -98,7 +98,7 @@ decoder_stream_decode(const DecoderPlugin &plugin,
|
||||||
{
|
{
|
||||||
const ScopeUnlock unlock(bridge.dc.mutex);
|
const ScopeUnlock unlock(bridge.dc.mutex);
|
||||||
|
|
||||||
FormatThreadName("decoder:%s", plugin.name);
|
FmtThreadName("decoder:{}", plugin.name);
|
||||||
|
|
||||||
plugin.StreamDecode(bridge, input_stream);
|
plugin.StreamDecode(bridge, input_stream);
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ decoder_file_decode(const DecoderPlugin &plugin,
|
||||||
{
|
{
|
||||||
const ScopeUnlock unlock(bridge.dc.mutex);
|
const ScopeUnlock unlock(bridge.dc.mutex);
|
||||||
|
|
||||||
FormatThreadName("decoder:%s", plugin.name);
|
FmtThreadName("decoder:{}", plugin.name);
|
||||||
|
|
||||||
plugin.FileDecode(bridge, path);
|
plugin.FileDecode(bridge, path);
|
||||||
|
|
||||||
|
|
|
@ -12,14 +12,16 @@
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "fs/FileSystem.hxx"
|
#include "fs/FileSystem.hxx"
|
||||||
#include "fs/NarrowPath.hxx"
|
#include "fs/NarrowPath.hxx"
|
||||||
|
#include "lib/fmt/PathFormatter.hxx"
|
||||||
#include "util/ScopeExit.hxx"
|
#include "util/ScopeExit.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <gme/gme.h>
|
#include <gme/gme.h>
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
@ -228,16 +230,16 @@ ScanGmeInfo(const gme_info_t &info, unsigned song_num, int track_count,
|
||||||
));
|
));
|
||||||
|
|
||||||
if (track_count > 1)
|
if (track_count > 1)
|
||||||
handler.OnTag(TAG_TRACK, StringFormat<16>("%u", song_num + 1).c_str());
|
handler.OnTag(TAG_TRACK, fmt::format_int{song_num + 1}.c_str());
|
||||||
|
|
||||||
if (!StringIsEmpty(info.song)) {
|
if (!StringIsEmpty(info.song)) {
|
||||||
if (track_count > 1) {
|
if (track_count > 1) {
|
||||||
/* start numbering subtunes from 1 */
|
/* start numbering subtunes from 1 */
|
||||||
const auto tag_title =
|
const auto tag_title =
|
||||||
StringFormat<1024>("%s (%u/%d)",
|
fmt::format("{} ({}/{})",
|
||||||
info.song, song_num + 1,
|
info.song, song_num + 1,
|
||||||
track_count);
|
track_count);
|
||||||
handler.OnTag(TAG_TITLE, tag_title.c_str());
|
handler.OnTag(TAG_TITLE, tag_title);
|
||||||
} else
|
} else
|
||||||
handler.OnTag(TAG_TITLE, info.song);
|
handler.OnTag(TAG_TITLE, info.song);
|
||||||
}
|
}
|
||||||
|
@ -306,7 +308,7 @@ gme_container_scan(Path path_fs)
|
||||||
if (num_songs < 2)
|
if (num_songs < 2)
|
||||||
return list;
|
return list;
|
||||||
|
|
||||||
const auto *subtune_suffix = path_fs.GetExtension();
|
const Path subtune_suffix = Path::FromFS(path_fs.GetExtension());
|
||||||
|
|
||||||
TagBuilder tag_builder;
|
TagBuilder tag_builder;
|
||||||
|
|
||||||
|
@ -315,10 +317,9 @@ gme_container_scan(Path path_fs)
|
||||||
AddTagHandler h(tag_builder);
|
AddTagHandler h(tag_builder);
|
||||||
ScanMusicEmu(emu, i, h);
|
ScanMusicEmu(emu, i, h);
|
||||||
|
|
||||||
const auto track_name =
|
auto track_name = fmt::format(SUBTUNE_PREFIX "{:03}.{}",
|
||||||
StringFormat<64>(SUBTUNE_PREFIX "%03u.%s", i+1,
|
i + 1, subtune_suffix);
|
||||||
subtune_suffix);
|
tail = list.emplace_after(tail, std::move(track_name),
|
||||||
tail = list.emplace_after(tail, track_name,
|
|
||||||
tag_builder.Commit());
|
tag_builder.Commit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,7 +15,6 @@
|
||||||
#ifdef HAVE_SIDPLAYFP
|
#ifdef HAVE_SIDPLAYFP
|
||||||
#include "io/FileReader.hxx"
|
#include "io/FileReader.hxx"
|
||||||
#endif
|
#endif
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "util/AllocatedString.hxx"
|
#include "util/AllocatedString.hxx"
|
||||||
#include "util/CharUtil.hxx"
|
#include "util/CharUtil.hxx"
|
||||||
|
@ -38,6 +37,8 @@
|
||||||
#include <sidplay/utils/SidDatabase.h>
|
#include <sidplay/utils/SidDatabase.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include <iterator>
|
#include <iterator>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
@ -510,7 +511,7 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
|
||||||
|
|
||||||
if (n_tracks > 1) {
|
if (n_tracks > 1) {
|
||||||
const auto tag_title =
|
const auto tag_title =
|
||||||
StringFormat<1024>("%s (%u/%u)",
|
fmt::format("{} ({}/{})",
|
||||||
album.c_str(), track, n_tracks);
|
album.c_str(), track, n_tracks);
|
||||||
handler.OnTag(TAG_TITLE, tag_title.c_str());
|
handler.OnTag(TAG_TITLE, tag_title.c_str());
|
||||||
} else
|
} else
|
||||||
|
@ -532,7 +533,7 @@ ScanSidTuneInfo(const SidTuneInfo &info, unsigned track, unsigned n_tracks,
|
||||||
handler.OnTag(TAG_DATE, date.c_str());
|
handler.OnTag(TAG_DATE, date.c_str());
|
||||||
|
|
||||||
/* track */
|
/* track */
|
||||||
handler.OnTag(TAG_TRACK, StringFormat<16>("%u", track).c_str());
|
handler.OnTag(TAG_TRACK, fmt::format_int{track}.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
|
@ -611,7 +612,7 @@ sidplay_container_scan(Path path_fs)
|
||||||
/* Construct container/tune path names, eg.
|
/* Construct container/tune path names, eg.
|
||||||
Delta.sid/tune_001.sid */
|
Delta.sid/tune_001.sid */
|
||||||
tail = list.emplace_after(tail,
|
tail = list.emplace_after(tail,
|
||||||
StringFormat<32>(SUBTUNE_PREFIX "%03u.sid", i),
|
fmt::format(SUBTUNE_PREFIX "{:03}.sid", i),
|
||||||
tag_builder.Commit());
|
tag_builder.Commit());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,11 +5,12 @@
|
||||||
#include "../DecoderAPI.hxx"
|
#include "../DecoderAPI.hxx"
|
||||||
#include "tag/Handler.hxx"
|
#include "tag/Handler.hxx"
|
||||||
#include "util/ScopeExit.hxx"
|
#include "util/ScopeExit.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "fs/AllocatedPath.hxx"
|
#include "fs/AllocatedPath.hxx"
|
||||||
#include "fs/FileSystem.hxx"
|
#include "fs/FileSystem.hxx"
|
||||||
#include "fs/Path.hxx"
|
#include "fs/Path.hxx"
|
||||||
#include "fs/NarrowPath.hxx"
|
#include "fs/NarrowPath.hxx"
|
||||||
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
|
#include "lib/fmt/PathFormatter.hxx"
|
||||||
#include "PluginUnavailable.hxx"
|
#include "PluginUnavailable.hxx"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
|
@ -31,11 +32,9 @@ wildmidi_init(const ConfigBlock &block)
|
||||||
block.GetPath("config_file",
|
block.GetPath("config_file",
|
||||||
"/etc/timidity/timidity.cfg");
|
"/etc/timidity/timidity.cfg");
|
||||||
|
|
||||||
if (!FileExists(path)) {
|
if (!FileExists(path))
|
||||||
const auto utf8 = path.ToUTF8();
|
throw PluginUnavailable{FmtBuffer<1024>("configuration file does not exist: {}",
|
||||||
throw PluginUnavailable(StringFormat<1024>("configuration file does not exist: %s",
|
path)};
|
||||||
utf8.c_str()));
|
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef LIBWILDMIDI_VERSION
|
#ifdef LIBWILDMIDI_VERSION
|
||||||
/* WildMidi_ClearError() requires libwildmidi 0.4 */
|
/* WildMidi_ClearError() requires libwildmidi 0.4 */
|
||||||
|
|
|
@ -51,7 +51,7 @@ ThreadInputStream::Start()
|
||||||
inline void
|
inline void
|
||||||
ThreadInputStream::ThreadFunc() noexcept
|
ThreadInputStream::ThreadFunc() noexcept
|
||||||
{
|
{
|
||||||
FormatThreadName("input:%s", plugin);
|
FmtThreadName("input:{}", plugin);
|
||||||
|
|
||||||
std::unique_lock<Mutex> lock(mutex);
|
std::unique_lock<Mutex> lock(mutex);
|
||||||
|
|
||||||
|
|
|
@ -16,10 +16,10 @@
|
||||||
#include "config/Block.hxx"
|
#include "config/Block.hxx"
|
||||||
#include "tag/Builder.hxx"
|
#include "tag/Builder.hxx"
|
||||||
#include "tag/Tag.hxx"
|
#include "tag/Tag.hxx"
|
||||||
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
#include "event/Call.hxx"
|
#include "event/Call.hxx"
|
||||||
#include "event/Loop.hxx"
|
#include "event/Loop.hxx"
|
||||||
#include "util/ASCII.hxx"
|
#include "util/ASCII.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "util/NumberParser.hxx"
|
#include "util/NumberParser.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
@ -33,6 +33,8 @@
|
||||||
#include "util/UriQueryParser.hxx"
|
#include "util/UriQueryParser.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <cinttypes>
|
#include <cinttypes>
|
||||||
|
|
||||||
|
@ -261,7 +263,7 @@ CurlInputStream::OnHeaders(unsigned status,
|
||||||
|
|
||||||
if (status < 200 || status >= 300)
|
if (status < 200 || status >= 300)
|
||||||
throw HttpStatusError(status,
|
throw HttpStatusError(status,
|
||||||
StringFormat<40>("got HTTP status %u",
|
FmtBuffer<40>("got HTTP status {}",
|
||||||
status).c_str());
|
status).c_str());
|
||||||
|
|
||||||
const std::scoped_lock<Mutex> protect(mutex);
|
const std::scoped_lock<Mutex> protect(mutex);
|
||||||
|
@ -475,7 +477,7 @@ CurlInputStream::InitEasy()
|
||||||
|
|
||||||
if (proxy_user != nullptr && proxy_password != nullptr)
|
if (proxy_user != nullptr && proxy_password != nullptr)
|
||||||
request->SetOption(CURLOPT_PROXYUSERPWD,
|
request->SetOption(CURLOPT_PROXYUSERPWD,
|
||||||
StringFormat<1024>("%s:%s", proxy_user,
|
FmtBuffer<1024>("{}:{}", proxy_user,
|
||||||
proxy_password).c_str());
|
proxy_password).c_str());
|
||||||
|
|
||||||
if (cacert != nullptr)
|
if (cacert != nullptr)
|
||||||
|
@ -532,8 +534,7 @@ CurlInputStream::SeekInternal(offset_type new_offset)
|
||||||
|
|
||||||
if (offset > 0)
|
if (offset > 0)
|
||||||
request->SetOption(CURLOPT_RANGE,
|
request->SetOption(CURLOPT_RANGE,
|
||||||
StringFormat<40>("%" PRIoffset "-",
|
fmt::format_int{offset}.c_str());
|
||||||
offset).c_str());
|
|
||||||
|
|
||||||
StartRequest();
|
StartRequest();
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
#include "FileOutputStream.hxx"
|
#include "FileOutputStream.hxx"
|
||||||
#include "lib/fmt/PathFormatter.hxx"
|
#include "lib/fmt/PathFormatter.hxx"
|
||||||
#include "lib/fmt/SystemError.hxx"
|
#include "lib/fmt/SystemError.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <tchar.h>
|
#include <tchar.h>
|
||||||
|
@ -282,7 +282,7 @@ try {
|
||||||
|
|
||||||
/* hard-link the temporary file to the final path */
|
/* hard-link the temporary file to the final path */
|
||||||
if (linkat(AT_FDCWD,
|
if (linkat(AT_FDCWD,
|
||||||
StringFormat<64>("/proc/self/fd/%d", fd.Get()),
|
FmtBuffer<64>("/proc/self/fd/{}", fd.Get()),
|
||||||
directory_fd.Get(), path.c_str(),
|
directory_fd.Get(), path.c_str(),
|
||||||
AT_SYMLINK_FOLLOW) < 0)
|
AT_SYMLINK_FOLLOW) < 0)
|
||||||
throw FmtErrno("Failed to commit {}", path);
|
throw FmtErrno("Failed to commit {}", path);
|
||||||
|
|
|
@ -6,8 +6,8 @@
|
||||||
|
|
||||||
#include "LogCallback.hxx"
|
#include "LogCallback.hxx"
|
||||||
#include "Domain.hxx"
|
#include "Domain.hxx"
|
||||||
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -40,7 +40,7 @@ FfmpegLogCallback(void *ptr, int level, const char *fmt, std::va_list vl)
|
||||||
|
|
||||||
if (cls != nullptr) {
|
if (cls != nullptr) {
|
||||||
const auto domain =
|
const auto domain =
|
||||||
StringFormat<64>("%s/%s",
|
FmtBuffer<64>("{}/{}",
|
||||||
ffmpeg_domain.GetName(),
|
ffmpeg_domain.GetName(),
|
||||||
cls->item_name(ptr));
|
cls->item_name(ptr));
|
||||||
const Domain d(domain);
|
const Domain d(domain);
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
// author: Max Kellermann <mk@cm4all.com>
|
// author: Max Kellermann <mk@cm4all.com>
|
||||||
|
|
||||||
#include "Error.hxx"
|
#include "Error.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include <nfsc/libnfs.h>
|
#include <nfsc/libnfs.h>
|
||||||
|
@ -13,20 +13,20 @@ extern "C" {
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
static StringBuffer<256>
|
static auto
|
||||||
FormatNfsClientError(struct nfs_context *nfs, const char *msg) noexcept
|
FormatNfsClientError(struct nfs_context *nfs, const char *msg) noexcept
|
||||||
{
|
{
|
||||||
assert(msg != nullptr);
|
assert(msg != nullptr);
|
||||||
|
|
||||||
const char *msg2 = nfs_get_error(nfs);
|
const char *msg2 = nfs_get_error(nfs);
|
||||||
return StringFormat<256>("%s: %s", msg, msg2);
|
return FmtBuffer<256>("{}: {}", msg, msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
NfsClientError::NfsClientError(struct nfs_context *nfs, const char *msg) noexcept
|
NfsClientError::NfsClientError(struct nfs_context *nfs, const char *msg) noexcept
|
||||||
:std::runtime_error(FormatNfsClientError(nfs, msg).c_str()),
|
:std::runtime_error(FormatNfsClientError(nfs, msg).c_str()),
|
||||||
code(0) {}
|
code(0) {}
|
||||||
|
|
||||||
static StringBuffer<256>
|
static auto
|
||||||
FormatNfsClientError(int err, struct nfs_context *nfs, void *data,
|
FormatNfsClientError(int err, struct nfs_context *nfs, void *data,
|
||||||
const char *msg) noexcept
|
const char *msg) noexcept
|
||||||
{
|
{
|
||||||
|
@ -40,7 +40,7 @@ FormatNfsClientError(int err, struct nfs_context *nfs, void *data,
|
||||||
msg2 = strerror(-err);
|
msg2 = strerror(-err);
|
||||||
}
|
}
|
||||||
|
|
||||||
return StringFormat<256>("%s: %s", msg, msg2);
|
return FmtBuffer<256>("{}: {}", msg, msg2);
|
||||||
}
|
}
|
||||||
|
|
||||||
NfsClientError::NfsClientError(int err, struct nfs_context *nfs, void *data,
|
NfsClientError::NfsClientError(int err, struct nfs_context *nfs, void *data,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
#include "Database.hxx"
|
#include "Database.hxx"
|
||||||
#include "Error.hxx"
|
#include "Error.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
|
|
||||||
namespace Sqlite {
|
namespace Sqlite {
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ Database::Database(const char *path)
|
||||||
int result = sqlite3_open(path, &db);
|
int result = sqlite3_open(path, &db);
|
||||||
if (result != SQLITE_OK)
|
if (result != SQLITE_OK)
|
||||||
throw SqliteError(db, result,
|
throw SqliteError(db, result,
|
||||||
StringFormat<1024>("Failed to open sqlite database '%s'",
|
FmtBuffer<1024>("Failed to open sqlite database '{}'",
|
||||||
path));
|
path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,9 +22,10 @@
|
||||||
#include "filter/plugins/VolumeFilterPlugin.hxx"
|
#include "filter/plugins/VolumeFilterPlugin.hxx"
|
||||||
#include "filter/plugins/NormalizeFilterPlugin.hxx"
|
#include "filter/plugins/NormalizeFilterPlugin.hxx"
|
||||||
#include "util/StringAPI.hxx"
|
#include "util/StringAPI.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
|
#include <fmt/core.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
@ -153,7 +154,7 @@ FilteredAudioOutput::Configure(const ConfigBlock &block,
|
||||||
config_audio_format.Clear();
|
config_audio_format.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
log_name = StringFormat<256>("\"%s\" (%s)", name, plugin_name);
|
log_name = fmt::format("\"{}\" ({})", name, plugin_name);
|
||||||
|
|
||||||
/* create the normalization filter (if configured) */
|
/* create the normalization filter (if configured) */
|
||||||
|
|
||||||
|
|
|
@ -405,7 +405,7 @@ AudioOutputControl::InternalDrain() noexcept
|
||||||
void
|
void
|
||||||
AudioOutputControl::Task() noexcept
|
AudioOutputControl::Task() noexcept
|
||||||
{
|
{
|
||||||
FormatThreadName("output:%s", GetName().c_str());
|
FmtThreadName("output:{}", GetName());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
SetThreadRealtime();
|
SetThreadRealtime();
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "../OutputAPI.hxx"
|
#include "../OutputAPI.hxx"
|
||||||
#include "mixer/plugins/OSXMixerPlugin.hxx"
|
#include "mixer/plugins/OSXMixerPlugin.hxx"
|
||||||
#include "lib/fmt/RuntimeError.hxx"
|
#include "lib/fmt/RuntimeError.hxx"
|
||||||
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "util/Manual.hxx"
|
#include "util/Manual.hxx"
|
||||||
#include "pcm/Export.hxx"
|
#include "pcm/Export.hxx"
|
||||||
|
@ -20,7 +21,6 @@
|
||||||
#include "util/RingBuffer.hxx"
|
#include "util/RingBuffer.hxx"
|
||||||
#include "util/StringAPI.hxx"
|
#include "util/StringAPI.hxx"
|
||||||
#include "util/StringBuffer.hxx"
|
#include "util/StringBuffer.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <CoreAudio/CoreAudio.h>
|
#include <CoreAudio/CoreAudio.h>
|
||||||
|
@ -42,20 +42,20 @@
|
||||||
|
|
||||||
static constexpr unsigned MPD_OSX_BUFFER_TIME_MS = 100;
|
static constexpr unsigned MPD_OSX_BUFFER_TIME_MS = 100;
|
||||||
|
|
||||||
static StringBuffer<64>
|
static auto
|
||||||
StreamDescriptionToString(const AudioStreamBasicDescription desc)
|
StreamDescriptionToString(const AudioStreamBasicDescription desc) noexcept
|
||||||
{
|
{
|
||||||
// Only convert the lpcm formats (nothing else supported / used by MPD)
|
// Only convert the lpcm formats (nothing else supported / used by MPD)
|
||||||
assert(desc.mFormatID == kAudioFormatLinearPCM);
|
assert(desc.mFormatID == kAudioFormatLinearPCM);
|
||||||
|
|
||||||
return StringFormat<64>("%u channel %s %sinterleaved %u-bit %s %s (%uHz)",
|
return FmtBuffer<256>("{} channel {} {}interleaved {}-bit {} {} ({}Hz)",
|
||||||
desc.mChannelsPerFrame,
|
desc.mChannelsPerFrame,
|
||||||
(desc.mFormatFlags & kAudioFormatFlagIsNonMixable) ? "" : "mixable",
|
(desc.mFormatFlags & kAudioFormatFlagIsNonMixable) ? "" : "mixable",
|
||||||
(desc.mFormatFlags & kAudioFormatFlagIsNonInterleaved) ? "non-" : "",
|
(desc.mFormatFlags & kAudioFormatFlagIsNonInterleaved) ? "non-" : "",
|
||||||
desc.mBitsPerChannel,
|
desc.mBitsPerChannel,
|
||||||
(desc.mFormatFlags & kAudioFormatFlagIsFloat) ? "Float" : "SInt",
|
(desc.mFormatFlags & kAudioFormatFlagIsFloat) ? "Float" : "SInt",
|
||||||
(desc.mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE",
|
(desc.mFormatFlags & kAudioFormatFlagIsBigEndian) ? "BE" : "LE",
|
||||||
(UInt32)desc.mSampleRate);
|
desc.mSampleRate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,11 +9,12 @@
|
||||||
#include "util/Domain.hxx"
|
#include "util/Domain.hxx"
|
||||||
#include "util/ScopeExit.hxx"
|
#include "util/ScopeExit.hxx"
|
||||||
#include "util/StringAPI.hxx"
|
#include "util/StringAPI.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "Log.hxx"
|
#include "Log.hxx"
|
||||||
|
|
||||||
#include <shout/shout.h>
|
#include <shout/shout.h>
|
||||||
|
|
||||||
|
#include <fmt/format.h>
|
||||||
|
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
@ -99,10 +100,10 @@ static void
|
||||||
ShoutSetAudioInfo(shout_t *shout_conn, const AudioFormat &audio_format)
|
ShoutSetAudioInfo(shout_t *shout_conn, const AudioFormat &audio_format)
|
||||||
{
|
{
|
||||||
shout_set_audio_info(shout_conn, SHOUT_AI_CHANNELS,
|
shout_set_audio_info(shout_conn, SHOUT_AI_CHANNELS,
|
||||||
StringFormat<11>("%u", audio_format.channels));
|
fmt::format_int{static_cast<unsigned>(audio_format.channels)}.c_str());
|
||||||
|
|
||||||
shout_set_audio_info(shout_conn, SHOUT_AI_SAMPLERATE,
|
shout_set_audio_info(shout_conn, SHOUT_AI_SAMPLERATE,
|
||||||
StringFormat<11>("%u", audio_format.sample_rate));
|
fmt::format_int{audio_format.sample_rate}.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SHOUT_TLS
|
#ifdef SHOUT_TLS
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
#include "lib/curl/Escape.hxx"
|
#include "lib/curl/Escape.hxx"
|
||||||
#include "lib/expat/ExpatParser.hxx"
|
#include "lib/expat/ExpatParser.hxx"
|
||||||
#include "lib/fmt/RuntimeError.hxx"
|
#include "lib/fmt/RuntimeError.hxx"
|
||||||
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
#include "fs/Traits.hxx"
|
#include "fs/Traits.hxx"
|
||||||
#include "event/InjectEvent.hxx"
|
#include "event/InjectEvent.hxx"
|
||||||
#include "thread/Mutex.hxx"
|
#include "thread/Mutex.hxx"
|
||||||
|
@ -22,7 +23,6 @@
|
||||||
#include "util/ASCII.hxx"
|
#include "util/ASCII.hxx"
|
||||||
#include "util/SpanCast.hxx"
|
#include "util/SpanCast.hxx"
|
||||||
#include "util/StringCompare.hxx"
|
#include "util/StringCompare.hxx"
|
||||||
#include "util/StringFormat.hxx"
|
|
||||||
#include "util/StringSplit.hxx"
|
#include "util/StringSplit.hxx"
|
||||||
#include "util/UriExtract.hxx"
|
#include "util/UriExtract.hxx"
|
||||||
|
|
||||||
|
@ -252,7 +252,7 @@ public:
|
||||||
username/password are specified */
|
username/password are specified */
|
||||||
request.SetOption(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
request.SetOption(CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
|
||||||
|
|
||||||
request_headers.Append(StringFormat<40>("depth: %u", depth));
|
request_headers.Append(FmtBuffer<40>("depth: {}", depth));
|
||||||
request_headers.Append("content-type: text/xml");
|
request_headers.Append("content-type: text/xml");
|
||||||
|
|
||||||
request.SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
request.SetOption(CURLOPT_HTTPHEADER, request_headers.Get());
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_THREAD_NAME
|
#ifdef HAVE_THREAD_NAME
|
||||||
#include "util/StringFormat.hxx"
|
#include "lib/fmt/ToBuffer.hxx"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
|
@ -42,10 +42,10 @@ SetThreadName(const char *name) noexcept
|
||||||
|
|
||||||
template<typename... Args>
|
template<typename... Args>
|
||||||
static inline void
|
static inline void
|
||||||
FormatThreadName(const char *fmt, [[maybe_unused]] Args&&... args) noexcept
|
FmtThreadName(const char *fmt, [[maybe_unused]] Args&&... args) noexcept
|
||||||
{
|
{
|
||||||
#ifdef HAVE_THREAD_NAME
|
#ifdef HAVE_THREAD_NAME
|
||||||
SetThreadName(StringFormat<16>(fmt, args...));
|
SetThreadName(FmtBuffer<16>(fmt, args...));
|
||||||
#else
|
#else
|
||||||
(void)fmt;
|
(void)fmt;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,43 +0,0 @@
|
||||||
// SPDX-License-Identifier: BSD-2-Clause
|
|
||||||
// author: Max Kellermann <max.kellermann@gmail.com>
|
|
||||||
|
|
||||||
#ifndef STRING_FORMAT_HXX
|
|
||||||
#define STRING_FORMAT_HXX
|
|
||||||
|
|
||||||
#include "StringBuffer.hxx" // IWYU pragma: export
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
static inline void
|
|
||||||
StringFormat(char *buffer, std::size_t size,
|
|
||||||
const char *fmt, Args&&... args) noexcept
|
|
||||||
{
|
|
||||||
snprintf(buffer, size, fmt, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t CAPACITY, typename... Args>
|
|
||||||
static inline void
|
|
||||||
StringFormat(StringBuffer<CAPACITY> &buffer,
|
|
||||||
const char *fmt, Args&&... args) noexcept
|
|
||||||
{
|
|
||||||
StringFormat(buffer.data(), buffer.capacity(), fmt, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
template<std::size_t CAPACITY, typename... Args>
|
|
||||||
static inline StringBuffer<CAPACITY>
|
|
||||||
StringFormat(const char *fmt, Args&&... args) noexcept
|
|
||||||
{
|
|
||||||
StringBuffer<CAPACITY> result;
|
|
||||||
StringFormat(result, fmt, args...);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template<typename... Args>
|
|
||||||
static inline void
|
|
||||||
StringFormatUnsafe(char *buffer, const char *fmt, Args&&... args) noexcept
|
|
||||||
{
|
|
||||||
sprintf(buffer, fmt, args...);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif
|
|
Loading…
Reference in New Issue