comparison audacious/playlist.c @ 840:ffc5ab7b4b2c trunk

[svn] added a 'remove duplicates' option to the playlist removal menu
author giacomo
date Sat, 18 Mar 2006 07:34:43 -0800
parents bf9bc9a514ba
children bcff46a2558d
comparison
equal deleted inserted replaced
839:247d1f58fbfe 840:ffc5ab7b4b2c
2204 playlist_generate_shuffle_list(); 2204 playlist_generate_shuffle_list();
2205 playlistwin_update_list(); 2205 playlistwin_update_list();
2206 playlist_recalc_total_time(); 2206 playlist_recalc_total_time();
2207 } 2207 }
2208 2208
2209 void
2210 playlist_remove_duplicates(void)
2211 {
2212 GList *node, *next_node;
2213 GList *node_cmp, *next_node_cmp;
2214
2215 PLAYLIST_LOCK();
2216
2217 for (node = playlist; node; node = next_node) {
2218 PlaylistEntry *entry = PLAYLIST_ENTRY(node->data);
2219 next_node = g_list_next(node);
2220
2221 if (!entry || !entry->filename) {
2222 g_message(G_STRLOC ": Playlist entry is invalid!");
2223 continue;
2224 }
2225
2226 for (node_cmp = next_node; node_cmp; node_cmp = next_node_cmp) {
2227 PlaylistEntry *entry_cmp = PLAYLIST_ENTRY(node_cmp->data);
2228 next_node_cmp = g_list_next(node_cmp);
2229
2230 if (!entry_cmp || !entry_cmp->filename) {
2231 g_message(G_STRLOC ": Playlist entry is invalid!");
2232 continue;
2233 }
2234
2235 /* compare path+filenames, this can/should be optimized */
2236 if ( !strcmp( entry->filename , entry_cmp->filename ) ) {
2237
2238 if (entry_cmp == playlist_position) {
2239 /* Don't remove the currently playing song */
2240 if (bmp_playback_get_playing())
2241 continue;
2242
2243 if (next_node_cmp)
2244 playlist_position = PLAYLIST_ENTRY(next_node_cmp->data);
2245 else
2246 playlist_position = NULL;
2247 }
2248
2249 /* check if this was the next item of the external
2250 loop; if true, replace it with the next of the next*/
2251 if ( node_cmp == next_node )
2252 next_node = g_list_next(next_node);
2253
2254 playlist_entry_free(entry_cmp);
2255 playlist = g_list_delete_link(playlist, node_cmp);
2256 }
2257 }
2258 }
2259
2260 PLAYLIST_UNLOCK();
2261
2262 playlistwin_update_list();
2263 playlist_recalc_total_time();
2264 }
2265
2209 static gulong pl_total_time = 0, pl_selection_time = 0; 2266 static gulong pl_total_time = 0, pl_selection_time = 0;
2210 static gboolean pl_total_more = FALSE, pl_selection_more = FALSE; 2267 static gboolean pl_total_more = FALSE, pl_selection_more = FALSE;
2211 2268
2212 void 2269 void
2213 playlist_get_total_time(gulong * total_time, 2270 playlist_get_total_time(gulong * total_time,