Commit b22d7218 authored by Max Kellermann's avatar Max Kellermann

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
parent d5be8c74
ver 0.23.1 (not yet released) ver 0.23.1 (not yet released)
* protocol
- use decimal notation instead of scientific notation
* output * output
- pipewire: attempt to change the graph sample rate - pipewire: attempt to change the graph sample rate
- snapcast: fix time stamp bug which caused "Failed to get chunk" - snapcast: fix time stamp bug which caused "Failed to get chunk"
......
...@@ -100,7 +100,7 @@ song_print_info(Response &r, const LightSong &song, bool base) noexcept ...@@ -100,7 +100,7 @@ song_print_info(Response &r, const LightSong &song, bool base) noexcept
const auto duration = song.GetDuration(); const auto duration = song.GetDuration();
if (!duration.IsNegative()) if (!duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n" r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3}\n"), "duration: {:1.3f}\n"),
duration.RoundS(), duration.RoundS(),
duration.ToDoubleS()); duration.ToDoubleS());
} }
...@@ -123,7 +123,7 @@ song_print_info(Response &r, const DetachedSong &song, bool base) noexcept ...@@ -123,7 +123,7 @@ song_print_info(Response &r, const DetachedSong &song, bool base) noexcept
const auto duration = song.GetDuration(); const auto duration = song.GetDuration();
if (!duration.IsNegative()) if (!duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n" r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3}\n"), "duration: {:1.3f}\n"),
duration.RoundS(), duration.RoundS(),
duration.ToDoubleS()); duration.ToDoubleS());
} }
...@@ -60,7 +60,7 @@ tag_print(Response &r, const Tag &tag) noexcept ...@@ -60,7 +60,7 @@ tag_print(Response &r, const Tag &tag) noexcept
{ {
if (!tag.duration.IsNegative()) if (!tag.duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n" r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3}\n"), "duration: {:1.3f}\n"),
tag.duration.RoundS(), tag.duration.RoundS(),
tag.duration.ToDoubleS()); tag.duration.ToDoubleS());
......
...@@ -171,7 +171,7 @@ handle_status(Client &client, [[maybe_unused]] Request args, Response &r) ...@@ -171,7 +171,7 @@ handle_status(Client &client, [[maybe_unused]] Request args, Response &r)
if (player_status.state != PlayerState::STOP) { if (player_status.state != PlayerState::STOP) {
r.Fmt(FMT_STRING(COMMAND_STATUS_TIME ": {}:{}\n" r.Fmt(FMT_STRING(COMMAND_STATUS_TIME ": {}:{}\n"
"elapsed: {:1.3}\n" "elapsed: {:1.3f}\n"
COMMAND_STATUS_BITRATE ": {}\n"), COMMAND_STATUS_BITRATE ": {}\n"),
player_status.elapsed_time.RoundS(), player_status.elapsed_time.RoundS(),
player_status.total_time.IsNegative() player_status.total_time.IsNegative()
...@@ -181,7 +181,7 @@ handle_status(Client &client, [[maybe_unused]] Request args, Response &r) ...@@ -181,7 +181,7 @@ handle_status(Client &client, [[maybe_unused]] Request args, Response &r)
player_status.bit_rate); player_status.bit_rate);
if (!player_status.total_time.IsNegative()) 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()); player_status.total_time.ToDoubleS());
if (player_status.audio_format.IsDefined()) if (player_status.audio_format.IsDefined())
......
...@@ -228,22 +228,22 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate) ...@@ -228,22 +228,22 @@ SoxrPcmResampler::Open(AudioFormat &af, unsigned new_sample_rate)
FmtDebug(soxr_domain, "soxr engine '{}'", soxr_engine(soxr)); FmtDebug(soxr_domain, "soxr engine '{}'", soxr_engine(soxr));
if (soxr_use_custom_recipe) if (soxr_use_custom_recipe)
FmtDebug(soxr_domain, FmtDebug(soxr_domain,
"soxr precision={:0.0}, phase_response={:0.2}, " "soxr precision={:0.0f}, phase_response={:0.2f}, "
"passband_end={:0.2}, stopband_begin={:0.2} scale={:0.2}", "passband_end={:0.2f}, stopband_begin={:0.2f} scale={:0.2f}",
soxr_quality.precision, soxr_quality.phase_response, soxr_quality.precision, soxr_quality.phase_response,
soxr_quality.passband_end, soxr_quality.stopband_begin, soxr_quality.passband_end, soxr_quality.stopband_begin,
soxr_io_custom_recipe.scale); soxr_io_custom_recipe.scale);
else else
FmtDebug(soxr_domain, FmtDebug(soxr_domain,
"soxr precision={:0.0}, phase_response={:0.2}, " "soxr precision={:0.0f}, phase_response={:0.2f}, "
"passband_end={:0.2}, stopband_begin={:0.2}", "passband_end={:0.2f}, stopband_begin={:0.2f}",
soxr_quality.precision, soxr_quality.phase_response, soxr_quality.precision, soxr_quality.phase_response,
soxr_quality.passband_end, soxr_quality.stopband_begin); soxr_quality.passband_end, soxr_quality.stopband_begin);
channels = af.channels; channels = af.channels;
ratio = float(new_sample_rate) / float(af.sample_rate); 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 */ /* libsoxr works with floating point samples */
af.format = SampleFormat::FLOAT; af.format = SampleFormat::FLOAT;
......
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