--- old-stuff/sources/rb-audiocd-source.c	2005-12-16 08:35:47.000000000 +1000
+++ new-stuff/sources/rb-audiocd-source.c	2005-12-16 08:35:47.000000000 +1000
@@ -281,14 +281,14 @@ rb_audiocd_get_cd_info (RBAudioCdSource 
 #elif HAVE_GSTREAMER_0_10
 	GstFormat out_fmt = fmt;
 	if (!gst_element_query_duration (priv->cdda, &out_fmt, num_tracks) || out_fmt != fmt) {
-	    return FALSE;
+		return FALSE;
 	}
 #endif
 
 	return TRUE;
 }
 
-static void
+static gboolean
 rb_audiocd_scan_songs (RBAudioCdSource *source, RhythmDB *db)
 {
 	gint64 i, num_tracks;
@@ -300,8 +300,8 @@ rb_audiocd_scan_songs (RBAudioCdSource *
 #ifdef HAVE_GSTREAMER_0_8
 	if (gst_element_set_state (priv->pipeline, GST_STATE_PAUSED) != GST_STATE_SUCCESS) {
 		rb_error_dialog (NULL, _("Couldn't load Audio CD"),
-					_("Rhythmbox couldn't access the cd."));
-		return;
+					_("Rhythmbox couldn't access the CD."));
+		return FALSE;
 	}
 #elif HAVE_GSTREAMER_0_10
 	ret = gst_element_set_state (priv->pipeline, GST_STATE_PAUSED);
@@ -310,16 +310,16 @@ rb_audiocd_scan_songs (RBAudioCdSource *
 	}
         if (ret == GST_STATE_CHANGE_FAILURE) {
 		rb_error_dialog (NULL, _("Couldn't load Audio CD"),
-					_("Rhythmbox couldn't access the cd."));
-		return;
+					_("Rhythmbox couldn't access the CD."));
+		return FALSE;
 	}
 #endif
 
 	if (!rb_audiocd_get_cd_info (source, &num_tracks))
 	{
 		rb_error_dialog (NULL, _("Couldn't load Audio CD"),
-					_("Rhythmbox could read the cd information."));
-		return;
+					_("Rhythmbox couldn't read the CD information."));
+		return FALSE;
 	}
 
 	rb_debug ("importing Audio Cd %s - %d tracks", priv->device_path, num_tracks);
@@ -340,6 +340,8 @@ rb_audiocd_scan_songs (RBAudioCdSource *
 #endif
 		rb_debug ("failed to set cd state");
 	}
+
+	return TRUE;
 }
 
 #ifdef HAVE_MUSICBRAINZ
@@ -360,6 +362,10 @@ metadata_cb (SjMetadata *metadata, GList
 		g_object_unref (metadata);
 		return;
 	}
+	if (cd_track == NULL) {
+		/* empty cd? */
+		return;
+	}
 
 	g_object_get (G_OBJECT (source), "shell", &shell, NULL);
 	g_object_get (G_OBJECT (shell), "db", &db, NULL);
@@ -486,8 +492,8 @@ rb_audiocd_load_songs (RBAudioCdSource *
 	gst_bin_add_many (GST_BIN (priv->pipeline), priv->cdda, priv->fakesink, NULL);
 	gst_element_link (priv->cdda, priv->fakesink);
 	
-	rb_audiocd_scan_songs (source, db);
-	rb_audiocd_load_metadata (source, db);
+	if (rb_audiocd_scan_songs (source, db))
+		rb_audiocd_load_metadata (source, db);
 
 error_out:
 	g_object_unref (G_OBJECT (db));

--- old-stuff/ChangeLog	2005-12-16 08:35:47.000000000 +1000
+++ new-stuff/ChangeLog	2005-12-16 08:35:47.000000000 +1000
@@ -1,3 +1,13 @@
+2005-12-16  Jonathan Matthew  <jonathan@kaolin.hn.org>
+
+	* sources/rb-audiocd-source.c 
+	(rb_audiocd_get_cd_info): tab
+	(rb_audiocd_scan_songs): Return boolean success/failure,
+	fix error messages a bit.
+	(metadata_cb): Don't crash if we have no tracks
+	(rb_audiocd_load_songs): Don't try to read metadata if we can't read
+	the CD.
+
 2005-12-15  William Jon McCann  <mccann@jhu.edu>
 
 	* shell/rb-shell.c (rb_shell_sync_fullscreen) 

