--- gst-plugins-base0.10-0.10.36.orig/gst-libs/gst/cdda/gstcddabasesrc.c
+++ gst-plugins-base0.10-0.10.36/gst-libs/gst/cdda/gstcddabasesrc.c
@@ -1139,22 +1139,28 @@ gst_cddabasesrc_calculate_musicbrainz_di
   guchar digest[20];
   gchar *ptr;
   gchar tmp[9];
-  gulong i;
+  gulong i, last_track;
   guint leadout_sector;
   gsize digest_len;
 
   s = g_string_new (NULL);
 
-  leadout_sector = src->tracks[src->num_tracks - 1].end + 1 + CD_MSF_OFFSET;
-
   /* generate SHA digest */
   sha = g_checksum_new (G_CHECKSUM_SHA1);
   g_snprintf (tmp, sizeof (tmp), "%02X", src->tracks[0].num);
   g_string_append_printf (s, "%02X", src->tracks[0].num);
   g_checksum_update (sha, (guchar *) tmp, 2);
 
-  g_snprintf (tmp, sizeof (tmp), "%02X", src->tracks[src->num_tracks - 1].num);
-  g_string_append_printf (s, " %02X", src->tracks[src->num_tracks - 1].num);
+  for (last_track = src->num_tracks - 1; last_track >= 0; last_track--) {
+    if (src->tracks[last_track].is_audio) {
+      break;
+    }
+  }
+
+  leadout_sector = src->tracks[last_track].end + 1 + CD_MSF_OFFSET;
+      
+  g_snprintf (tmp, sizeof (tmp), "%02X", src->tracks[last_track].num);
+  g_string_append_printf (s, " %02X", src->tracks[last_track].num);
   g_checksum_update (sha, (guchar *) tmp, 2);
 
   g_snprintf (tmp, sizeof (tmp), "%08X", leadout_sector);
@@ -1162,7 +1168,7 @@ gst_cddabasesrc_calculate_musicbrainz_di
   g_checksum_update (sha, (guchar *) tmp, 8);
 
   for (i = 0; i < 99; i++) {
-    if (i < src->num_tracks) {
+    if (i < src->num_tracks && src->tracks[i].is_audio) {
       guint frame_offset = src->tracks[i].start + CD_MSF_OFFSET;
 
       g_snprintf (tmp, sizeof (tmp), "%08X", frame_offset);
