[vlc-devel] commit: Sort the playlist under a static lock due to static variables ( Rémi Denis-Courmont )

git version control git at videolan.org
Tue May 26 18:31:40 CEST 2009


vlc | branch: 1.0-bugfix | Rémi Denis-Courmont <remi at remlab.net> | Tue May 26 19:28:21 2009 +0300| [afc6b18db2f7bc084e1590282e449f29a8d81203] | committer: Rémi Denis-Courmont 

Sort the playlist under a static lock due to static variables

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=afc6b18db2f7bc084e1590282e449f29a8d81203
---

 src/playlist/sort.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/src/playlist/sort.c b/src/playlist/sort.c
index 5cbf2ac..cb973fd 100644
--- a/src/playlist/sort.c
+++ b/src/playlist/sort.c
@@ -104,6 +104,7 @@ int playlist_RecursiveNodeSort( playlist_t *p_playlist, playlist_item_t *p_node,
 
 static int sort_mode = 0;
 static int sort_type = 0;
+static vlc_mutex_t sort_lock = VLC_STATIC_MUTEX;
 
 static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
                                    playlist_item_t **pp_items, int i_mode,
@@ -111,6 +112,8 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
 {
     int i_position;
     playlist_item_t *p_temp;
+
+    vlc_mutex_lock( &sort_lock );
     sort_mode = i_mode;
     sort_type = i_type;
 
@@ -134,6 +137,7 @@ static int playlist_ItemArraySort( playlist_t *p_playlist, int i_items,
         return VLC_SUCCESS;
     }
     qsort(pp_items,i_items,sizeof(pp_items[0]),playlist_cmp);
+    vlc_mutex_unlock( &sort_lock );
     return VLC_SUCCESS;
 }
 




More information about the vlc-devel mailing list