File gstreamer-plugins-base-discid.patch of Package gstreamer-plugins-base.4248

From 3e2add20f53d2543d495d32ab581e145be254013 Mon Sep 17 00:00:00 2001
From: Johannes Dewender <gnome@JonnyJD.net>
Date: Sat, 28 Sep 2013 13:19:02 +0200
Subject: [PATCH] bug 708991: fix MB discids for trailing data tracks

MusicBrainz removes trailing data tracks from releases on the server
and also for the calculation of the MusicBrainz Disc ID.
---
 gst-libs/gst/audio/gstaudiocdsrc.c | 20 ++++++++++++++------
 1 file changed, 14 insertions(+), 6 deletions(-)

diff --git a/gst-libs/gst/audio/gstaudiocdsrc.c b/gst-libs/gst/audio/gstaudiocdsrc.c
index 716ea0a..8296ab2 100644
--- a/gst-libs/gst/audio/gstaudiocdsrc.c
+++ b/gst-libs/gst/audio/gstaudiocdsrc.c
@@ -1189,13 +1189,23 @@ gst_audio_cd_src_calculate_musicbrainz_discid (GstAudioCdSrc * src)
   gchar *ptr;
   gchar tmp[9];
   gulong i;
+  unsigned int last_audio_track;
   guint leadout_sector;
   gsize digest_len;
 
   s = g_string_new (NULL);
 
+  /* MusicBrainz doesn't consider trailing data tracks
+   * data tracks up front stay, since the disc has to start with 1 */
+  last_audio_track = 0;
+  for (i = 0; i < src->priv->num_tracks; i++) {
+    if (src->priv->tracks[i].is_audio) {
+      last_audio_track = src->priv->tracks[i].num;
+    }
+  }
+
   leadout_sector =
-      src->priv->tracks[src->priv->num_tracks - 1].end + 1 + CD_MSF_OFFSET;
+      src->priv->tracks[last_audio_track - 1].end + 1 + CD_MSF_OFFSET;
 
   /* generate SHA digest */
   sha = g_checksum_new (G_CHECKSUM_SHA1);
@@ -1203,10 +1213,8 @@ gst_audio_cd_src_calculate_musicbrainz_discid (GstAudioCdSrc * src)
   g_string_append_printf (s, "%02X", src->priv->tracks[0].num);
   g_checksum_update (sha, (guchar *) tmp, 2);
 
-  g_snprintf (tmp, sizeof (tmp), "%02X",
-      src->priv->tracks[src->priv->num_tracks - 1].num);
-  g_string_append_printf (s, " %02X",
-      src->priv->tracks[src->priv->num_tracks - 1].num);
+  g_snprintf (tmp, sizeof (tmp), "%02X", last_audio_track);
+  g_string_append_printf (s, " %02X", last_audio_track);
   g_checksum_update (sha, (guchar *) tmp, 2);
 
   g_snprintf (tmp, sizeof (tmp), "%08X", leadout_sector);
@@ -1214,7 +1222,7 @@ gst_audio_cd_src_calculate_musicbrainz_discid (GstAudioCdSrc * src)
   g_checksum_update (sha, (guchar *) tmp, 8);
 
   for (i = 0; i < 99; i++) {
-    if (i < src->priv->num_tracks) {
+    if (i < last_audio_track) {
       guint frame_offset = src->priv->tracks[i].start + CD_MSF_OFFSET;
 
       g_snprintf (tmp, sizeof (tmp), "%08X", frame_offset);
-- 
1.8.1.3
openSUSE Build Service is sponsored by