Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from MusicPlayerDaemon:master #17

Merged
merged 5 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/PlaylistDatabase.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ void
playlist_vector_save(BufferedOutputStream &os, const PlaylistVector &pv)
{
for (const PlaylistInfo &pi : pv) {
os.Fmt(FMT_STRING(PLAYLIST_META_BEGIN "{}\n"), pi.name);
os.Fmt(PLAYLIST_META_BEGIN "{}\n", pi.name);
if (!IsNegative(pi.mtime))
os.Fmt(FMT_STRING("mtime: {}\n"),
os.Fmt("mtime: {}\n",
std::chrono::system_clock::to_time_t(pi.mtime));
os.Write("playlist_end\n");
}
Expand Down
4 changes: 2 additions & 2 deletions src/PlaylistSave.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ playlist_print_path(BufferedOutputStream &os, const Path path)
"narrow" charset (i.e. CP_ACP) is incapable of storing all
Unicode paths */
try {
os.Fmt(FMT_STRING("{}\n"), path.ToUTF8Throw());
os.Fmt("{}\n", path.ToUTF8Throw());
} catch (...) {
}
#else
os.Fmt(FMT_STRING("{}\n"), path.c_str());
os.Fmt("{}\n", path.c_str());
#endif
}

Expand Down
20 changes: 10 additions & 10 deletions src/SongPrint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ song_print_uri(Response &r, const char *uri, bool base) noexcept
uri = allocated.c_str();
}

r.Fmt(FMT_STRING(SONG_FILE "{}\n"), uri);
r.Fmt(SONG_FILE "{}\n", uri);
}

