Index: plparse/totem-disc.c
===================================================================
RCS file: /cvs/gnome/totem/src/plparse/totem-disc.c,v
retrieving revision 1.25
diff -u -r1.25 totem-disc.c
--- plparse/totem-disc.c	24 Sep 2005 19:15:08 -0000	1.25
+++ plparse/totem-disc.c	23 Oct 2005 20:07:18 -0000
@@ -214,21 +214,15 @@
 
       mnt = gnome_vfs_drive_get_activation_uri (drive);
       if (mnt && strncmp (mnt, "file://", 7) == 0) {
-	g_free (pdev2);
         *mountpoint = g_strdup (mnt + 7);
-        g_free (mnt);
-        gnome_vfs_drive_ref (drive);
-	found = TRUE;
-        break;
-      } else if (mnt && strncmp (mnt, "cdda://", 7) == 0) {
-	g_free (pdev2);
+      } else /*if (mnt && strncmp (mnt, "cdda://", 7) == 0)*/ {
 	*mountpoint = NULL;
-	g_free (mnt);
-	gnome_vfs_drive_ref (drive);
-	found = TRUE;
-	break;
       }
+      found = TRUE;
+      g_free (pdev2);
       g_free (mnt);
+      gnome_vfs_drive_ref (drive);
+      break;
     }
     g_free (pdev2);
   }
@@ -373,10 +367,25 @@
   return TRUE;
 }
 
+typedef struct _CdCacheCallbackData {
+  CdCache *cache;
+  gboolean called;
+} CdCacheCallbackData;
+
+static void
+cb_mount_done (gboolean success, char * error,
+               char * detail, CdCacheCallbackData * data)
+{
+  data->called = TRUE;
+  data->cache->mounted = success;
+}
+
 static gboolean
 cd_cache_open_mountpoint (CdCache *cache,
 			  GError **error)
 {
+  CdCacheCallbackData data;
+
   /* already opened? */
   if (cache->mounted || cache->is_media == FALSE)
     return TRUE;
@@ -388,38 +397,53 @@
 
   /* mount if we have to */
   if (cache->self_mounted) {
-    char *command;
-    int status;
+    /* mount - wait for callback */
+    data.called = FALSE;
+    data.cache = cache;
+    gnome_vfs_drive_mount (cache->drive,
+	(GnomeVFSVolumeOpCallback) cb_mount_done, &data);
+    while (!data.called) g_main_iteration (TRUE);
 
-    command = g_strdup_printf ("mount %s", cache->mountpoint);
-    if (!g_spawn_command_line_sync (command,
-             NULL, NULL, &status, error)) {
-      g_free (command);
-      return FALSE;
-    }
-    g_free (command);
-    if (status != 0) {
+    if (!cache->mounted) {
       g_set_error (error, 0, 0,
-          _("Unexpected error status %d while mounting %s"),
-          status, cache->mountpoint);
+	  _("Failed to mount %s"), cache->device);
       return FALSE;
     }
+    if (!cache->mountpoint) {
+      char *mnt = gnome_vfs_drive_get_activation_uri (cache->drive);
+
+      if (mnt && strncmp (mnt, "file://", 7) == 0) {
+        cache->mountpoint = g_strdup (mnt + 7);
+	g_free (mnt);
+      } else {
+	g_free (mnt);
+	g_set_error (error, 0, 0,
+	    _("Failed to find mountpoint for %s"), cache->device);
+	return FALSE;
+      }
+    }
   }
 
-  cache->mounted = TRUE;
   return TRUE;
 }
 
 static void
+cb_umount_done (gboolean success, char * error,
+                char * detail, gboolean * called)
+{
+  *called = TRUE;
+}
+
+static void
 cd_cache_free (CdCache *cache)
 {
   /* umount if we mounted */
   if (cache->self_mounted && cache->mounted) {
-    char *command;
+    gboolean called = FALSE;
 
-    command = g_strdup_printf ("umount %s", cache->mountpoint);
-    g_spawn_command_line_sync (command, NULL, NULL, NULL, NULL);
-    g_free (command);
+    gnome_vfs_drive_unmount (cache->drive,
+	(GnomeVFSVolumeOpCallback) cb_umount_done, &called);
+    while (!called) g_main_iteration (TRUE);
   }
 
   /* close file descriptor to device */
@@ -543,13 +567,13 @@
 cd_cache_disc_is_vcd (CdCache *cache,
                       GError **error)
 {
-  if (!cache->mountpoint)
-    return MEDIA_TYPE_ERROR;
   /* open disc and open mount */
   if (!cd_cache_open_device (cache, error))
     return MEDIA_TYPE_ERROR;
   if (!cd_cache_open_mountpoint (cache, error))
     return MEDIA_TYPE_ERROR;
+  if (!cache->mountpoint)
+    return MEDIA_TYPE_ERROR;
   /* first is VCD, second is SVCD */
   if (cd_cache_file_exists (cache, "MPEGAV", "AVSEQ01.DAT") ||
       cd_cache_file_exists (cache, "MPEG2", "AVSEQ01.MPG"))
@@ -562,14 +586,14 @@
 cd_cache_disc_is_dvd (CdCache *cache,
 		      GError **error)
 {
-  if (!cache->mountpoint)
-    return MEDIA_TYPE_ERROR;
   /* open disc, check capabilities and open mount */
   if (!cd_cache_open_device (cache, error))
     return MEDIA_TYPE_ERROR;
   if (!(cache->cap & CDC_DVD))
     return MEDIA_TYPE_DATA;
   if (!cd_cache_open_mountpoint (cache, error))
+    return MEDIA_TYPE_ERROR;
+  if (!cache->mountpoint)
     return MEDIA_TYPE_ERROR;
   if (cd_cache_file_exists (cache, "VIDEO_TS", "VIDEO_TS.IFO"))
     return MEDIA_TYPE_DVD;
