summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7d37796)
raw | patch | inline | side by side (parent: 7d37796)
author | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 18:18:50 +0000 (20:18 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Sat, 3 Oct 2009 18:18:50 +0000 (20:18 +0200) |
NEWS | patch | blob | history | |
src/filelist.c | patch | blob | history | |
src/filelist.h | patch | blob | history | |
src/screen_search.c | patch | blob | history |
index bbbe18f9686ece24dcff691f97af5c79d84cd042..1019253de2797b11ecbd57d4cdc546d43fcf710d 100644 (file)
--- a/NEWS
+++ b/NEWS
* reactivate incremental playlist changes
* optimize "add+play song" with addid/playid
* handle stderr messages from lyrics plugins
+* search: eliminate duplicate results
ncmpc 0.15 - 2009-09-24
diff --git a/src/filelist.c b/src/filelist.c
index 063acbbc8cf1deb8e0f50604e2abe8ef7ca33fa7..46b9a1c8d82820d263be67aaee84a119d4b7a0fd 100644 (file)
--- a/src/filelist.c
+++ b/src/filelist.c
filelist_compare_indirect, compare_func);
}
+void
+filelist_no_duplicates(struct filelist *filelist)
+{
+ for (int i = filelist_length(filelist) - 1; i >= 0; --i) {
+ struct filelist_entry *entry = filelist_get(filelist, i);
+ const struct mpd_song *song;
+
+ if (entry->entity == NULL ||
+ mpd_entity_get_type(entry->entity) != MPD_ENTITY_TYPE_SONG)
+ continue;
+
+ song = mpd_entity_get_song(entry->entity);
+ if (filelist_find_song(filelist, song) < i) {
+ g_ptr_array_remove_index(filelist->entries, i);
+ mpd_entity_free(entry->entity);
+ g_slice_free(struct filelist_entry, entry);
+ }
+ }
+}
+
static bool
same_song(const struct mpd_song *a, const struct mpd_song *b)
{
diff --git a/src/filelist.h b/src/filelist.h
index bbae9d67209ebaae0aa6c5592fd0bde33eedbc03..a54e2aef993e5e0db8b180d3c356650041b81030 100644 (file)
--- a/src/filelist.h
+++ b/src/filelist.h
void
filelist_sort_dir_play(struct filelist *filelist, GCompareFunc compare_func);
+/**
+ * Eliminates duplicate songs from the filelist.
+ */
+void
+filelist_no_duplicates(struct filelist *filelist);
+
int
filelist_find_song(struct filelist *flist, const struct mpd_song *song);
diff --git a/src/screen_search.c b/src/screen_search.c
index 9742410d9b610277a2b0a6c97a64694f46b53a81..85f817964008ebe0b7f93050c4d3c6c31d42bee3 100644 (file)
--- a/src/screen_search.c
+++ b/src/screen_search.c
mpd_command_list_end(connection);
list = filelist_new_recv(connection);
-
- if (list != NULL)
- filelist_sort_all(list, compare_filelistentry_format);
+ filelist_no_duplicates(list);
} else if (table == SEARCH_URI) {
mpd_search_db_songs(connection, exact_match);
mpd_search_add_uri_constraint(connection, MPD_OPERATOR_DEFAULT,