decoder/mad, ...: more libfmt logging

This commit is contained in:
Max Kellermann
2021-06-25 17:26:41 +02:00
parent f60a42e0b6
commit b29a43b4d7
42 changed files with 245 additions and 251 deletions

View File

@@ -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,

View File

@@ -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();

View File

@@ -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);

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}

View File

@@ -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;
}