From 4c8a5dfb0522b0ff7d6acb96fd2fbc33c22c14e6 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 23 Jun 2014 08:57:51 +0200 Subject: db/proxy: use mpd_song_get_{start,end}() only with libmpdclient >= 2.3 --- src/db/ProxyDatabasePlugin.cxx | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/db') diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index 00b5d445f..e41ecdec0 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -398,8 +398,13 @@ Convert(const struct mpd_song *song) Song *s = Song::NewDetached(mpd_song_get_uri(song)); s->mtime = mpd_song_get_last_modified(song); + +#if LIBMPDCLIENT_CHECK_VERSION(2,3,0) s->start_ms = mpd_song_get_start(song) * 1000; s->end_ms = mpd_song_get_end(song) * 1000; +#else + s->start_ms = s->end_ms = 0; +#endif TagBuilder tag; tag.SetTime(mpd_song_get_duration(song)); -- cgit v1.2.3 From 848ed1478866e4d99c10aa962a6d976a6b989536 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 23 Jun 2014 09:12:51 +0200 Subject: db/proxy: fall back to recursive walk on old libmpdclient/MPD Error message was 'too few arguments for "find"' because the "base" constraint was not supported, and no other constraints remained. --- src/db/ProxyDatabasePlugin.cxx | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'src/db') diff --git a/src/db/ProxyDatabasePlugin.cxx b/src/db/ProxyDatabasePlugin.cxx index e41ecdec0..cb1bcdc6b 100644 --- a/src/db/ProxyDatabasePlugin.cxx +++ b/src/db/ProxyDatabasePlugin.cxx @@ -566,6 +566,23 @@ SearchSongs(struct mpd_connection *connection, return result && CheckError(connection, error); } +/** + * Check whether we can use the "base" constraint. Requires + * libmpdclient 2.9 and MPD 0.18. + */ +gcc_pure +static bool +ServerSupportsSearchBase(const struct mpd_connection *connection) +{ +#if LIBMPDCLIENT_CHECK_VERSION(2,9,0) + return mpd_connection_cmp_server_version(connection, 0, 18, 0) >= 0; +#else + (void)connection; + + return false; +#endif +} + bool ProxyDatabase::Visit(const DatabaseSelection &selection, VisitDirectory visit_directory, @@ -577,7 +594,10 @@ ProxyDatabase::Visit(const DatabaseSelection &selection, if (!const_cast(this)->EnsureConnected(error)) return nullptr; - if (!visit_directory && !visit_playlist && selection.recursive) + if (!visit_directory && !visit_playlist && selection.recursive && + (ServerSupportsSearchBase(connection) + ? !selection.IsEmpty() + : selection.HasOtherThanBase())) /* this optimized code path can only be used under certain conditions */ return ::SearchSongs(connection, selection, visit_song, error); -- cgit v1.2.3