Commit b29a43b4 authored by Max Kellermann's avatar Max Kellermann

decoder/mad, ...: more libfmt logging

parent f60a42e0
......@@ -234,7 +234,7 @@ cycle_log_files() noexcept
if (out_path.IsNull())
return 0;
FormatDebug(log_domain, "Cycling log files");
LogDebug(log_domain, "Cycling log files");
close_log_files();
fd = open_log_file();
......
......@@ -44,7 +44,7 @@ Client::OnTimeout() noexcept
assert(!idle_waiting);
assert(!background_command);
FormatDebug(client_domain, "[%u] timeout", num);
FmtDebug(client_domain, "[{}] timeout", num);
}
Close();
......
......@@ -113,8 +113,7 @@ UpdateService::Task() noexcept
SetThreadName("update");
if (!next.path_utf8.empty())
FormatDebug(update_domain, "starting: %s",
next.path_utf8.c_str());
FmtDebug(update_domain, "starting: {}", next.path_utf8);
else
LogDebug(update_domain, "starting");
......@@ -133,8 +132,7 @@ UpdateService::Task() noexcept
}
if (!next.path_utf8.empty())
FormatDebug(update_domain, "finished: %s",
next.path_utf8.c_str());
FmtDebug(update_domain, "finished: {}", next.path_utf8);
else
LogDebug(update_domain, "finished");
......@@ -155,8 +153,8 @@ UpdateService::StartThread(UpdateQueueItem &&i)
update_thread.Start();
FormatDebug(update_domain,
"spawned thread for update job id %i", next.id);
FmtDebug(update_domain,
"spawned thread for update job id {}", next.id);
}
unsigned
......
......@@ -21,6 +21,7 @@
#include "DecoderAPI.hxx"
#include "Domain.hxx"
#include "Control.hxx"
#include "lib/fmt/AudioFormatFormatter.hxx"
#include "song/DetachedSong.hxx"
#include "pcm/Convert.hxx"
#include "MusicPipe.hxx"
......@@ -268,9 +269,9 @@ DecoderBridge::Ready(const AudioFormat audio_format,
assert(decoder_tag == nullptr);
assert(!seeking);
FormatDebug(decoder_domain, "audio_format=%s, seekable=%s",
ToString(audio_format).c_str(),
seekable ? "true" : "false");
FmtDebug(decoder_domain, "audio_format={}, seekable={}",
audio_format,
seekable);
{
const std::lock_guard<Mutex> protect(dc.mutex);
......@@ -278,8 +279,8 @@ DecoderBridge::Ready(const AudioFormat audio_format,
}
if (dc.in_audio_format != dc.out_audio_format) {
FormatDebug(decoder_domain, "converting to %s",
ToString(dc.out_audio_format).c_str());
FmtDebug(decoder_domain, "converting to %s",
dc.out_audio_format);
try {
convert = std::make_unique<PcmConvert>(dc.in_audio_format,
......
......@@ -61,7 +61,7 @@ DecoderUriDecode(const DecoderPlugin &plugin,
assert(uri != nullptr);
assert(bridge.dc.state == DecoderState::START);
FormatDebug(decoder_thread_domain, "probing plugin %s", plugin.name);
FmtDebug(decoder_thread_domain, "probing plugin {}", plugin.name);
if (bridge.dc.command == DecoderCommand::STOP)
throw StopDecoder();
......@@ -99,7 +99,7 @@ decoder_stream_decode(const DecoderPlugin &plugin,
assert(input_stream.IsReady());
assert(bridge.dc.state == DecoderState::START);
FormatDebug(decoder_thread_domain, "probing plugin %s", plugin.name);
FmtDebug(decoder_thread_domain, "probing plugin {}", plugin.name);
if (bridge.dc.command == DecoderCommand::STOP)
throw StopDecoder();
......@@ -142,7 +142,7 @@ decoder_file_decode(const DecoderPlugin &plugin,
assert(path.IsAbsolute());
assert(bridge.dc.state == DecoderState::START);
FormatDebug(decoder_thread_domain, "probing plugin %s", plugin.name);
FmtDebug(decoder_thread_domain, "probing plugin {}", plugin.name);
if (bridge.dc.command == DecoderCommand::STOP)
throw StopDecoder();
......
......@@ -38,8 +38,8 @@ static unsigned sample_rate;
static bool
adplug_init(const ConfigBlock &block)
{
FormatDebug(adplug_domain, "adplug %s",
CAdPlug::get_version().c_str());
FmtDebug(adplug_domain, "adplug {}",
CAdPlug::get_version());
sample_rate = block.GetPositiveValue("sample_rate", 48000U);
CheckSampleRate(sample_rate);
......
......@@ -168,8 +168,8 @@ audiofile_setup_sample_format(AFfilehandle af_fp) noexcept
afGetSampleFormat(af_fp, AF_DEFAULT_TRACK, &fs, &bits);
if (!audio_valid_sample_format(audiofile_bits_to_sample_format(bits))) {
FormatDebug(audiofile_domain,
"input file has %d bit samples, converting to 16",
FmtDebug(audiofile_domain,
"input file has {} bit samples, converting to 16",
bits);
bits = 16;
}
......
......@@ -73,9 +73,9 @@ flac_scan_file(Path path_fs, TagHandler &handler)
{
FlacMetadataChain chain;
if (!chain.Read(NarrowPath(path_fs))) {
FormatDebug(flac_domain,
"Failed to read FLAC tags: %s",
chain.GetStatusString());
FmtDebug(flac_domain,
"Failed to read FLAC tags: {}",
chain.GetStatusString());
return false;
}
......@@ -88,9 +88,9 @@ flac_scan_stream(InputStream &is, TagHandler &handler)
{
FlacMetadataChain chain;
if (!chain.Read(is)) {
FormatDebug(flac_domain,
"Failed to read FLAC tags: %s",
chain.GetStatusString());
FmtDebug(flac_domain,
"Failed to read FLAC tags: {}",
chain.GetStatusString());
return false;
}
......@@ -317,9 +317,9 @@ oggflac_scan_file(Path path_fs, TagHandler &handler)
{
FlacMetadataChain chain;
if (!chain.ReadOgg(NarrowPath(path_fs))) {
FormatDebug(flac_domain,
"Failed to read OggFLAC tags: %s",
chain.GetStatusString());
FmtDebug(flac_domain,
"Failed to read OggFLAC tags: {}",
chain.GetStatusString());
return false;
}
......@@ -332,9 +332,9 @@ oggflac_scan_stream(InputStream &is, TagHandler &handler)
{
FlacMetadataChain chain;
if (!chain.ReadOgg(is)) {
FormatDebug(flac_domain,
"Failed to read OggFLAC tags: %s",
chain.GetStatusString());
FmtDebug(flac_domain,
"Failed to read OggFLAC tags: {}",
chain.GetStatusString());
return false;
}
......
......@@ -160,8 +160,8 @@ gme_file_decode(DecoderClient &client, Path path_fs)
AtScopeExit(emu) { gme_delete(emu); };
FormatDebug(gme_domain, "emulator type '%s'\n",
gme_type_system(gme_type(emu)));
FmtDebug(gme_domain, "emulator type '{}'",
gme_type_system(gme_type(emu)));
#if GME_VERSION >= 0x000600
if (gme_accuracy >= 0)
......
......@@ -382,9 +382,9 @@ RecoverFrameError(const struct mad_stream &stream) noexcept
if (MAD_RECOVERABLE(stream.error))
return MadDecoderAction::SKIP;
FormatWarning(mad_domain,
"unrecoverable frame level error: %s",
mad_stream_errorstr(&stream));
FmtWarning(mad_domain,
"unrecoverable frame level error: {}",
mad_stream_errorstr(&stream));
return MadDecoderAction::BREAK;
}
......@@ -571,8 +571,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) noexcept
&lame->version.major, &lame->version.minor) != 2)
return false;
FormatDebug(mad_domain, "detected LAME version %i.%i (\"%s\")",
lame->version.major, lame->version.minor, lame->encoder);
FmtDebug(mad_domain, "detected LAME version {}.{} (\"{}\")",
lame->version.major, lame->version.minor, lame->encoder);
/* The reference volume was changed from the 83dB used in the
* ReplayGain spec to 89dB in lame 3.95.1. Bump the gain for older
......@@ -589,7 +589,7 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) noexcept
mad_bit_skip(ptr, 16);
lame->peak = MAD_F(mad_bit_read(ptr, 32) << 5); /* peak */
FormatDebug(mad_domain, "LAME peak found: %f", double(lame->peak));
FmtDebug(mad_domain, "LAME peak found: {}", lame->peak);
lame->track_gain = 0;
unsigned name = mad_bit_read(ptr, 3); /* gain name */
......@@ -598,8 +598,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) noexcept
int gain = mad_bit_read(ptr, 9); /* gain*10 */
if (gain && name == 1 && orig != 0) {
lame->track_gain = ((sign ? -gain : gain) / 10.0f) + adj;
FormatDebug(mad_domain, "LAME track gain found: %f",
double(lame->track_gain));
FmtDebug(mad_domain, "LAME track gain found: {}",
lame->track_gain);
}
/* tmz reports that this isn't currently written by any version of lame
......@@ -614,8 +614,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) noexcept
gain = mad_bit_read(ptr, 9); /* gain*10 */
if (gain && name == 2 && orig != 0) {
lame->album_gain = ((sign ? -gain : gain) / 10.0) + adj;
FormatDebug(mad_domain, "LAME album gain found: %f",
double(lame->track_gain));
FmtDebug(mad_domain, "LAME album gain found: {}",
lame->track_gain);
}
#else
mad_bit_skip(ptr, 16);
......@@ -626,8 +626,8 @@ parse_lame(struct lame *lame, struct mad_bitptr *ptr, int *bitlen) noexcept
lame->encoder_delay = mad_bit_read(ptr, 12);
lame->encoder_padding = mad_bit_read(ptr, 12);
FormatDebug(mad_domain, "encoder delay is %i, encoder padding is %i",
lame->encoder_delay, lame->encoder_padding);
FmtDebug(mad_domain, "encoder delay is {}, encoder padding is {}",
lame->encoder_delay, lame->encoder_padding);
mad_bit_skip(ptr, 80);
......@@ -763,9 +763,9 @@ MadDecoder::DecodeFirstFrame(Tag *tag) noexcept
return false;
if (max_frames > 8 * 1024 * 1024) {
FormatWarning(mad_domain,
"mp3 file header indicates too many frames: %zu",
max_frames);
FmtWarning(mad_domain,
"mp3 file header indicates too many frames: {}",
max_frames);
return false;
}
......
......@@ -101,9 +101,9 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
char *endptr;
unsigned value = ParseUnsigned(s, &endptr);
if (endptr == s || *endptr != 0) {
FormatWarning(pcm_decoder_domain,
"Failed to parse sample rate: %s",
s);
FmtWarning(pcm_decoder_domain,
"Failed to parse sample rate: {}",
s);
return;
}
......@@ -123,9 +123,9 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
char *endptr;
unsigned value = ParseUnsigned(s, &endptr);
if (endptr == s || *endptr != 0) {
FormatWarning(pcm_decoder_domain,
"Failed to parse sample rate: %s",
s);
FmtWarning(pcm_decoder_domain,
"Failed to parse sample rate: {}",
s);
return;
}
......@@ -146,9 +146,9 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
const char *s = i->second.c_str();
audio_format = ParseAudioFormat(s, false);
if (!audio_format.IsFullyDefined()) {
FormatWarning(pcm_decoder_domain,
"Invalid audio format specification: %s",
mime);
FmtWarning(pcm_decoder_domain,
"Invalid audio format specification: {}",
mime);
return;
}
}
......@@ -157,9 +157,9 @@ pcm_stream_decode(DecoderClient &client, InputStream &is)
}
if (audio_format.sample_rate == 0) {
FormatWarning(pcm_decoder_domain,
"Missing 'rate' parameter: %s",
mime);
FmtWarning(pcm_decoder_domain,
"Missing 'rate' parameter: {}",
mime);
return;
}
......
......@@ -254,8 +254,7 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
#else
const char *error = tune.getInfo().statusString;
#endif
FormatWarning(sidplay_domain, "failed to load file: %s",
error);
FmtWarning(sidplay_domain, "failed to load file: {}", error);
return;
}
......@@ -283,8 +282,8 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
bool error = player.load(&tune) < 0;
#endif
if (error) {
FormatWarning(sidplay_domain,
"sidplay2.load() failed: %s", player.error());
FmtWarning(sidplay_domain,
"sidplay2.load() failed: {}", player.error());
return;
}
......@@ -293,25 +292,25 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
#ifdef HAVE_SIDPLAYFP
ReSIDfpBuilder builder("ReSID");
if (!builder.getStatus()) {
FormatWarning(sidplay_domain,
"failed to initialize ReSIDfpBuilder: %s",
builder.error());
FmtWarning(sidplay_domain,
"failed to initialize ReSIDfpBuilder: {}",
builder.error());
return;
}
builder.create(player.info().maxsids());
if (!builder.getStatus()) {
FormatWarning(sidplay_domain,
"ReSIDfpBuilder.create() failed: %s",
builder.error());
FmtWarning(sidplay_domain,
"ReSIDfpBuilder.create() failed: {}",
builder.error());
return;
}
#else
ReSIDBuilder builder("ReSID");
builder.create(player.info().maxsids);
if (!builder) {
FormatWarning(sidplay_domain, "ReSIDBuilder.create() failed: %s",
builder.error());
FmtWarning(sidplay_domain, "ReSIDBuilder.create() failed: {}",
builder.error());
return;
}
#endif
......@@ -319,15 +318,15 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
builder.filter(sidplay_global->filter_setting);
#ifdef HAVE_SIDPLAYFP
if (!builder.getStatus()) {
FormatWarning(sidplay_domain,
"ReSIDfpBuilder.filter() failed: %s",
builder.error());
FmtWarning(sidplay_domain,
"ReSIDfpBuilder.filter() failed: {}",
builder.error());
return;
}
#else
if (!builder) {
FormatWarning(sidplay_domain, "ReSIDBuilder.filter() failed: %s",
builder.error());
FmtWarning(sidplay_domain, "ReSIDBuilder.filter() failed: {}",
builder.error());
return;
}
#endif
......@@ -388,8 +387,8 @@ sidplay_file_decode(DecoderClient &client, Path path_fs)
error = player.config(config) < 0;
#endif
if (error) {
FormatWarning(sidplay_domain,
"sidplay2.config() failed: %s", player.error());
FmtWarning(sidplay_domain,
"sidplay2.config() failed: {}", player.error());
return;
}
......
......@@ -203,8 +203,8 @@ sndfile_stream_decode(DecoderClient &client, InputStream &is)
SNDFILE *const sf = sf_open_virtual(const_cast<SF_VIRTUAL_IO *>(&vio),
SFM_READ, &info, &sis);
if (sf == nullptr) {
FormatWarning(sndfile_domain, "sf_open_virtual() failed: %s",
sf_strerror(nullptr));
FmtWarning(sndfile_domain, "sf_open_virtual() failed: {}",
sf_strerror(nullptr));
return;
}
......@@ -281,8 +281,8 @@ sndfile_scan_stream(InputStream &is, TagHandler &handler)
AtScopeExit(sf) { sf_close(sf); };
if (!audio_valid_sample_rate(info.samplerate)) {
FormatWarning(sndfile_domain,
"Invalid sample rate in %s", is.GetURI());
FmtWarning(sndfile_domain,
"Invalid sample rate in {}", is.GetURI());
return false;
}
......
......@@ -124,8 +124,8 @@ PreparedTwolameEncoder::PreparedTwolameEncoder(const ConfigBlock &block)
static PreparedEncoder *
twolame_encoder_init(const ConfigBlock &block)
{
FormatDebug(twolame_encoder_domain,
"libtwolame version %s", get_twolame_version());
FmtDebug(twolame_encoder_domain,
"libtwolame version {}", get_twolame_version());
return new PreparedTwolameEncoder(block);
}
......
......@@ -53,6 +53,7 @@ encoder_plugins = static_library(
liblame_dep,
libtwolame_dep,
libshine_dep,
log_dep,
],
)
......
......@@ -94,9 +94,9 @@ public:
/* no change */
return;
FormatDebug(replay_gain_domain,
"replay gain mode has changed %s->%s\n",
ToString(mode), ToString(_mode));
FmtDebug(replay_gain_domain,
"replay gain mode has changed {}->{}",
ToString(mode), ToString(_mode));
mode = _mode;
Update();
......@@ -155,8 +155,7 @@ ReplayGainFilter::Update()
if (mode != ReplayGainMode::OFF) {
const auto &tuple = info.Get(mode);
float scale = tuple.CalculateScale(config);
FormatDebug(replay_gain_domain,
"scale=%f\n", (double)scale);
FmtDebug(replay_gain_domain, "scale={}\n", scale);
volume = pcm_float_to_volume(scale);
}
......
......@@ -26,6 +26,7 @@ filter_plugins = static_library(
include_directories: inc,
dependencies: [
filter_plugins_deps,
log_dep,
],
)
......
......@@ -270,15 +270,15 @@ AlsaInputStream::Recover(int err)
{
switch(err) {
case -EPIPE:
FormatDebug(alsa_input_domain,
"Overrun on ALSA capture device \"%s\"",
device.c_str());
FmtDebug(alsa_input_domain,
"Overrun on ALSA capture device \"{}\"",
device);
break;
case -ESTRPIPE:
FormatDebug(alsa_input_domain,
"ALSA capture device \"%s\" was suspended",
device.c_str());
FmtDebug(alsa_input_domain,
"ALSA capture device \"{}\" was suspended",
device);
break;
}
......@@ -361,9 +361,9 @@ AlsaInputStream::ConfigureCapture(AudioFormat audio_format)
unsigned buffer_time_min, buffer_time_max;
snd_pcm_hw_params_get_buffer_time_min(hw_params, &buffer_time_min, nullptr);
snd_pcm_hw_params_get_buffer_time_max(hw_params, &buffer_time_max, nullptr);
FormatDebug(alsa_input_domain, "buffer: size=%u..%u time=%u..%u",
(unsigned)buffer_size_min, (unsigned)buffer_size_max,
buffer_time_min, buffer_time_max);
FmtDebug(alsa_input_domain, "buffer: size={}..{} time={}..{}",
buffer_size_min, buffer_size_max,
buffer_time_min, buffer_time_max);
snd_pcm_uframes_t period_size_min, period_size_max;
snd_pcm_hw_params_get_period_size_min(hw_params, &period_size_min, nullptr);
......@@ -371,9 +371,9 @@ AlsaInputStream::ConfigureCapture(AudioFormat audio_format)
unsigned period_time_min, period_time_max;
snd_pcm_hw_params_get_period_time_min(hw_params, &period_time_min, nullptr);
snd_pcm_hw_params_get_period_time_max(hw_params, &period_time_max, nullptr);
FormatDebug(alsa_input_domain, "period: size=%u..%u time=%u..%u",
(unsigned)period_size_min, (unsigned)period_size_max,
period_time_min, period_time_max);
FmtDebug(alsa_input_domain, "period: size={}..{} time={}..{}",
period_size_min, period_size_max,
period_time_min, period_time_max);
/* choose the maximum possible buffer_size ... */
snd_pcm_hw_params_set_buffer_size(capture_handle, hw_params,
......@@ -409,8 +409,8 @@ AlsaInputStream::ConfigureCapture(AudioFormat audio_format)
throw FormatRuntimeError("snd_pcm_hw_params_get_period_size() failed: %s",
snd_strerror(-err));
FormatDebug(alsa_input_domain, "buffer_size=%u period_size=%u",
(unsigned)alsa_buffer_size, (unsigned)alsa_period_size);
FmtDebug(alsa_input_domain, "buffer_size={} period_size={}",
alsa_buffer_size, alsa_period_size);
snd_pcm_sw_params_t *sw_params;
snd_pcm_sw_params_alloca(&sw_params);
......
......@@ -281,10 +281,7 @@ CurlInputStream::OnHeaders(unsigned status,
if (i != headers.end()) {
size_t icy_metaint = ParseUint64(i->second.c_str());
#ifndef _WIN32
/* Windows doesn't know "%z" */
FormatDebug(curl_domain, "icy-metaint=%zu", icy_metaint);
#endif
FmtDebug(curl_domain, "icy-metaint={}", icy_metaint);
if (icy_metaint > 0) {
icy->Start(icy_metaint);
......@@ -358,10 +355,10 @@ input_curl_init(EventLoop &event_loop, const ConfigBlock &block)
const auto version_info = curl_version_info(CURLVERSION_FIRST);
if (version_info != nullptr) {
FormatDebug(curl_domain, "version %s", version_info->version);
FmtDebug(curl_domain, "version {}", version_info->version);
if (version_info->features & CURL_VERSION_SSL)
FormatDebug(curl_domain, "with %s",
version_info->ssl_version);
FmtDebug(curl_domain, "with {}",
version_info->ssl_version);
}
http_200_aliases = curl_slist_append(http_200_aliases, "ICY 200 OK");
......
......@@ -183,7 +183,8 @@ InitTidalInput(EventLoop &event_loop, const ConfigBlock &block)
if (password == nullptr)
throw PluginUnconfigured("No Tidal password configured");
FormatWarning(tidal_domain, "The Tidal input plugin is deprecated because Tidal has changed the protocol and doesn't share documentation");
LogWarning(tidal_domain,
"The Tidal input plugin is deprecated because Tidal has changed the protocol and doesn't share documentation");
tidal_audioquality = block.GetBlockValue("audioquality", "HIGH");
......
......@@ -81,7 +81,7 @@ TidalSessionManager::AddLoginHandler(TidalSessionHandler &h) noexcept
void
TidalSessionManager::OnTidalLoginSuccess(std::string _session) noexcept
{
FormatDebug(tidal_domain, "Login successful, session=%s", _session.c_str());
FmtDebug(tidal_domain, "Login successful, session={}", _session);
{
const std::lock_guard<Mutex> protect(mutex);
......
......@@ -235,9 +235,9 @@ SetupHw(snd_pcm_t *pcm,
unsigned buffer_time_min, buffer_time_max;
snd_pcm_hw_params_get_buffer_time_min(hwparams, &buffer_time_min, nullptr);
snd_pcm_hw_params_get_buffer_time_max(hwparams, &buffer_time_max, nullptr);
FormatDebug(alsa_output_domain, "buffer: size=%u..%u time=%u..%u",
(unsigned)buffer_size_min, (unsigned)buffer_size_max,
buffer_time_min, buffer_time_max);
FmtDebug(alsa_output_domain, "buffer: size={}..{} time={}..{}",
buffer_size_min, buffer_size_max,
buffer_time_min, buffer_time_max);
snd_pcm_uframes_t period_size_min, period_size_max;
snd_pcm_hw_params_get_period_size_min(hwparams, &period_size_min, nullptr);
......@@ -245,9 +245,9 @@ SetupHw(snd_pcm_t *pcm,
unsigned period_time_min, period_time_max;
snd_pcm_hw_params_get_period_time_min(hwparams, &period_time_min, nullptr);
snd_pcm_hw_params_get_period_time_max(hwparams, &period_time_max, nullptr);
FormatDebug(alsa_output_domain, "period: size=%u..%u time=%u..%u",
(unsigned)period_size_min, (unsigned)period_size_max,
period_time_min, period_time_max);
FmtDebug(alsa_output_domain, "period: size={}..{} time={}..{}",
period_size_min, period_size_max,
period_time_min, period_time_max);
if (buffer_time > 0) {
err = snd_pcm_hw_params_set_buffer_time_near(pcm, hwparams,
......@@ -265,9 +265,9 @@ SetupHw(snd_pcm_t *pcm,
if (period_time_ro == 0 && buffer_time >= 10000) {
period_time_ro = period_time = buffer_time / 4;
FormatDebug(alsa_output_domain,
"default period_time = buffer_time/4 = %u/4 = %u",
buffer_time, period_time);
FmtDebug(alsa_output_domain,
"default period_time = buffer_time/4 = {}/4 = {}",
buffer_time, period_time);
}
if (period_time_ro > 0) {
......
......@@ -20,6 +20,7 @@ alsa = static_library(
include_directories: inc,
dependencies: [
libasound_dep,
log_dep,
],
)
......
......@@ -153,9 +153,9 @@ OssMixer::GetVolume()
right = (level & 0xff00) >> 8;
if (left != right) {
FormatWarning(oss_mixer_domain,
"volume for left and right is not the same, \"%i\" and "
"\"%i\"\n", left, right);
FmtWarning(oss_mixer_domain,
"volume for left and right is not the same, \"{}\" and "
"\"{}\"\n", left, right);
}
return left;
......
......@@ -70,8 +70,8 @@ audio_output_state_read(const char *line, MultipleOutputs &outputs)
name = endptr + 1;
auto *ao = outputs.FindByName(name);
if (ao == nullptr) {
FormatDebug(output_domain,
"Ignoring device state for '%s'", name);
FmtDebug(output_domain,
"Ignoring device state for '{}'", name);
return true;
}
......
......@@ -123,8 +123,8 @@ AoOutput::AoOutput(const ConfigBlock &block)
if (ai == nullptr)
throw std::runtime_error("problems getting driver info");
FormatDebug(ao_output_domain, "using ao driver \"%s\" for \"%s\"\n",
ai->short_name, block.GetBlockValue("name", nullptr));
FmtDebug(ao_output_domain, "using ao driver \"{}\" for \"{}\"\n",
ai->short_name, block.GetBlockValue("name", nullptr));
value = block.GetBlockValue("options", nullptr);
if (value != nullptr) {
......
......@@ -90,8 +90,8 @@ FifoOutput::FifoOutput(const ConfigBlock &block)
inline void
FifoOutput::Delete()
{
FormatDebug(fifo_output_domain,
"Removing FIFO \"%s\"", path_utf8.c_str());
FmtDebug(fifo_output_domain,
"Removing FIFO \"{}\"", path_utf8);
try {
RemoveFile(path);
......
......@@ -96,7 +96,7 @@ initialize_application()
// TODO: actually Run() it and handle B_QUIT_REQUESTED
// TODO: use some locking?
if (be_app == NULL) {
FormatDebug(haiku_output_domain, "creating be_app\n");
LogDebug(haiku_output_domain, "creating be_app");
new BApplication("application/x-vnd.MusicPD");
}
}
......@@ -107,7 +107,7 @@ finalize_application()
// TODO: use some locking?
delete be_app;
be_app = NULL;
FormatDebug(haiku_output_domain, "deleting be_app\n");
LogDebug(haiku_output_domain, "deleting be_app");
}
static bool
......@@ -163,19 +163,18 @@ HaikuOutput::FillBuffer(void* _buffer, size_t size,
release_sem(new_buffer);
acquire_sem(buffer_done);
bigtime_t w = system_time() - start;
if (w > 5000LL) {
FormatDebug(haiku_output_domain,
"haiku:fill_buffer waited %Ldus\n", w);
FmtDebug(haiku_output_domain,
"haiku:fill_buffer waited {}us", w);
}
if (buffer_filled < buffer_size) {
memset(buffer + buffer_filled, 0,
buffer_size - buffer_filled);
FormatDebug(haiku_output_domain,
"haiku:fill_buffer filled %d size %d clearing remainder\n",
(int)buffer_filled, (int)buffer_size);
FmtDebug(haiku_output_domain,
"haiku:fill_buffer filled {} size {} clearing remainder",
buffer_filled, buffer_size);
}
}
......@@ -222,12 +221,12 @@ HaikuOutput::Open(AudioFormat &audio_format)
format.channel_count, format.format,
format.frame_rate, B_UNKNOWN_BUS) * 2;
FormatDebug(haiku_output_domain,
"using haiku driver ad: bs: %d ws: %d "
"channels %d rate %f fmt %08lx bs %d\n",
(int)buffer_size, (int)write_size,
(int)format.channel_count, format.frame_rate,
format.format, (int)format.buffer_size);
FmtDebug(haiku_output_domain,
"using haiku driver ad: bs: {} ws: {} "
"channels {} rate {} fmt {:08x} bs {}",
buffer_size, write_size,
format.channel_count, format.frame_rate,
format.format, format.buffer_size);
sound_player = new BSoundPlayer(&format, "MPD Output",
HaikuOutput::_FillBuffer, NULL, this);
......@@ -247,8 +246,7 @@ HaikuOutput::Open(AudioFormat &audio_format)
buffer_delay *= 1000 / format.frame_rate;
// half of the total buffer play time
buffer_delay /= 2;
FormatDebug(haiku_output_domain,
"buffer delay: %d ms\n", buffer_delay);
FmtDebug(haiku_output_domain, "buffer delay: {} ms", buffer_delay);
new_buffer = create_sem(0, "New buffer request");
buffer_done = create_sem(0, "Buffer done");
......@@ -303,8 +301,8 @@ HaikuOutput::Delay() const noexcept
{
unsigned delay = buffer_filled ? 0 : buffer_delay;
//FormatDebug(haiku_output_domain,
// "delay=%d\n", delay / 2);
//FmtDebug(haiku_output_domain,
// "delay={}", delay / 2);
// XXX: doesn't work
//return (delay / 2) ? 1 : 0;
(void)delay;
......@@ -393,8 +391,9 @@ HaikuOutput::SendTag(const Tag &tag)
case TAG_MUSICBRAINZ_ALBUMARTISTID:
case TAG_MUSICBRAINZ_TRACKID:
default:
FormatDebug(haiku_output_domain,
"tag item: type %d value '%s'\n", item.type, item.value);
FmtDebug(haiku_output_domain,
"tag item: type {} value '{}'\n",
item.type, item.value);
break;
}
}
......
......@@ -242,9 +242,9 @@ JackOutput::JackOutput(const ConfigBlock &block)
/* compatibility with MPD < 0.16 */
value = block.GetBlockValue("ports", nullptr);
if (value != nullptr)
FormatWarning(jack_output_domain,
"deprecated option 'ports' in line %d",
block.line);
FmtWarning(jack_output_domain,
"deprecated option 'ports' in line {}",
block.line);
}
if (value != nullptr) {
......@@ -258,11 +258,11 @@ JackOutput::JackOutput(const ConfigBlock &block)
if (num_destination_ports > 0 &&
num_destination_ports != num_source_ports)
FormatWarning(jack_output_domain,
"number of source ports (%u) mismatches the "
"number of destination ports (%u) in line %d",
num_source_ports, num_destination_ports,
block.line);
FmtWarning(jack_output_domain,
"number of source ports ({}) mismatches the "
"number of destination ports ({}) in line {}",
num_source_ports, num_destination_ports,
block.line);
ringbuffer_size = block.GetPositiveValue("ringbuffer_size", 32768U);
}
......@@ -543,10 +543,9 @@ JackOutput::Start()
for (num_dports = 0; num_dports < MAX_PORTS &&
jports[num_dports] != nullptr;
++num_dports) {
FormatDebug(jack_output_domain,
"destination_port[%u] = '%s'\n",
num_dports,
jports[num_dports]);
FmtDebug(jack_output_domain,
"destination_port[{}] = '{}'\n",
num_dports, jports[num_dports]);
dports[num_dports] = jports[num_dports];
}
} else {
......
......@@ -258,9 +258,10 @@ osx_output_parse_channel_map(const char *device_name,
channel_map_str = endptr;
want_number = false;
FormatDebug(osx_output_domain,
"%s: channel_map[%u] = %d",
device_name, inserted_channels, channel_map[inserted_channels]);
FmtDebug(osx_output_domain,
"{}: channel_map[{}] = {}",
device_name, inserted_channels,
channel_map[inserted_channels]);
++inserted_channels;
continue;
}
......@@ -421,10 +422,10 @@ osx_output_set_device_format(AudioDeviceID dev_id,
// print all (linear pcm) formats and their rating
if (score > 0.0f)
FormatDebug(osx_output_domain,
"Format: %s rated %f",
StreamDescriptionToString(format_desc).c_str(),
(double)score);
FmtDebug(osx_output_domain,
"Format: {} rated {}",
StreamDescriptionToString(format_desc).c_str(),
score);
if (score > output_score) {
output_score = score;
......@@ -498,14 +499,14 @@ osx_output_hog_device(AudioDeviceID dev_id, bool hog) noexcept
if (hog) {
if (hog_pid != -1) {
FormatDebug(osx_output_domain,
"Device is already hogged.");
LogDebug(osx_output_domain,
"Device is already hogged");
return;
}
} else {
if (hog_pid != getpid()) {
FormatDebug(osx_output_domain,
"Device is not owned by this process.");
FmtDebug(osx_output_domain,
"Device is not owned by this process");
return;
}
}
......@@ -520,9 +521,8 @@ osx_output_hog_device(AudioDeviceID dev_id, bool hog) noexcept
size,
&hog_pid);
if (err != noErr) {
FormatDebug(osx_output_domain,
"Cannot hog the device: %d",
err);
FmtDebug(osx_output_domain,
"Cannot hog the device: {}", err);
} else {
LogDebug(osx_output_domain,
hog_pid == -1
......@@ -585,16 +585,16 @@ osx_output_set_device(OSXOutput *oo)
const auto id = FindAudioDeviceByName(oo->device_name);
FormatDebug(osx_output_domain,
"found matching device: ID=%u, name=%s",
(unsigned)id, oo->device_name);
FmtDebug(osx_output_domain,
"found matching device: ID={}, name={}",
id, oo->device_name);
AudioUnitSetCurrentDevice(oo->au, id);
oo->dev_id = id;
FormatDebug(osx_output_domain,
"set OS X audio output device ID=%u, name=%s",
(unsigned)id, oo->device_name);
FmtDebug(osx_output_domain,
"set OS X audio output device ID={}, name={}",
id, oo->device_name);
if (oo->channel_map)
osx_output_set_channel_map(oo);
......
......@@ -200,16 +200,16 @@ oss_open_default()
/* never reached */
break;
case OSS_STAT_DOESN_T_EXIST:
FormatWarning(oss_output_domain,
"%s not found", dev);
FmtWarning(oss_output_domain,
"{} not found", dev);
break;
case OSS_STAT_NOT_CHAR_DEV:
FormatWarning(oss_output_domain,
"%s is not a character device", dev);
FmtWarning(oss_output_domain,
"{} is not a character device", dev);
break;
case OSS_STAT_NO_PERMS:
FormatWarning(oss_output_domain,
"%s: permission denied", dev);
FmtWarning(oss_output_domain,
"{}: permission denied", dev);
break;
case OSS_STAT_OTHER:
FormatErrno(oss_output_domain, err[i],
......
......@@ -19,6 +19,7 @@
#include "RecorderOutputPlugin.hxx"
#include "../OutputAPI.hxx"
#include "lib/fmt/PathFormatter.hxx"
#include "tag/Format.hxx"
#include "encoder/ToOutputStream.hxx"
#include "encoder/EncoderInterface.hxx"
......@@ -276,8 +277,7 @@ RecorderOutput::ReopenFormat(AllocatedPath &&new_path)
path = std::move(new_path);
file = new_file;
FormatDebug(recorder_domain, "Recording to \"%s\"",
path.ToUTF8().c_str());
FmtDebug(recorder_domain, "Recording to \"{}\"", path);
}
void
......
......@@ -282,9 +282,9 @@ ShoutOutput::Close() noexcept
if (shout_get_connected(shout_conn) != SHOUTERR_UNCONNECTED &&
shout_close(shout_conn) != SHOUTERR_SUCCESS) {
FormatWarning(shout_output_domain,
"problem closing connection to shout server: %s",
shout_get_error(shout_conn));
FmtWarning(shout_output_domain,
"problem closing connection to shout server: {}",
shout_get_error(shout_conn));
}
}
......
......@@ -171,9 +171,9 @@ HttpdClient::SendResponse() noexcept
ssize_t nbytes = GetSocket().Write(response, strlen(response));
if (gcc_unlikely(nbytes < 0)) {
const SocketErrorMessage msg;
FormatWarning(httpd_output_domain,
"failed to write to client: %s",
(const char *)msg);
FmtWarning(httpd_output_domain,
"failed to write to client: {}",
(const char *)msg);
LockClose();
return false;
}
......@@ -284,9 +284,9 @@ HttpdClient::TryWrite() noexcept
if (!IsSocketErrorClosed(e)) {
SocketErrorMessage msg(e);
FormatWarning(httpd_output_domain,
"failed to write to client: %s",
(const char *)msg);
FmtWarning(httpd_output_domain,
"failed to write to client: {}",
(const char *)msg);
}
Close();
......@@ -311,9 +311,9 @@ HttpdClient::TryWrite() noexcept
if (!IsSocketErrorClosed(e)) {
SocketErrorMessage msg(e);
FormatWarning(httpd_output_domain,
"failed to write to client: %s",
(const char *)msg);
FmtWarning(httpd_output_domain,
"failed to write to client: {}",
(const char *)msg);
}
Close();
......@@ -334,9 +334,9 @@ HttpdClient::TryWrite() noexcept
if (!IsSocketErrorClosed(e)) {
SocketErrorMessage msg(e);
FormatWarning(httpd_output_domain,
"failed to write to client: %s",
(const char *)msg);
FmtWarning(httpd_output_domain,
"failed to write to client: {}",
(const char *)msg);
}
Close();
......@@ -370,8 +370,8 @@ HttpdClient::PushPage(PagePtr page) noexcept
return;
if (queue_size > 256 * 1024) {
FormatDebug(httpd_output_domain,
"client is too slow, flushing its queue");
LogDebug(httpd_output_domain,
"client is too slow, flushing its queue");
ClearQueue();
}
......
......@@ -26,6 +26,7 @@
#include "PropertyStore.hxx"
#include "output/OutputAPI.hxx"
#include "lib/icu/Win32.hxx"
#include "lib/fmt/AudioFormatFormatter.hxx"
#include "mixer/MixerList.hxx"
#include "output/Error.hxx"
#include "pcm/Export.hxx"
......@@ -824,13 +825,12 @@ WasapiOutput::TryFormatExclusive(const AudioFormat &audio_format)
HRESULT result = client->IsFormatSupported(
AUDCLNT_SHAREMODE_EXCLUSIVE,
reinterpret_cast<WAVEFORMATEX *>(&test_format), nullptr);
const auto format_string = ToString(audio_format);
const auto result_string = std::string(HRESULTToString(result));
FormatDebug(wasapi_output_domain, "Trying %s %lu %u-%u (exclusive) -> %s",
format_string.c_str(), test_format.Format.nSamplesPerSec,
test_format.Format.wBitsPerSample,
test_format.Samples.wValidBitsPerSample,
result_string.c_str());
FmtDebug(wasapi_output_domain, "Trying {} {} {}-{} (exclusive) -> {}",
audio_format, test_format.Format.nSamplesPerSec,
test_format.Format.wBitsPerSample,
test_format.Samples.wValidBitsPerSample,
result_string);
if (SUCCEEDED(result)) {
device_format = test_format;
return true;
......@@ -922,13 +922,12 @@ WasapiOutput::FindSharedFormatSupported(AudioFormat &audio_format)
reinterpret_cast<WAVEFORMATEX *>(&device_format),
closest_format.AddressCast<WAVEFORMATEX>());
{
const auto format_string = ToString(audio_format);
const auto result_string = std::string(HRESULTToString(result));
FormatDebug(wasapi_output_domain, "Trying %s %lu %u-%u (shared) -> %s",
format_string.c_str(), device_format.Format.nSamplesPerSec,
device_format.Format.wBitsPerSample,
device_format.Samples.wValidBitsPerSample,
result_string.c_str());
FmtDebug(wasapi_output_domain, "Trying {} {} {}-{} (shared) -> {}",
audio_format, device_format.Format.nSamplesPerSec,
device_format.Format.wBitsPerSample,
device_format.Samples.wValidBitsPerSample,
result_string);
}
if (FAILED(result) && result != AUDCLNT_E_UNSUPPORTED_FORMAT) {
......@@ -950,15 +949,14 @@ WasapiOutput::FindSharedFormatSupported(AudioFormat &audio_format)
reinterpret_cast<WAVEFORMATEX *>(&device_format),
closest_format.AddressCast<WAVEFORMATEX>());
{
const auto format_string = ToString(audio_format);
const auto result_string = std::string(HRESULTToString(result));
FormatDebug(wasapi_output_domain,
"Trying %s %lu %u-%u (shared) -> %s",
format_string.c_str(),
device_format.Format.nSamplesPerSec,
device_format.Format.wBitsPerSample,
device_format.Samples.wValidBitsPerSample,
result_string.c_str());
FmtDebug(wasapi_output_domain,
"Trying {} {} {}-{} (shared) -> {}",
audio_format,
device_format.Format.nSamplesPerSec,
device_format.Format.wBitsPerSample,
device_format.Samples.wValidBitsPerSample,
result_string);
}
if (FAILED(result)) {
throw MakeHResultError(result, "Format is not supported");
......
......@@ -71,9 +71,9 @@ pcm_resample_lsr_global_init(const ConfigBlock &block)
throw FormatRuntimeError("unknown samplerate converter '%s'",
converter);
FormatDebug(libsamplerate_domain,
"libsamplerate converter '%s'",
src_get_name(lsr_converter));
FmtDebug(libsamplerate_domain,
"libsamplerate converter '{}'",
src_get_name(lsr_converter));
}
AudioFormat
......@@ -98,9 +98,9 @@ LibsampleratePcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
memset(&data, 0, sizeof(data));
data.src_ratio = double(new_sample_rate) / double(af.sample_rate);
FormatDebug(libsamplerate_domain,
"setting samplerate conversion ratio to %.2lf",
data.src_ratio);
FmtDebug(libsamplerate_domain,
"setting samplerate conversion ratio to {:.2}",
data.src_ratio);
src_set_ratio(state, data.src_ratio);
AudioFormat result = af;
......
......@@ -200,9 +200,8 @@ pcm_resample_soxr_global_init(const ConfigBlock &block)
soxr_quality = soxr_quality_spec(recipe, 0);
}
FormatDebug(soxr_domain,
"soxr converter '%s'",
soxr_quality_name(recipe));
FmtDebug(soxr_domain, "soxr converter '{}'",
soxr_quality_name(recipe));
const unsigned n_threads = block.GetBlockValue("threads", 1);
soxr_runtime = soxr_runtime_spec(n_threads);
......@@ -226,7 +225,7 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
throw FormatRuntimeError("soxr initialization has failed: %s",
e);
FormatDebug(soxr_domain, "soxr engine '%s'", soxr_engine(soxr));
FmtDebug(soxr_domain, "soxr engine '{}'", soxr_engine(soxr));
if (soxr_use_custom_recipe)
FormatDebug(soxr_domain,
"soxr precision=%0.0f, phase_response=%0.2f, "
......
......@@ -69,6 +69,7 @@ pcm = static_library(
pcm_basic_dep,
libsamplerate_dep,
soxr_dep,
log_dep,
],
)
......
......@@ -128,9 +128,9 @@ CrossFadeSettings::Calculate(SignedSongTime total_time,
mixramp_delay <= mixramp_overlap) {
chunks = lround((mixramp_overlap - mixramp_delay)
/ chunk_duration);
FormatDebug(cross_fade_domain,
"will overlap %d chunks, %fs", chunks,
(mixramp_overlap - mixramp_delay).count());
FmtDebug(cross_fade_domain,
"will overlap {} chunks, {}s", chunks,
(mixramp_overlap - mixramp_delay).count());
}
}
......
......@@ -71,8 +71,8 @@ playlist::QueueSongOrder(PlayerControl &pc, unsigned order) noexcept
const DetachedSong &song = queue.GetOrder(order);
FormatDebug(playlist_domain, "queue song %i:\"%s\"",
queued, song.GetURI());
FmtDebug(playlist_domain, "queue song {}:\"{}\"",
queued, song.GetURI());
pc.LockEnqueueSong(std::make_unique<DetachedSong>(song));
}
......@@ -178,7 +178,7 @@ playlist::PlayOrder(PlayerControl &pc, unsigned order)
const DetachedSong &song = queue.GetOrder(order);
FormatDebug(playlist_domain, "play %u:\"%s\"", order, song.GetURI());
FmtDebug(playlist_domain, "play {}:\"{}\"", order, song.GetURI());
current = order;
......
......@@ -36,7 +36,7 @@ playlist::Stop(PlayerControl &pc) noexcept
assert(current >= 0);
FormatDebug(playlist_domain, "stop");
LogDebug(playlist_domain, "stop");
pc.LockStop();
queued = -1;
playing = false;
......
......@@ -79,9 +79,9 @@ BonjourHelper::Callback([[maybe_unused]] DNSServiceRef sdRef,
helper.Cancel();
} else {
FormatDebug(bonjour_domain,
"Registered zeroconf service with name '%s'",
name);
FmtDebug(bonjour_domain,
"Registered zeroconf service with name '{}'",
name);
}
}
......
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