Skip to content

Commit

Permalink
require libmpdclient 2.19 or newer
Browse files Browse the repository at this point in the history
2.19 is the version in Debian "oldstable" Bullseye and is more than
four years old already.  Let's drop all the LIBMPDCLIENT_CHECK_VERSION
checks!
  • Loading branch information
MaxKellermann committed Sep 23, 2024
1 parent c6afcaa commit 9c9b83e
Show file tree
Hide file tree
Showing 9 changed files with 4 additions and 69 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ ncmpc 0.51 - not yet released
* pressing Enter while in "jump mode" activates selected item
* fix crash in new text input dialog
* fix crash on song info page
* require libmpdclient 2.19 or newer

ncmpc 0.50 - (2024-09-12)
* build: require Meson 0.60
Expand Down
7 changes: 1 addition & 6 deletions src/Deleter.hxx
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright The Music Player Daemon Project

#ifndef DELETER_HXX
#define DELETER_HXX
#pragma once

#include <mpd/client.h>

Expand All @@ -15,11 +14,7 @@ struct LibmpdclientDeleter {
mpd_output_free(o);
}

#if LIBMPDCLIENT_CHECK_VERSION(2,17,0)
void operator()(struct mpd_partition *o) const noexcept {
mpd_partition_free(o);
}
#endif
};

#endif
6 changes: 0 additions & 6 deletions src/EditPlaylistPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,6 @@ EditPlaylistPage::HandleDelete(struct mpdclient &c)
return true;
}

#if LIBMPDCLIENT_CHECK_VERSION(2,19,0)

inline bool
EditPlaylistPage::HandleMoveUp(struct mpdclient &c)
{
Expand Down Expand Up @@ -253,8 +251,6 @@ EditPlaylistPage::HandleMoveDown(struct mpdclient &c)
return true;
}

#endif

bool
EditPlaylistPage::OnCommand(struct mpdclient &c, Command cmd)
{
Expand All @@ -279,13 +275,11 @@ EditPlaylistPage::OnCommand(struct mpdclient &c, Command cmd)
// TODO
return true;

#if LIBMPDCLIENT_CHECK_VERSION(2,19,0)
case Command::LIST_MOVE_UP:
return HandleMoveUp(c);

case Command::LIST_MOVE_DOWN:
return HandleMoveDown(c);
#endif

default:
break;
Expand Down
4 changes: 0 additions & 4 deletions src/Instance.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,14 @@ static constexpr TagMask global_tag_whitelist{
MPD_TAG_ALBUM,
MPD_TAG_COMPOSER,
MPD_TAG_PERFORMER,
#if LIBMPDCLIENT_CHECK_VERSION(2,17,0)
MPD_TAG_CONDUCTOR,
MPD_TAG_WORK,
#endif
MPD_TAG_NAME,
MPD_TAG_DISC,
MPD_TAG_TRACK,
MPD_TAG_DATE,
MPD_TAG_GENRE,
#if LIBMPDCLIENT_CHECK_VERSION(2,17,0)
MPD_TAG_LABEL,
#endif
MPD_TAG_COMMENT,
};

Expand Down
43 changes: 1 addition & 42 deletions src/OutputsPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@

using std::string_view_literals::operator""sv;

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)

[[gnu::pure]]
static uint64_t
PartitionNameHash(const char *name) noexcept
Expand All @@ -47,18 +45,13 @@ GetActivePartitionNameHash(const struct mpd_status *status) noexcept
return PartitionNameHash(partition);
}

#endif

