Patrick Williams | e760df8 | 2023-05-26 11:10:49 -0500 | [diff] [blame] | 1 | Upstream-Status: Backport [https://github.com/MusicPlayerDaemon/MPD/commit/181b96dd2d71bc8f2668776719d344466f258b5d] |
| 2 | |
| 3 | Signed-off-by: Wang Mingyu <wangmy@fujitsu.com> |
| 4 | |
| 5 | From 181b96dd2d71bc8f2668776719d344466f258b5d Mon Sep 17 00:00:00 2001 |
| 6 | From: Max Kellermann <max.kellermann@gmail.com> |
| 7 | Date: Mon, 15 May 2023 20:52:21 +0200 |
| 8 | Subject: [PATCH] command/player, SongPrint: use AudioFormatFormatter() |
| 9 | |
| 10 | libfmt version 10 apparently doesn't know how to format a |
| 11 | `StringBuffer`, failing the MPD build. Since we have a formatter |
| 12 | specialization for `AudioFormat`, let's use that - it's better and |
| 13 | easier to use. |
| 14 | |
| 15 | Closes https://github.com/MusicPlayerDaemon/MPD/issues/1807 |
| 16 | --- |
| 17 | src/SongPrint.cxx | 5 +++-- |
| 18 | src/command/PlayerCommands.cxx | 3 ++- |
| 19 | 2 files changed, 5 insertions(+), 3 deletions(-) |
| 20 | |
| 21 | diff --git a/src/SongPrint.cxx b/src/SongPrint.cxx |
| 22 | index 98d544cc38..835669d276 100644 |
| 23 | --- a/src/SongPrint.cxx |
| 24 | +++ b/src/SongPrint.cxx |
| 25 | @@ -8,6 +8,7 @@ |
| 26 | #include "TagPrint.hxx" |
| 27 | #include "client/Response.hxx" |
| 28 | #include "fs/Traits.hxx" |
| 29 | +#include "lib/fmt/AudioFormatFormatter.hxx" |
| 30 | #include "time/ChronoUtil.hxx" |
| 31 | #include "util/StringBuffer.hxx" |
| 32 | #include "util/UriUtil.hxx" |
| 33 | @@ -77,7 +78,7 @@ song_print_info(Response &r, const LightSong &song, bool base) noexcept |
| 34 | time_print(r, "Last-Modified", song.mtime); |
| 35 | |
| 36 | if (song.audio_format.IsDefined()) |
| 37 | - r.Fmt(FMT_STRING("Format: {}\n"), ToString(song.audio_format)); |
| 38 | + r.Fmt(FMT_STRING("Format: {}\n"), song.audio_format); |
| 39 | |
| 40 | tag_print_values(r, song.tag); |
| 41 | |
| 42 | @@ -100,7 +101,7 @@ song_print_info(Response &r, const DetachedSong &song, bool base) noexcept |
| 43 | time_print(r, "Last-Modified", song.GetLastModified()); |
| 44 | |
| 45 | if (const auto &f = song.GetAudioFormat(); f.IsDefined()) |
| 46 | - r.Fmt(FMT_STRING("Format: {}\n"), ToString(f)); |
| 47 | + r.Fmt(FMT_STRING("Format: {}\n"), f); |
| 48 | |
| 49 | tag_print_values(r, song.GetTag()); |
| 50 | |
| 51 | diff --git a/src/command/PlayerCommands.cxx b/src/command/PlayerCommands.cxx |
| 52 | index 5108b9d3c4..0b5a917020 100644 |
| 53 | --- a/src/command/PlayerCommands.cxx |
| 54 | +++ b/src/command/PlayerCommands.cxx |
| 55 | @@ -13,6 +13,7 @@ |
| 56 | #include "Partition.hxx" |
| 57 | #include "Instance.hxx" |
| 58 | #include "IdleFlags.hxx" |
| 59 | +#include "lib/fmt/AudioFormatFormatter.hxx" |
| 60 | #include "util/StringBuffer.hxx" |
| 61 | #include "util/ScopeExit.hxx" |
| 62 | #include "util/Exception.hxx" |
| 63 | @@ -170,7 +171,7 @@ handle_status(Client &client, [[maybe_unused]] Request args, Response &r) |
| 64 | |
| 65 | if (player_status.audio_format.IsDefined()) |
| 66 | r.Fmt(FMT_STRING(COMMAND_STATUS_AUDIO ": {}\n"), |
| 67 | - ToString(player_status.audio_format)); |
| 68 | + player_status.audio_format); |
| 69 | } |
| 70 | |
| 71 | #ifdef ENABLE_DATABASE |