changeset 3507:57d2c56f00db trunk

Automated merge with file:/home/ccr/audacious/core
author Matti Hamalainen <ccr@tnsp.org>
date Sun, 09 Sep 2007 05:41:40 +0300
parents 65502ec17b75 (current diff) 95a607e527f2 (diff)
children 6f67258c43fd
files src/audacious/playlist.c
diffstat 4 files changed, 30 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/.hgtags	Sun Sep 09 03:26:32 2007 +0300
+++ b/.hgtags	Sun Sep 09 05:41:40 2007 +0300
@@ -1,3 +1,4 @@
 55a4a6da92a5e5bc68e352e47e0c9259818a1f92 audacious-1.4.0-dr1
 40b4b64dfb42c81a6677532097c41037026b0b86 audacious-1.4.0-DR1
 91a5f34b07803a8bae1e162446e40c08ddf33273 audacious-1.4.0-dr2
+e0d1499b428724311766c06e69a288cb10a42b32 audacious-1.4.0-dr3
--- a/src/audacious/playlist.c	Sun Sep 09 03:26:32 2007 +0300
+++ b/src/audacious/playlist.c	Sun Sep 09 05:41:40 2007 +0300
@@ -45,11 +45,11 @@
 #include <sys/errno.h>
 
 #if defined(USE_REGEX_ONIGURUMA)
-  #include <onigposix.h>
+#  include <onigposix.h>
 #elif defined(USE_REGEX_PCRE)
-  #include <pcreposix.h>
+#  include <pcreposix.h>
 #else
-  #include <regex.h>
+#  include <regex.h>
 #endif
 
 #include "input.h"
@@ -102,11 +102,11 @@
  * January 7, 2006, William Pitcock <nenolod@nenolod.net>
  */
 
-G_LOCK_DEFINE(playlist_get_info_going);
 
 //static gchar *playlist_current_name = NULL;
 
 static gboolean playlist_get_info_scan_active = FALSE;
+GStaticRWLock playlist_get_info_rwlock = G_STATIC_RW_LOCK_INIT;
 static gboolean playlist_get_info_going = FALSE;
 static GThread *playlist_get_info_thread;
 
@@ -412,11 +412,8 @@
 }
 
 void
-playlist_clear(Playlist *playlist)
+playlist_clear_only(Playlist *playlist)
 {
-    if (!playlist)
-        return;
-
     PLAYLIST_LOCK( playlist->mutex );
 
     g_list_foreach(playlist->entries, (GFunc) playlist_entry_free, NULL);
@@ -427,7 +424,15 @@
     playlist->attribute = PLAYLIST_PLAIN;
 
     PLAYLIST_UNLOCK( playlist->mutex );
-
+}
+
+void
+playlist_clear(Playlist *playlist)
+{
+    if (!playlist)
+        return;
+
+    playlist_clear_only(playlist);
     playlist_generate_shuffle_list(playlist);
     playlistwin_update_list(playlist);
     playlist_recalc_total_time(playlist);
@@ -2509,13 +2514,14 @@
 {
     gboolean result;
 
-    G_LOCK(playlist_get_info_going);
+    g_static_rw_lock_reader_lock(&playlist_get_info_rwlock);
     result = playlist_get_info_going;
-    G_UNLOCK(playlist_get_info_going);
+    g_static_rw_lock_reader_unlock(&playlist_get_info_rwlock);
 
     return result;
 }
 
+
 static gboolean
 playlist_request_win_update(gpointer unused)
 {
@@ -2524,6 +2530,7 @@
     return FALSE; /* to be called only once */
 }
 
+
 static gpointer
 playlist_get_info_func(gpointer arg)
 {
@@ -2535,8 +2542,7 @@
         Playlist *playlist = playlist_get_active();
 
         // on_load
-        if (cfg.use_pl_metadata &&
-            cfg.get_info_on_load &&
+        if (cfg.use_pl_metadata && cfg.get_info_on_load &&
             playlist_get_info_scan_active) {
 
             for (node = playlist->entries; node; node = g_list_next(node)) {
@@ -2605,9 +2611,8 @@
                 }
             }
         } // on_demand
-        else if (cfg.get_info_on_demand && 
-			(!cfg.playlist_visible || cfg.playlist_shaded
-                	 || !cfg.use_pl_metadata))
+        else if (cfg.get_info_on_demand &&
+                 (!cfg.playlist_visible || cfg.playlist_shaded || !cfg.use_pl_metadata))
         {
             g_mutex_lock(mutex_scan);
             playlist_get_info_scan_active = FALSE;
@@ -2645,9 +2650,9 @@
 void
 playlist_start_get_info_thread(void)
 {
-    G_LOCK(playlist_get_info_going);
+    g_static_rw_lock_writer_lock(&playlist_get_info_rwlock);
     playlist_get_info_going = TRUE;
-    G_UNLOCK(playlist_get_info_going);
+    g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock);
 
     playlist_get_info_thread = g_thread_create(playlist_get_info_func,
                                                NULL, TRUE, NULL);
@@ -2656,9 +2661,9 @@
 void
 playlist_stop_get_info_thread(void)
 {
-    G_LOCK(playlist_get_info_going);
+    g_static_rw_lock_writer_lock(&playlist_get_info_rwlock);
     playlist_get_info_going = FALSE;
-    G_UNLOCK(playlist_get_info_going);
+    g_static_rw_lock_writer_unlock(&playlist_get_info_rwlock);
 
     g_cond_broadcast(cond_scan);
     g_thread_join(playlist_get_info_thread);
@@ -2670,6 +2675,7 @@
     g_mutex_lock(mutex_scan);
     playlist_get_info_scan_active = TRUE;
     g_mutex_unlock(mutex_scan);
+
     g_cond_signal(cond_scan);
 }
 
@@ -3244,7 +3250,6 @@
 {
     g_mutex_free( playlist->mutex );
     g_free( playlist );
-    return;
 }
 
 Playlist *
--- a/src/audacious/playlist.h	Sun Sep 09 03:26:32 2007 +0300
+++ b/src/audacious/playlist.h	Sun Sep 09 05:41:40 2007 +0300
@@ -126,6 +126,7 @@
 void playlist_select_prev(void);
 GList * playlist_get_playlists(void);
 
+void playlist_clear_only(Playlist *playlist);
 void playlist_clear(Playlist *playlist);
 void playlist_delete(Playlist *playlist, gboolean crop);
 
--- a/src/audacious/ui_main.c	Sun Sep 09 03:26:32 2007 +0300
+++ b/src/audacious/ui_main.c	Sun Sep 09 05:41:40 2007 +0300
@@ -406,6 +406,8 @@
 {
     GList *playlists = NULL, *playlists_top = NULL;
 
+    playlist_stop_get_info_thread();
+
     gtk_widget_hide(equalizerwin);
     gtk_widget_hide(playlistwin);
     gtk_widget_hide(mainwin);
@@ -417,7 +419,6 @@
 
     plugin_system_cleanup();
 
-    playlist_stop_get_info_thread();
 
     /* free and clear each playlist */
     playlists = playlist_get_playlists();