void
song_print_uri(Response &r, const LightSong &song, bool base) noexcept
{
if (!base && song.directory != nullptr)
r.Fmt(FMT_STRING(SONG_FILE "{}/{}\n"),
r.Fmt(SONG_FILE "{}/{}\n",
song.directory, song.uri);
else
song_print_uri(r, song.uri, base);
Expand All @@ -56,13 +56,13 @@ PrintRange(Response &r, SongTime start_time, SongTime end_time) noexcept
const unsigned end_ms = end_time.ToMS();

if (end_ms > 0)
r.Fmt(FMT_STRING("Range: {}.{:03}-{}.{:03}\n"),
r.Fmt("Range: {}.{:03}-{}.{:03}\n",
start_ms / 1000,
start_ms % 1000,
end_ms / 1000,
end_ms % 1000);
else if (start_ms > 0)
r.Fmt(FMT_STRING("Range: {}.{:03}-\n"),
r.Fmt("Range: {}.{:03}-\n",
start_ms / 1000,
start_ms % 1000);
}
Expand All @@ -81,14 +81,14 @@ song_print_info(Response &r, const LightSong &song, bool base) noexcept
time_print(r, "Added", song.added);

if (song.audio_format.IsDefined())
r.Fmt(FMT_STRING("Format: {}\n"), song.audio_format);
r.Fmt("Format: {}\n", song.audio_format);

tag_print_values(r, song.tag);

const auto duration = song.GetDuration();
if (!duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3f}\n"),
r.Fmt("Time: {}\n"
"duration: {:1.3f}\n",
duration.RoundS(),
duration.ToDoubleS());
}
Expand All @@ -107,14 +107,14 @@ song_print_info(Response &r, const DetachedSong &song, bool base) noexcept
time_print(r, "Added", song.GetAdded());

if (const auto &f = song.GetAudioFormat(); f.IsDefined())
r.Fmt(FMT_STRING("Format: {}\n"), f);
r.Fmt("Format: {}\n", f);

tag_print_values(r, song.GetTag());

const auto duration = song.GetDuration();
if (!duration.IsNegative())
r.Fmt(FMT_STRING("Time: {}\n"
"duration: {:1.3f}\n"),
r.Fmt("Time: {}\n"
"duration: {:1.3f}\n",
duration.RoundS(),
duration.ToDoubleS());
}
20 changes: 10 additions & 10 deletions src/SongSave.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -29,54 +29,54 @@ static void
range_save(BufferedOutputStream &os, unsigned start_ms, unsigned end_ms)
{
if (end_ms > 0)
os.Fmt(FMT_STRING("Range: {}-{}\n"), start_ms, end_ms);
os.Fmt("Range: {}-{}\n", start_ms, end_ms);
else if (start_ms > 0)
os.Fmt(FMT_STRING("Range: {}-\n"), start_ms);
os.Fmt("Range: {}-\n", start_ms);
}

void
song_save(BufferedOutputStream &os, const Song &song)
{
os.Fmt(FMT_STRING(SONG_BEGIN "{}\n"), song.filename);
os.Fmt(SONG_BEGIN "{}\n", song.filename);

if (!song.target.empty())
os.Fmt(FMT_STRING("Target: {}\n"), song.target);
os.Fmt("Target: {}\n", song.target);

range_save(os, song.start_time.ToMS(), song.end_time.ToMS());

tag_save(os, song.tag);

if (song.audio_format.IsDefined())
os.Fmt(FMT_STRING("Format: {}\n"), song.audio_format);
os.Fmt("Format: {}\n", song.audio_format);

if (song.in_playlist)
os.Write("InPlaylist: yes\n");

if (!IsNegative(song.mtime))
os.Fmt(FMT_STRING(SONG_MTIME ": {}\n"),
os.Fmt(SONG_MTIME ": {}\n",
std::chrono::system_clock::to_time_t(song.mtime));

if (!IsNegative(song.added))
os.Fmt(FMT_STRING(SONG_ADDED ": {}\n"),
os.Fmt(SONG_ADDED ": {}\n",
std::chrono::system_clock::to_time_t(song.added));
os.Write(SONG_END "\n");
}

void
song_save(BufferedOutputStream &os, const DetachedSong &song)
{
os.Fmt(FMT_STRING(SONG_BEGIN "{}\n"), song.GetURI());
os.Fmt(SONG_BEGIN "{}\n", song.GetURI());

range_save(os, song.GetStartTime().ToMS(), song.GetEndTime().ToMS());

tag_save(os, song.GetTag());

if (!IsNegative(song.GetLastModified()))
os.Fmt(FMT_STRING(SONG_MTIME ": {}\n"),
os.Fmt(SONG_MTIME ": {}\n",
std::chrono::system_clock::to_time_t(song.GetLastModified()));

if (!IsNegative(song.GetAdded()))
os.Fmt(FMT_STRING(SONG_ADDED ": {}\n"),
os.Fmt(SONG_ADDED ": {}\n",
std::chrono::system_clock::to_time_t(song.GetAdded()));
os.Write(SONG_END "\n");
}
Expand Down
14 changes: 7 additions & 7 deletions src/Stats.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,18 @@ db_stats_print(Response &r, const Database &db)
unsigned total_duration_s =
std::chrono::duration_cast<std::chrono::seconds>(stats.total_duration).count();

r.Fmt(FMT_STRING("artists: {}\n"
"albums: {}\n"
"songs: {}\n"
"db_playtime: {}\n"),
r.Fmt("artists: {}\n"
"albums: {}\n"
"songs: {}\n"
"db_playtime: {}\n",
stats.artist_count,
stats.album_count,
stats.song_count,
total_duration_s);

const auto update_stamp = db.GetUpdateStamp();
if (!IsNegative(update_stamp))
r.Fmt(FMT_STRING("db_update: {}\n"),
r.Fmt("db_update: {}\n",
std::chrono::system_clock::to_time_t(update_stamp));
}

Expand All @@ -109,8 +109,8 @@ stats_print(Response &r, const Partition &partition)
const auto uptime = std::chrono::steady_clock::now() - start_time;
#endif

r.Fmt(FMT_STRING("uptime: {}\n"
"playtime: {}\n"),
r.Fmt("uptime: {}\n"
"playtime: {}\n",
std::chrono::duration_cast<std::chrono::seconds>(uptime).count(),
lround(partition.pc.GetTotalPlayTime().count()));

Expand Down
15 changes: 8 additions & 7 deletions src/TagPrint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,28 @@ tag_print_types(Response &r) noexcept
const auto tag_mask = global_tag_mask & r.GetTagMask();
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++)
if (tag_mask.Test(TagType(i)))
r.Fmt(FMT_STRING("tagtype: {}\n"), tag_item_names[i]);
r.Fmt("tagtype: {}\n", tag_item_names[i]);
}

void
tag_print_types_available(Response &r) noexcept
{
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++)
if (global_tag_mask.Test(TagType(i)))
r.Fmt(FMT_STRING("tagtype: {}\n"), tag_item_names[i]);
r.Fmt("tagtype: {}\n", tag_item_names[i]);
}

void
tag_print(Response &r, TagType type, std::string_view value) noexcept
tag_print(Response &r, TagType type, std::string_view _value) noexcept
{
r.Fmt(FMT_STRING("{}: {}\n"), tag_item_names[type], value);
const std::string_view value{_value};
r.Fmt("{}: {}\n", tag_item_names[type], value);
}

void
tag_print(Response &r, TagType type, const char *value) noexcept
{
r.Fmt(FMT_STRING("{}: {}\n"), tag_item_names[type], value);
r.Fmt("{}: {}\n", tag_item_names[type], value);
}

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

Expand Down
4 changes: 2 additions & 2 deletions src/TagSave.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ void
tag_save(BufferedOutputStream &os, const Tag &tag)
{
if (!tag.duration.IsNegative())
os.Fmt(FMT_STRING(SONG_TIME "{}\n"), tag.duration.ToDoubleS());
os.Fmt(SONG_TIME "{}\n", tag.duration.ToDoubleS());

if (tag.has_playlist)
os.Write("Playlist: yes\n");

for (const auto &i : tag)
os.Fmt(FMT_STRING("{}: {}\n"),
os.Fmt("{}: {}\n",
tag_item_names[i.type], i.value);
}
2 changes: 1 addition & 1 deletion src/TimePrint.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ time_print(Response &r, const char *name,
return;
}

r.Fmt(FMT_STRING("{}: {}\n"), name, s.c_str());
r.Fmt("{}: {}\n", name, s.c_str());
}
2 changes: 1 addition & 1 deletion src/client/Idle.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ WriteIdleResponse(Response &r, unsigned flags) noexcept
const char *const*idle_names = idle_get_names();
for (unsigned i = 0; idle_names[i]; ++i) {
if (flags & (1 << i))
r.Fmt(FMT_STRING("changed: {}\n"), idle_names[i]);
r.Fmt("changed: {}\n", idle_names[i]);
}

r.Write("OK\n");
Expand Down
4 changes: 2 additions & 2 deletions src/client/ProtocolFeature.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,14 @@ protocol_features_print(Client &client, Response &r) noexcept
const auto protocol_feature = client.GetProtocolFeatures();
for (unsigned i = 0; i < PF_NUM_OF_ITEM_TYPES; i++)
if (protocol_feature.Test(ProtocolFeatureType(i)))
r.Fmt(FMT_STRING("feature: {}\n"), protocol_feature_names[i]);
r.Fmt("feature: {}\n", protocol_feature_names[i]);
}

void
protocol_features_print_all(Response &r) noexcept
{
for (unsigned i = 0; i < PF_NUM_OF_ITEM_TYPES; i++)
r.Fmt(FMT_STRING("feature: {}\n"), protocol_feature_names[i]);
r.Fmt("feature: {}\n", protocol_feature_names[i]);
}

ProtocolFeatureType
Expand Down
4 changes: 2 additions & 2 deletions src/client/Response.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Response::WriteBinary(std::span<const std::byte> payload) noexcept
void
Response::Error(enum ack code, const char *msg) noexcept
{
Fmt(FMT_STRING("ACK [{}@{}] {{{}}} "),
Fmt("ACK [{}@{}] {{{}}} ",
(int)code, list_index, command);

Write(msg);
Expand All @@ -57,7 +57,7 @@ void
Response::VFmtError(enum ack code,
fmt::string_view format_str, fmt::format_args args) noexcept
{
Fmt(FMT_STRING("ACK [{}@{}] {{{}}} "),
Fmt("ACK [{}@{}] {{{}}} ",
(int)code, list_index, command);

VFmt(format_str, args);
Expand Down
14 changes: 7 additions & 7 deletions src/command/AllCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ PrintAvailableCommands(Response &r, const Partition &partition,

if (cmd->permission == (permission & cmd->permission) &&
command_available(partition, cmd))
r.Fmt(FMT_STRING("command: {}\n"), cmd->cmd);
r.Fmt("command: {}\n", cmd->cmd);
}

return CommandResult::OK;
Expand All @@ -267,7 +267,7 @@ PrintUnavailableCommands(Response &r, unsigned permission) noexcept
const struct command *cmd = &i;

if (cmd->permission != (permission & cmd->permission))
r.Fmt(FMT_STRING("command: {}\n"), cmd->cmd);
r.Fmt("command: {}\n", cmd->cmd);
}

return CommandResult::OK;
Expand Down Expand Up @@ -325,7 +325,7 @@ command_check_request(const struct command *cmd, Response &r,
{
if (cmd->permission != (permission & cmd->permission)) {
r.FmtError(ACK_ERROR_PERMISSION,
FMT_STRING("you don't have permission for {:?}"),
"you don't have permission for {:?}",
cmd->cmd);
return false;
}
Expand All @@ -338,17 +338,17 @@ command_check_request(const struct command *cmd, Response &r,

if (min == max && unsigned(max) != args.size()) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("wrong number of arguments for {:?}"),
"wrong number of arguments for {:?}",
cmd->cmd);
return false;
} else if (args.size() < unsigned(min)) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("too few arguments for {:?}"),
"too few arguments for {:?}",
cmd->cmd);
return false;
} else if (max >= 0 && args.size() > unsigned(max)) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("too many arguments for {:?}"),
"too many arguments for {:?}",
cmd->cmd);
return false;
} else
Expand All @@ -362,7 +362,7 @@ command_checked_lookup(Response &r, unsigned permission,
const struct command *cmd = command_lookup(cmd_name);
if (cmd == nullptr) {
r.FmtError(ACK_ERROR_UNKNOWN,
FMT_STRING("unknown command {:?}"), cmd_name);
"unknown command {:?}", cmd_name);
return nullptr;
}

Expand Down
8 changes: 4 additions & 4 deletions src/command/DatabaseCommands.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ handle_count_internal(Client &client, Request args, Response &r, bool fold_case)
group = tag_name_parse_i(s);
if (group == TAG_NUM_OF_ITEM_TYPES) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("Unknown tag type: {}"), s);
"Unknown tag type: {}", s);
return CommandResult::ERROR;
}

Expand Down Expand Up @@ -311,7 +311,7 @@ handle_list(Client &client, Request args, Response &r)
const auto tagType = tag_name_parse_i(tag_name);
if (tagType == TAG_NUM_OF_ITEM_TYPES) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("Unknown tag type: {}"), tag_name);
"Unknown tag type: {}", tag_name);
return CommandResult::ERROR;
}

Expand All @@ -325,7 +325,7 @@ handle_list(Client &client, Request args, Response &r)
/* for compatibility with < 0.12.0 */
if (tagType != TAG_ALBUM) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("should be {:?} for 3 arguments"),
"should be {:?} for 3 arguments",
tag_item_names[TAG_ALBUM]);
return CommandResult::ERROR;
}
Expand All @@ -340,7 +340,7 @@ handle_list(Client &client, Request args, Response &r)
const auto group = tag_name_parse_i(s);
if (group == TAG_NUM_OF_ITEM_TYPES) {
r.FmtError(ACK_ERROR_ARG,
FMT_STRING("Unknown tag type: {}"), s);
"Unknown tag type: {}", s);
return CommandResult::ERROR;
}

Expand Down
Loading