# HG changeset patch # User nenolod # Date 1176228776 25200 # Node ID d5da5d37ec8bc8d53b2a9a5076ad00eec5957c9d # Parent 8c56926de2ad642087683bbe1d5d4e35d9737325 [svn] - unlock many playlist operations that do not really need locking - information retrieval should not be atomic - add code to expose potentially unnecessary playlist locks - now playlists with remote URIs can mostly be probed in the background diff -r 8c56926de2ad -r d5da5d37ec8b ChangeLog --- a/ChangeLog Tue Apr 10 10:17:48 2007 -0700 +++ b/ChangeLog Tue Apr 10 11:12:56 2007 -0700 @@ -1,3 +1,11 @@ +2007-04-10 17:17:48 +0000 William Pitcock + revision [4360] + - probe remote sources (hardcoded to http://, https://) in the background. + + trunk/src/audacious/playlist.c | 61 ++++++++++++++++++++++++----------------- + 1 file changed, 37 insertions(+), 24 deletions(-) + + 2007-04-10 16:45:30 +0000 William Pitcock revision [4358] - do not use the signal handler at all on linuxthreads and hope for the best diff -r 8c56926de2ad -r d5da5d37ec8b src/audacious/build_stamp.c --- a/src/audacious/build_stamp.c Tue Apr 10 10:17:48 2007 -0700 +++ b/src/audacious/build_stamp.c Tue Apr 10 11:12:56 2007 -0700 @@ -1,2 +1,2 @@ #include -const gchar *svn_stamp = "20070410-4358"; +const gchar *svn_stamp = "20070410-4360"; diff -r 8c56926de2ad -r d5da5d37ec8b src/audacious/playlist.c --- a/src/audacious/playlist.c Tue Apr 10 10:17:48 2007 -0700 +++ b/src/audacious/playlist.c Tue Apr 10 11:12:56 2007 -0700 @@ -192,17 +192,18 @@ g_return_val_if_fail(entry != NULL, FALSE); - // Let's not randomly probe streams, mmkay? - if (entry->decoder == NULL && - (str_has_prefix_nocase(entry->filename, "http://") || - str_has_prefix_nocase(entry->filename, "https://"))) - return TRUE; - if (entry->tuple == NULL || entry->tuple->mtime > 0 || entry->tuple->mtime == -1) modtime = playlist_get_mtime(entry->filename); else modtime = 0; /* URI -nenolod */ + if (str_has_prefix_nocase(entry->filename, "http:") && + g_thread_self() != playlist_get_info_thread) + { + g_print("attempting to retrieve remote info not in background thread!\n"); + return FALSE; + } + if (entry->decoder == NULL) entry->decoder = input_check_file(entry->filename, FALSE); @@ -608,11 +609,11 @@ { g_return_if_fail(filename != NULL); - PLAYLIST_LOCK(playlist->mutex); + PLAYLIST_LOCK( playlist->mutex ); playlist->entries = g_list_insert(playlist->entries, playlist_entry_new(filename, title, len, dec), pos); - PLAYLIST_UNLOCK(playlist->mutex); + PLAYLIST_UNLOCK( playlist->mutex ); g_mutex_lock(mutex_scan); playlist_get_info_scan_active = TRUE; @@ -636,8 +637,7 @@ if(!playlist->tail) playlist->tail = g_list_last(playlist->entries); - PLAYLIST_LOCK(playlist->mutex); - + PLAYLIST_LOCK( playlist->mutex ); if(pos == -1) { // the common case GList *element; element = g_list_alloc(); @@ -659,13 +659,13 @@ playlist->entries = g_list_insert(playlist->entries, entry, pos); } + PLAYLIST_UNLOCK( playlist->mutex ); if (tuple != NULL) { entry->title = xmms_get_titlestring(tuple->formatter != NULL ? tuple->formatter : xmms_get_gentitle_format(), tuple); entry->length = tuple->length; entry->tuple = tuple; } - PLAYLIST_UNLOCK(playlist->mutex); if(tuple->mtime == -1) { // kick the scanner thread only if mtime = -1 (uninitialized). g_mutex_lock(mutex_scan); playlist_get_info_scan_active = TRUE; @@ -1588,10 +1588,8 @@ if (!playlist) return 0; - PLAYLIST_LOCK(playlist->mutex); if (playlist->position) len = playlist->position->length; - PLAYLIST_UNLOCK(playlist->mutex); return len; } @@ -1670,10 +1668,11 @@ } tmp = g_build_filename(path, filename, NULL); - if (playlist->loading_playlist != TRUE && cfg.playlist_detect != TRUE) + if (playlist->loading_playlist == TRUE && cfg.playlist_detect == TRUE) + dec = NULL; + else if (!str_has_prefix_nocase(tmp, "http://") && + !str_has_prefix_nocase(tmp, "https://")) dec = input_check_file(tmp, FALSE); - else - dec = NULL; __playlist_ins_with_info(playlist, tmp, pos, title, len, dec); g_free(tmp); @@ -2494,7 +2493,6 @@ cfg.get_info_on_load && playlist_get_info_scan_active) { - PLAYLIST_LOCK(playlist->mutex); for (node = playlist->entries; node; node = g_list_next(node)) { entry = node->data; @@ -2517,7 +2515,6 @@ break; } } - PLAYLIST_UNLOCK(playlist->mutex); if (!node) { g_mutex_lock(mutex_scan); @@ -2537,40 +2534,31 @@ playlist_get_info_scan_active = FALSE; g_mutex_unlock(mutex_scan); - PLAYLIST_LOCK(playlist->mutex); - - if (!playlist->entries) { - PLAYLIST_UNLOCK(playlist->mutex); - } - else { - for (node = g_list_nth(playlist->entries, playlistwin_get_toprow()); - node && playlistwin_item_visible(g_list_position(playlist->entries, node)); - node = g_list_next(node)) { - - entry = node->data; - - if(playlist->attribute & PLAYLIST_STATIC || - (entry->tuple && entry->tuple->length > -1 && entry->tuple->mtime != -1)) { - update_playlistwin = TRUE; - continue; - } - - if (!playlist_entry_get_info(entry)) { - if (g_list_index(playlist->entries, entry) == -1) - /* Entry disapeared while we - looked it up. Restart. */ - node = - g_list_nth(playlist->entries, - playlistwin_get_toprow()); - } - else if ((entry->tuple != NULL || entry->title != NULL) && entry->length != -1) { - update_playlistwin = TRUE; - if (entry == playlist->position) - update_mainwin = TRUE; + for (node = g_list_nth(playlist->entries, playlistwin_get_toprow()); + node && playlistwin_item_visible(g_list_position(playlist->entries, node)); + node = g_list_next(node)) { + + entry = node->data; + + if(playlist->attribute & PLAYLIST_STATIC || + (entry->tuple && entry->tuple->length > -1 && entry->tuple->mtime != -1)) { + update_playlistwin = TRUE; + continue; + } + + if (!playlist_entry_get_info(entry)) { + if (g_list_index(playlist->entries, entry) == -1) + /* Entry disapeared while we + looked it up. Restart. */ + node = g_list_nth(playlist->entries, + playlistwin_get_toprow()); + } + else if ((entry->tuple != NULL || entry->title != NULL) && entry->length != -1) { + update_playlistwin = TRUE; + if (entry == playlist->position) + update_mainwin = TRUE; // no need for break here since this iteration is very short. - } } - PLAYLIST_UNLOCK(playlist->mutex); } } // on_demand else if (cfg.get_info_on_demand && diff -r 8c56926de2ad -r d5da5d37ec8b src/audacious/playlist.h --- a/src/audacious/playlist.h Tue Apr 10 10:17:48 2007 -0700 +++ b/src/audacious/playlist.h Tue Apr 10 11:12:56 2007 -0700 @@ -220,8 +220,8 @@ PlaylistFormat playlist_format_get_from_name(const gchar * filename); gboolean is_playlist_name(const gchar * filename); -#define PLAYLIST_LOCK(m) g_mutex_lock(m) -#define PLAYLIST_UNLOCK(m) g_mutex_unlock(m) +#define PLAYLIST_LOCK(m) g_mutex_lock(m); g_print("playlist lock: %p [thread %p]\n", m, g_thread_self()) +#define PLAYLIST_UNLOCK(m) g_mutex_unlock(m); g_print("playlist unlock: %p [thread: %p]\n", m, g_thread_self()) G_LOCK_EXTERN(playlists);