Merge branch 'v0.18.x'
This commit is contained in:
@@ -30,6 +30,18 @@ DatabaseSelection::DatabaseSelection(const char *_uri, bool _recursive,
|
||||
uri = filter->GetBase();
|
||||
}
|
||||
|
||||
bool
|
||||
DatabaseSelection::IsEmpty() const
|
||||
{
|
||||
return uri.empty() && (filter == nullptr || filter->IsEmpty());
|
||||
}
|
||||
|
||||
bool
|
||||
DatabaseSelection::HasOtherThanBase() const
|
||||
{
|
||||
return filter != nullptr && filter->HasOtherThanBase();
|
||||
}
|
||||
|
||||
bool
|
||||
DatabaseSelection::Match(const LightSong &song) const
|
||||
{
|
||||
|
@@ -44,6 +44,15 @@ struct DatabaseSelection {
|
||||
DatabaseSelection(const char *_uri, bool _recursive,
|
||||
const SongFilter *_filter=nullptr);
|
||||
|
||||
gcc_pure
|
||||
bool IsEmpty() const;
|
||||
|
||||
/**
|
||||
* Does this selection contain constraints other than "base"?
|
||||
*/
|
||||
gcc_pure
|
||||
bool HasOtherThanBase() const;
|
||||
|
||||
gcc_pure
|
||||
bool Match(const LightSong &song) const;
|
||||
};
|
||||
|
@@ -695,6 +695,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,
|
||||
@@ -706,7 +723,10 @@ ProxyDatabase::Visit(const DatabaseSelection &selection,
|
||||
if (!const_cast<ProxyDatabase *>(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);
|
||||
|
Reference in New Issue
Block a user