command/player, ...: use decimal notation

During the libfmt migration, I converted "%1.3f" to just "{:1.3}"
without the "f" suffix, but libfmt defaults to scientific notation,
which can break some MPD clients.

Closes https://github.com/MusicPlayerDaemon/MPD/issues/1291
This commit is contained in:
Max Kellermann 2021-10-18 16:52:58 +02:00
parent d5be8c74b0
commit b22d7218aa
5 changed files with 12 additions and 10 deletions

2
NEWS
View File

@ -1,4 +1,6 @@
ver 0.23.1 (not yet released)
* protocol
- use decimal notation instead of scientific notation
* output
- pipewire: attempt to change the graph sample rate
- snapcast: fix time stamp bug which caused "Failed to get chunk"

View File

@ -100,7 +100,7 @@ song_print_info(Response &r, const LightSong &song, bool base) noexcept
const auto duration = song.GetDuration();
if (!duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3}\n"),
"duration: {:1.3f}\n"),
duration.RoundS(),
duration.ToDoubleS());
}
@ -123,7 +123,7 @@ song_print_info(Response &r, const DetachedSong &song, bool base) noexcept
const auto duration = song.GetDuration();
if (!duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3}\n"),
"duration: {:1.3f}\n"),
duration.RoundS(),
duration.ToDoubleS());
}

View File

@ -60,7 +60,7 @@ tag_print(Response &r, const Tag &tag) noexcept
{
if (!tag.duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3}\n"),
"duration: {:1.3f}\n"),
tag.duration.RoundS(),
tag.duration.ToDoubleS());

View File

@ -171,7 +171,7 @@ handle_status(Client &client, [[maybe_unused]] Request args, Response &r)
if (player_status.state != PlayerState::STOP) {
r.Fmt(FMT_STRING(COMMAND_STATUS_TIME ": {}:{}\n"
"elapsed: {:1.3}\n"
"elapsed: {:1.3f}\n"
COMMAND_STATUS_BITRATE ": {}\n"),
player_status.elapsed_time.RoundS(),
player_status.total_time.IsNegative()
@ -181,7 +181,7 @@ handle_status(Client &client, [[maybe_unused]] Request args, Response &r)
player_status.bit_rate);
if (!player_status.total_time.IsNegative())
r.Fmt(FMT_STRING("duration: {:1.3}\n"),
r.Fmt(FMT_STRING("duration: {:1.3f}\n"),
player_status.total_time.ToDoubleS());
if (player_status.audio_format.IsDefined())

View File

@ -228,22 +228,22 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
FmtDebug(soxr_domain, "soxr engine '{}'", soxr_engine(soxr));
if (soxr_use_custom_recipe)
FmtDebug(soxr_domain,
"soxr precision={:0.0}, phase_response={:0.2}, "
"passband_end={:0.2}, stopband_begin={:0.2} scale={:0.2}",
"soxr precision={:0.0f}, phase_response={:0.2f}, "
"passband_end={:0.2f}, stopband_begin={:0.2f} scale={:0.2f}",
soxr_quality.precision, soxr_quality.phase_response,
soxr_quality.passband_end, soxr_quality.stopband_begin,
soxr_io_custom_recipe.scale);
else
FmtDebug(soxr_domain,
"soxr precision={:0.0}, phase_response={:0.2}, "
"passband_end={:0.2}, stopband_begin={:0.2}",
"soxr precision={:0.0f}, phase_response={:0.2f}, "
"passband_end={:0.2f}, stopband_begin={:0.2f}",
soxr_quality.precision, soxr_quality.phase_response,
soxr_quality.passband_end, soxr_quality.stopband_begin);
channels = af.channels;
ratio = float(new_sample_rate) / float(af.sample_rate);
FmtDebug(soxr_domain, "samplerate conversion ratio to {:.2}", ratio);
FmtDebug(soxr_domain, "samplerate conversion ratio to {:0.2f}", ratio);
/* libsoxr works with floating point samples */
af.format = SampleFormat::FLOAT;