[sound-juicer/musicbrainz4: 5/12] mb4: use libdiscid for discid extraction
- From: Ross Burton <rburton src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [sound-juicer/musicbrainz4: 5/12] mb4: use libdiscid for discid extraction
- Date: Mon, 7 Nov 2011 15:11:21 +0000 (UTC)
commit d33042ca2b2f5384e8b3663a6ee014c08065ccc6
Author: Christophe Fergeau <cfergeau redhat com>
Date: Mon Aug 1 11:45:02 2011 +0200
mb4: use libdiscid for discid extraction
libmusicbrainz4 no longer provides an API to get the discid of
a physical CD, libdiscid has to be used for that.
configure.in | 2 +-
libjuicer/sj-metadata-musicbrainz4.c | 36 ++++++++++++++-------------------
2 files changed, 16 insertions(+), 22 deletions(-)
---
diff --git a/configure.in b/configure.in
index f5027b3..9e97014 100644
--- a/configure.in
+++ b/configure.in
@@ -71,7 +71,7 @@ AM_GST_ELEMENT_CHECK(wavenc,,AC_MSG_WARN([The 'wavenc' element was not found. Th
AM_GST_ELEMENT_CHECK(giosink,,AC_MSG_WARN([The 'giosink' element was not found. This will cause Sound Juicer to fail at runtime.]))
# Find optional MusicBrainz4
-PKG_CHECK_MODULES(MUSICBRAINZ4, libmusicbrainz4, [have_mb4=yes], [have_mb4=no])
+PKG_CHECK_MODULES(MUSICBRAINZ4, libmusicbrainz4 libdiscid, [have_mb4=yes], [have_mb4=no])
AC_SUBST(MUSICBRAINZ4_CFLAGS)
AC_SUBST(MUSICBRAINZ4_LIBS)
if test "$have_mb4" = "yes" ; then
diff --git a/libjuicer/sj-metadata-musicbrainz4.c b/libjuicer/sj-metadata-musicbrainz4.c
index 95c3a89..772eb63 100644
--- a/libjuicer/sj-metadata-musicbrainz4.c
+++ b/libjuicer/sj-metadata-musicbrainz4.c
@@ -29,6 +29,7 @@
#include <glib.h>
#include <glib-object.h>
#include <gconf/gconf-client.h>
+#include <discid/discid.h>
#include <musicbrainz4/mb4_c.h>
#include "sj-metadata-musicbrainz4.h"
@@ -76,6 +77,7 @@
typedef struct {
Mb4Query mb;
+ DiscId *disc;
char *cdrom;
/* Proxy */
char *http_proxy;
@@ -445,51 +447,40 @@ mb4_list_albums (SjMetadata *metadata, char **url, GError **error)
GList *albums = NULL;
Mb4ReleaseList releases;
Mb4Release release;
- char *discid = NULL;
+ const char *discid = NULL;
char buffer[1024];
int i;
g_return_val_if_fail (SJ_IS_METADATA_MUSICBRAINZ4 (metadata), NULL);
priv = GET_PRIVATE (metadata);
-#if 0
if (sj_metadata_helper_check_media (priv->cdrom, error) == FALSE) {
return NULL;
}
-#endif
-#if 0
- priv->disc = mb_read_disc (priv->cdrom);
+ priv->disc = discid_new ();
if (priv->disc == NULL)
return NULL;
+ if (discid_read (priv->disc, priv->cdrom) == 0)
+ return NULL;
- if (url != NULL) {
- mb_get_submission_url (priv->disc, NULL, 0, buffer, sizeof (buffer));
- *url = g_strdup (buffer);
- }
-#endif
- g_warning("no reading of disc");
- /* priv->disc = NULL; */
- g_warning("no setting of url");
- *url = NULL;
+ if (url != NULL)
+ *url = g_strdup (discid_get_submission_url (priv->disc));
if (g_getenv("MUSICBRAINZ_FORCE_DISC_ID")) {
- discid = g_strdup (g_getenv("MUSICBRAINZ_FORCE_DISC_ID"));
+ discid = g_getenv("MUSICBRAINZ_FORCE_DISC_ID");
} else {
- g_warning("no MusicBrainz ID, use MISICBRAINZ_FORCE_DISC_ID");
- //GET(discid, mb_disc_get_id, priv->disc);
+ discid = discid_get_id (priv->disc);
}
releases = mb4_query_lookup_discid(priv->mb, discid);
if (releases == NULL) {
- g_free (discid);
return NULL;
}
if (mb4_release_list_size (releases) == 0) {
mb4_release_list_delete (releases);
- g_free (discid);
return NULL;
}
@@ -528,7 +519,6 @@ mb4_list_albums (SjMetadata *metadata, char **url, GError **error)
}
}
mb4_release_list_delete (releases);
- g_free (discid);
return albums;
}
@@ -652,13 +642,17 @@ static void
sj_metadata_musicbrainz4_finalize (GObject *object)
{
SjMetadataMusicbrainz4Private *priv;
-
+
priv = GET_PRIVATE (object);
if (priv->mb != NULL) {
mb4_query_delete (priv->mb);
priv->mb = NULL;
}
+ if (priv->disc != NULL) {
+ discid_free (priv->disc);
+ priv->disc = NULL;
+ }
g_free (priv->cdrom);
G_OBJECT_CLASS (sj_metadata_musicbrainz4_parent_class)->finalize (object);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]