class OutputsPage final : public ListPage, ListRenderer {
static constexpr unsigned RELOAD_IDLE_FLAGS =
#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
MPD_IDLE_PARTITION |
#endif
MPD_IDLE_OUTPUT;

struct Item {
std::unique_ptr<struct mpd_output, LibmpdclientDeleter> output;
#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
std::unique_ptr<struct mpd_partition, LibmpdclientDeleter> partition;

enum class Special {
Expand All @@ -68,19 +61,15 @@ class OutputsPage final : public ListPage, ListRenderer {

explicit Item(Special _special) noexcept
:special(_special) {}
#endif

explicit Item(struct mpd_output *_output) noexcept
:output(_output) {}

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
explicit Item(struct mpd_partition *_partition) noexcept
:partition(_partition) {}
#endif

[[gnu::pure]]
uint64_t GetHash() const noexcept {
#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
switch (special) {
case Special::NONE:
break;
Expand All @@ -92,7 +81,6 @@ class OutputsPage final : public ListPage, ListRenderer {
if (partition) {
return PartitionNameHash(mpd_partition_get_name(partition.get()));
}
#endif

return FNV1aHash64(mpd_output_get_name(output.get()));
}
Expand All @@ -102,9 +90,7 @@ class OutputsPage final : public ListPage, ListRenderer {

std::vector<Item> items;

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
uint64_t active_partition = 0;
#endif

public:
OutputsPage(ScreenManager &_screen, const Window window)
Expand All @@ -114,13 +100,11 @@ class OutputsPage final : public ListPage, ListRenderer {
void Clear();
void Reload(struct mpdclient &c) noexcept;

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
bool ActivatePartition(struct mpdclient &c,
const struct mpd_partition &partition) noexcept;

[[nodiscard]]
Co::InvokeTask CreateNewPartition(struct mpdclient &c) noexcept;
#endif

bool Toggle(struct mpdclient &c, unsigned output_index);

Expand All @@ -138,8 +122,6 @@ class OutputsPage final : public ListPage, ListRenderer {
bool selected) const noexcept override;
};

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)

inline bool
OutputsPage::ActivatePartition(struct mpdclient &c,
const struct mpd_partition &partition) noexcept
Expand Down Expand Up @@ -181,16 +163,13 @@ OutputsPage::CreateNewPartition(struct mpdclient &c) noexcept
}
}

#endif

inline bool
OutputsPage::Toggle(struct mpdclient &c, unsigned output_index)
{
if (output_index >= items.size())
return false;

const auto &item = items[output_index];
#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
switch (item.special) {
case Item::Special::NONE:
break;
Expand All @@ -202,7 +181,6 @@ OutputsPage::Toggle(struct mpdclient &c, unsigned output_index)

if (item.partition)
return ActivatePartition(c, *item.partition);
#endif

assert(item.output);

Expand Down Expand Up @@ -238,8 +216,6 @@ OutputsPage::Toggle(struct mpdclient &c, unsigned output_index)
return true;
}

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)

bool
OutputsPage::Delete(struct mpdclient &c, unsigned idx)
{
Expand All @@ -260,8 +236,6 @@ OutputsPage::Delete(struct mpdclient &c, unsigned idx)
return false;
}

#endif

void
OutputsPage::Clear()
{
Expand Down Expand Up @@ -303,8 +277,6 @@ fill_outputs_list(struct mpdclient *c, O &items)
c->FinishCommand();
}

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)

template<typename O>
static void
FillPartitionList(struct mpdclient &c, O &items)
Expand All @@ -328,8 +300,6 @@ FillPartitionList(struct mpdclient &c, O &items)
items.emplace_back(Item::Special::NEW_PARTITION);
}

#endif

inline void
OutputsPage::Reload(struct mpdclient &c) noexcept
{
Expand All @@ -339,9 +309,7 @@ OutputsPage::Reload(struct mpdclient &c) noexcept

fill_outputs_list(&c, items);

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
FillPartitionList(c, items);
#endif

lw.SetLength(items.size());
SchedulePaint();
Expand All @@ -362,8 +330,6 @@ OutputsPage::GetTitle(std::span<char>) const noexcept
return _("Outputs");
}

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)

static void
PaintPartition(const Window window, unsigned width, bool selected, bool active,
const struct mpd_partition &partition) noexcept
Expand All @@ -377,8 +343,6 @@ PaintPartition(const Window window, unsigned width, bool selected, bool active,
row_clear_to_eol(window, width, selected);
}

#endif

void
OutputsPage::PaintListItem(Window window, unsigned i,
[[maybe_unused]] unsigned y, unsigned width,
Expand All @@ -387,7 +351,6 @@ OutputsPage::PaintListItem(Window window, unsigned i,
assert(i < items.size());
const auto &item = items[i];

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
switch (item.special) {
case Item::Special::NONE:
break;
Expand All @@ -407,7 +370,7 @@ OutputsPage::PaintListItem(Window window, unsigned i,
*item.partition);
return;
}
#endif


assert(item.output);

Expand All @@ -428,9 +391,7 @@ OutputsPage::Paint() const noexcept
void
OutputsPage::Update(struct mpdclient &c, unsigned events) noexcept
{
#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
active_partition = GetActivePartitionNameHash(c.status);
#endif

if (events & RELOAD_IDLE_FLAGS)
Reload(c);
Expand All @@ -456,10 +417,8 @@ OutputsPage::OnCommand(struct mpdclient &c, Command cmd)
SchedulePaint();
return true;

#if LIBMPDCLIENT_CHECK_VERSION(2,18,0)
case Command::DELETE:
return Delete(c, lw.GetCursorIndex());
#endif

default:
break;
Expand Down
6 changes: 0 additions & 6 deletions src/SongPage.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -50,24 +50,18 @@ static constexpr struct tag_label tag_labels[] = {
{ MPD_TAG_ARTIST, N_("Artist") },
{ MPD_TAG_TITLE, N_("Title") },
{ MPD_TAG_ALBUM, N_("Album") },
#if LIBMPDCLIENT_CHECK_VERSION(2,17,0)
{ MPD_TAG_WORK, N_("Work") },
#endif
{ LABEL_LENGTH, N_("Length") },
{ LABEL_POSITION, N_("Position") },
{ MPD_TAG_COMPOSER, N_("Composer") },
{ MPD_TAG_PERFORMER, N_("Performer") },
#if LIBMPDCLIENT_CHECK_VERSION(2,17,0)
{ MPD_TAG_CONDUCTOR, N_("Conductor") },
#endif
{ MPD_TAG_NAME, N_("Name") },
{ MPD_TAG_DISC, N_("Disc") },
{ MPD_TAG_TRACK, N_("Track") },
{ MPD_TAG_DATE, N_("Date") },
{ MPD_TAG_GENRE, N_("Genre") },
#if LIBMPDCLIENT_CHECK_VERSION(2,17,0)
{ MPD_TAG_LABEL, N_("Label") },
#endif
{ MPD_TAG_COMMENT, N_("Comment") },
{ LABEL_PATH, N_("Path") },
{ LABEL_BITRATE, N_("Bitrate") },
Expand Down
2 changes: 1 addition & 1 deletion src/client/meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
libmpdclient_dep = dependency('libmpdclient', version: '>= 2.16')
libmpdclient_dep = dependency('libmpdclient', version: '>= 2.19')

client_sources = [
'gidle.cxx',
Expand Down
2 changes: 0 additions & 2 deletions src/client/mpdclient.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -291,9 +291,7 @@ static TagMask
ResetAndObtainTagList(struct mpd_connection *c) noexcept
{
if (!mpd_command_list_begin(c, false) ||
#if LIBMPDCLIENT_CHECK_VERSION(2,19,0)
!mpd_send_all_tag_types(c) ||
#endif
!mpd_send_list_tag_types(c) ||
!mpd_command_list_end(c))
return TagMask::None();
Expand Down
2 changes: 0 additions & 2 deletions src/strfsong.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ _strfsong(char *const s0, char *const end,
tag = MPD_TAG_COMPOSER;
else if (name == "performer"sv)
tag = MPD_TAG_PERFORMER;
#if LIBMPDCLIENT_CHECK_VERSION(2,17,0)
else if (name == "conductor"sv)
tag = MPD_TAG_CONDUCTOR;
else if (name == "work"sv)
Expand All @@ -186,7 +185,6 @@ _strfsong(char *const s0, char *const end,
tag = MPD_TAG_GROUPING;
else if (strncmp("%label%", p, n) == 0)
tag = MPD_TAG_LABEL;
#endif
else if (name == "title"sv)
tag = MPD_TAG_TITLE;
else if (name == "album"sv)
Expand Down

0 comments on commit 9c9b83e

Please sign in to comment.