db/proxy: require libmpdclient 2.11 or later

Remove lots of #ifdefs.
This commit is contained in:
Max Kellermann 2021-05-19 07:42:19 +02:00
parent 360381e65d
commit e108568082
3 changed files with 2 additions and 28 deletions

1
NEWS
View File

@ -4,6 +4,7 @@ ver 0.23 (not yet released)
- show the audio format in "playlistinfo" - show the audio format in "playlistinfo"
* database * database
- proxy: require MPD 0.20 or later - proxy: require MPD 0.20 or later
- proxy: require libmpdclient 2.11 or later
* output * output
- pipewire: new plugin - pipewire: new plugin
- snapcast: new plugin - snapcast: new plugin

View File

@ -178,14 +178,10 @@ static constexpr struct {
{ TAG_MUSICBRAINZ_ALBUMARTISTID, { TAG_MUSICBRAINZ_ALBUMARTISTID,
MPD_TAG_MUSICBRAINZ_ALBUMARTISTID }, MPD_TAG_MUSICBRAINZ_ALBUMARTISTID },
{ TAG_MUSICBRAINZ_TRACKID, MPD_TAG_MUSICBRAINZ_TRACKID }, { TAG_MUSICBRAINZ_TRACKID, MPD_TAG_MUSICBRAINZ_TRACKID },
#if LIBMPDCLIENT_CHECK_VERSION(2,10,0)
{ TAG_MUSICBRAINZ_RELEASETRACKID, { TAG_MUSICBRAINZ_RELEASETRACKID,
MPD_TAG_MUSICBRAINZ_RELEASETRACKID }, MPD_TAG_MUSICBRAINZ_RELEASETRACKID },
#endif
#if LIBMPDCLIENT_CHECK_VERSION(2,11,0)
{ TAG_ARTIST_SORT, MPD_TAG_ARTIST_SORT }, { TAG_ARTIST_SORT, MPD_TAG_ARTIST_SORT },
{ TAG_ALBUM_ARTIST_SORT, MPD_TAG_ALBUM_ARTIST_SORT }, { TAG_ALBUM_ARTIST_SORT, MPD_TAG_ALBUM_ARTIST_SORT },
#endif
#if LIBMPDCLIENT_CHECK_VERSION(2,12,0) #if LIBMPDCLIENT_CHECK_VERSION(2,12,0)
{ TAG_ALBUM_SORT, MPD_TAG_ALBUM_SORT }, { TAG_ALBUM_SORT, MPD_TAG_ALBUM_SORT },
#endif #endif
@ -388,7 +384,6 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection)
!SendConstraints(connection, *selection.filter)) !SendConstraints(connection, *selection.filter))
return false; return false;
#if LIBMPDCLIENT_CHECK_VERSION(2, 11, 0)
if (selection.sort != TAG_NUM_OF_ITEM_TYPES && if (selection.sort != TAG_NUM_OF_ITEM_TYPES &&
mpd_connection_cmp_server_version(connection, 0, 21, 0) >= 0) { mpd_connection_cmp_server_version(connection, 0, 21, 0) >= 0) {
#if LIBMPDCLIENT_CHECK_VERSION(2, 15, 0) #if LIBMPDCLIENT_CHECK_VERSION(2, 15, 0)
@ -410,14 +405,11 @@ SendConstraints(mpd_connection *connection, const DatabaseSelection &selection)
} }
#endif #endif
} }
#endif
#if LIBMPDCLIENT_CHECK_VERSION(2, 10, 0)
if (selection.window != RangeArg::All() && if (selection.window != RangeArg::All() &&
!mpd_search_add_window(connection, selection.window.start, !mpd_search_add_window(connection, selection.window.start,
selection.window.end)) selection.window.end))
return false; return false;
#endif
return true; return true;
} }
@ -527,12 +519,7 @@ ProxyDatabase::Connect()
host.c_str())); host.c_str()));
} }
#if LIBMPDCLIENT_CHECK_VERSION(2, 10, 0)
mpd_connection_set_keepalive(connection, keepalive); mpd_connection_set_keepalive(connection, keepalive);
#else
// suppress -Wunused-private-field
(void)keepalive;
#endif
idle_received = ~0U; idle_received = ~0U;
is_idle = false; is_idle = false;
@ -865,8 +852,6 @@ try {
throw; throw;
} }
#if LIBMPDCLIENT_CHECK_VERSION(2, 10, 0)
gcc_pure gcc_pure
static bool static bool
IsFilterSupported(const ISongFilter &f) noexcept IsFilterSupported(const ISongFilter &f) noexcept
@ -920,10 +905,6 @@ IsFilterFullySupported(const SongFilter *filter,
IsFilterFullySupported(*filter, connection); IsFilterFullySupported(*filter, connection);
} }
#endif
#if LIBMPDCLIENT_CHECK_VERSION(2, 11, 0)
gcc_pure gcc_pure
static bool static bool
IsSortSupported(TagType tag_type, IsSortSupported(TagType tag_type,
@ -946,8 +927,6 @@ IsSortSupported(TagType tag_type,
return Convert(tag_type) != MPD_TAG_COUNT; return Convert(tag_type) != MPD_TAG_COUNT;
} }
#endif
gcc_pure gcc_pure
static DatabaseSelection static DatabaseSelection
CheckSelection(DatabaseSelection selection, CheckSelection(DatabaseSelection selection,
@ -956,23 +935,17 @@ CheckSelection(DatabaseSelection selection,
selection.uri.clear(); selection.uri.clear();
selection.filter = nullptr; selection.filter = nullptr;
#if LIBMPDCLIENT_CHECK_VERSION(2, 11, 0)
if (selection.sort != TAG_NUM_OF_ITEM_TYPES && if (selection.sort != TAG_NUM_OF_ITEM_TYPES &&
IsSortSupported(selection.sort, connection)) IsSortSupported(selection.sort, connection))
/* we can forward the "sort" parameter to the other /* we can forward the "sort" parameter to the other
MPD */ MPD */
selection.sort = TAG_NUM_OF_ITEM_TYPES; selection.sort = TAG_NUM_OF_ITEM_TYPES;
#endif
#if LIBMPDCLIENT_CHECK_VERSION(2, 10, 0)
if (selection.window != RangeArg::All() && if (selection.window != RangeArg::All() &&
IsFilterFullySupported(selection.filter, connection)) IsFilterFullySupported(selection.filter, connection))
/* we can forward the "window" parameter to the other /* we can forward the "window" parameter to the other
MPD */ MPD */
selection.window = RangeArg::All(); selection.window = RangeArg::All();
#else
(void)connection;
#endif
return selection; return selection;
} }

View File

@ -23,7 +23,7 @@ if upnp_dep.found()
] ]
endif endif
libmpdclient_dep = dependency('libmpdclient', version: '>= 2.9', required: get_option('libmpdclient')) libmpdclient_dep = dependency('libmpdclient', version: '>= 2.11', required: get_option('libmpdclient'))
conf.set('ENABLE_LIBMPDCLIENT', libmpdclient_dep.found()) conf.set('ENABLE_LIBMPDCLIENT', libmpdclient_dep.found())
if libmpdclient_dep.found() if libmpdclient_dep.found()
db_plugins_sources += 'ProxyDatabasePlugin.cxx' db_plugins_sources += 'ProxyDatabasePlugin.cxx'