banshee r4496 - in trunk/banshee: . src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod src/Dap/Banshee.Dap/Banshee.Dap



Author: gburt
Date: Mon Sep  8 23:38:21 2008
New Revision: 4496
URL: http://svn.gnome.org/viewvc/banshee?rev=4496&view=rev

Log:
2008-09-08  Gabriel Burt  <gabriel burt gmail com>

	* src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs: Fix threading
	issues with syncing playlists on eject/dispose.

	* src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs: Fix typo in comment



Modified:
   trunk/banshee/ChangeLog
   trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
   trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs

Modified: trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap.Ipod/Banshee.Dap.Ipod/IpodSource.cs	Mon Sep  8 23:38:21 2008
@@ -112,6 +112,7 @@
         protected override void Eject ()
         {
             base.Eject ();
+            CancelSyncThread ();
             if (ipod_device.CanUnmount) {
                 ipod_device.Unmount ();
             }
@@ -438,10 +439,9 @@
 
         public override void SyncPlaylists ()
         {
-            if (sync_thread_wait == null) {
-                PerformSyncThreadCycle ();
-            } else {
-                QueueSync ();
+            if (Monitor.TryEnter (sync_mutex)) {
+                PerformSync ();
+                Monitor.Exit (sync_mutex);
             }
         }
 
@@ -458,12 +458,17 @@
         
         private void CancelSyncThread ()
         {
+            Thread thread = sync_thread;
             lock (sync_mutex) {
                 if (sync_thread != null && sync_thread_wait != null) {
                     sync_thread_dispose = true;
                     sync_thread_wait.Set ();
                 }
             }
+
+            if (thread != null) {
+                thread.Join ();
+            }
         }
         
         private bool PerformSync ()

Modified: trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs
==============================================================================
--- trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs	(original)
+++ trunk/banshee/src/Dap/Banshee.Dap/Banshee.Dap/DapSource.cs	Mon Sep  8 23:38:21 2008
@@ -299,7 +299,7 @@
 
         private void AttemptToAddTrackToDevice (DatabaseTrackInfo track, SafeUri fromUri)
         {
-            // Ensure there's enouch space
+            // Ensure there's enough space
             if (BytesAvailable - Banshee.IO.File.GetSize (fromUri) >= 0) {
                 // Ensure it's not already on the device
                 if (ServiceManager.DbConnection.Query<int> (track_on_dap_query, DbId, track.MetadataHash) == 0) {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]