diff -ruN sound-juicer-2.32.0/configure.in sound-juicer-2.32.0.patched/configure.in --- sound-juicer-2.32.0/configure.in 2017-04-05 01:01:49.846241257 +0300 +++ sound-juicer-2.32.0.patched/configure.in 2017-04-05 01:00:52.799533147 +0300 @@ -93,6 +93,15 @@ AM_GST_ELEMENT_CHECK(wavenc,,AC_MSG_WARN([The 'wavenc' element was not found. This will cause encoding to Wave to fail.])) 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 libcdio +PKG_CHECK_MODULES([CDIO],[libcdio >= 0.70], [have_cdio=yes], [have_cdio=no]) +AC_SUBST([CDIO_CFLAGS]) +AC_SUBST([CDIO_LIBS]) +AM_CONDITIONAL([HAVE_LIBCDIO], [test "$have_cdio" = "yes"]) +if test "$have_cdio" = "yes" ; then + AC_DEFINE([HAVE_LIBCDIO], 1, [Whether libcdio is available]) +fi + # Find optional MusicBrainz3 and required Musicbrainz2 PKG_CHECK_MODULES(MUSICBRAINZ3, libmusicbrainz3 >= 3.0.2, [have_mb3=yes], [have_mb3=no]) AC_SUBST(MUSICBRAINZ3_CFLAGS) diff -ruN sound-juicer-2.32.0/libjuicer/Makefile.am sound-juicer-2.32.0.patched/libjuicer/Makefile.am --- sound-juicer-2.32.0/libjuicer/Makefile.am 2017-04-05 01:01:49.849873326 +0300 +++ sound-juicer-2.32.0.patched/libjuicer/Makefile.am 2017-04-05 01:00:54.663486380 +0300 @@ -49,6 +49,12 @@ sj-metadata-musicbrainz3.c endif +if HAVE_LIBCDIO +libjuicer_la_SOURCES += \ + sj-metadata-cdtext.h \ + sj-metadata-cdtext.c +endif + # # Build the GValue marshals # diff -ruN sound-juicer-2.32.0/libjuicer/sj-metadata-cdtext.c sound-juicer-2.32.0.patched/libjuicer/sj-metadata-cdtext.c --- sound-juicer-2.32.0/libjuicer/sj-metadata-cdtext.c.~1~ 2017-04-05 01:04:46.652330182 +0300 +++ sound-juicer-2.32.0/libjuicer/sj-metadata-cdtext.c 2017-04-05 01:32:41.473066952 +0300 @@ -0,0 +1,222 @@ +/* + * sj-metadata-cdtext.c + * Copyright (C) 2005 Ross Burton + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif /* HAVE_CONFIG_H */ + +#include +#include +#include +#include +#include +#include + +#include "sj-metadata-cdtext.h" +#include "sj-structures.h" +#include "sj-error.h" +#include "sj-util.h" + +struct SjMetadataCdtextPrivate { + char *cdrom; +}; + +#define GET_PRIVATE(o) \ + (G_TYPE_INSTANCE_GET_PRIVATE ((o), SJ_TYPE_METADATA_CDTEXT, SjMetadataCdtextPrivate)) + +enum { + PROP_0, + PROP_DEVICE, + PROP_PROXY_HOST, + PROP_PROXY_PORT, +}; + +static void metadata_iface_init (gpointer g_iface, gpointer iface_data); + +G_DEFINE_TYPE_WITH_CODE (SjMetadataCdtext, sj_metadata_cdtext, + G_TYPE_OBJECT, + G_IMPLEMENT_INTERFACE (SJ_TYPE_METADATA, metadata_iface_init)); + + +/* + * Private methods + */ + +static GList * +cdtext_list_albums (SjMetadata *metadata, char **url, GError **error) +{ + SjMetadataCdtextPrivate *priv; + AlbumDetails *album; + CdIo *cdio; + track_t cdtrack, last_cdtrack; + const cdtext_t *cdtext; + + g_return_val_if_fail (SJ_IS_METADATA_CDTEXT (metadata), NULL); + + priv = SJ_METADATA_CDTEXT (metadata)->priv; + + cdio = cdio_open (priv->cdrom, DRIVER_UNKNOWN); + if (!cdio) { + g_warning ("Cannot open CD"); + g_set_error (error, SJ_ERROR, SJ_ERROR_INTERNAL_ERROR, _("Cannot read CD")); + return NULL; + } + + album = g_new0 (AlbumDetails, 1); + + /* TODO: why can't I do this first? */ + cdtext = cdio_get_cdtext(cdio); + if (cdtext) { + album->title = g_strdup (cdtext_get (cdtext, CDTEXT_FIELD_TITLE, 0)); + album->artist = g_strdup (cdtext_get (cdtext, CDTEXT_FIELD_PERFORMER, 0)); + album->genre = g_strdup (cdtext_get (cdtext, CDTEXT_FIELD_GENRE, 0)); + + album->metadata_source = SOURCE_CDTEXT; + } else { + album->artist = g_strdup (_("Unknown Artist")); + album->title = g_strdup (_("Unknown Title")); + album->genre = g_strdup (""); + + album->metadata_source = SOURCE_FALLBACK; + } + + cdtrack = cdio_get_first_track_num(cdio); + last_cdtrack = cdtrack + cdio_get_num_tracks(cdio); + + for ( ; cdtrack < last_cdtrack; cdtrack++ ) { + TrackDetails *track; + track = g_new0 (TrackDetails, 1); + track->album = album; + track->number = cdtrack; + cdtext = cdio_get_cdtext(cdio); + if (cdtext) { + track->title = g_strdup (cdtext_get (cdtext, CDTEXT_FIELD_TITLE, cdtrack)); + track->artist = g_strdup (cdtext_get (cdtext, CDTEXT_FIELD_PERFORMER, cdtrack)); + } else { + track->title = g_strdup_printf (_("Track %d"), cdtrack); + track->artist = g_strdup (_("Unknown Artist")); + } + track->duration = cdio_get_track_sec_count (cdio, cdtrack) / CDIO_CD_FRAMES_PER_SEC; + + album->tracks = g_list_append (album->tracks, track); + album->number++; + } + + return g_list_append (NULL, album); +} + + +/* + * GObject methods + */ + +static void +sj_metadata_cdtext_get_property (GObject *object, guint property_id, + GValue *value, GParamSpec *pspec) +{ + SjMetadataCdtextPrivate *priv = SJ_METADATA_CDTEXT (object)->priv; + g_assert (priv); + + switch (property_id) { + case PROP_DEVICE: + g_value_set_string (value, priv->cdrom); + break; + case PROP_PROXY_HOST: + /* Do nothing */ + g_value_set_string (value, ""); + break; + case PROP_PROXY_PORT: + /* Do nothing */ + g_value_set_int (value, 0); + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +sj_metadata_cdtext_set_property (GObject *object, guint property_id, + const GValue *value, GParamSpec *pspec) +{ + SjMetadataCdtextPrivate *priv = SJ_METADATA_CDTEXT (object)->priv; + g_assert (priv); + + switch (property_id) { + case PROP_DEVICE: + if (priv->cdrom) + g_free (priv->cdrom); + priv->cdrom = g_value_dup_string (value); + break; + case PROP_PROXY_HOST: + case PROP_PROXY_PORT: + /* Do nothing */ + break; + default: + G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); + } +} + +static void +sj_metadata_cdtext_finalize (GObject *object) +{ + SjMetadataCdtextPrivate *priv = SJ_METADATA_CDTEXT (object)->priv; + g_free (priv->cdrom); +} + +static void +sj_metadata_cdtext_init (SjMetadataCdtext *cdtext) +{ + cdtext->priv = GET_PRIVATE (cdtext); +} + +static void +metadata_iface_init (gpointer g_iface, gpointer iface_data) +{ + SjMetadataClass *klass = (SjMetadataClass*)g_iface; + + klass->list_albums = cdtext_list_albums; +} + +static void +sj_metadata_cdtext_class_init (SjMetadataCdtextClass *class) +{ + GObjectClass *object_class = (GObjectClass*) class; + + g_type_class_add_private (class, sizeof (SjMetadataCdtextPrivate)); + + object_class->get_property = sj_metadata_cdtext_get_property; + object_class->set_property = sj_metadata_cdtext_set_property; + object_class->finalize = sj_metadata_cdtext_finalize; + + g_object_class_override_property (object_class, PROP_DEVICE, "device"); + g_object_class_override_property (object_class, PROP_PROXY_HOST, "proxy-host"); + g_object_class_override_property (object_class, PROP_PROXY_PORT, "proxy-port"); +} + + +/* + * Public methods + */ + +GObject * +sj_metadata_cdtext_new (void) +{ + return g_object_new (sj_metadata_cdtext_get_type (), NULL); +} diff -ruN sound-juicer-2.32.0/libjuicer/sj-metadata-getter.c sound-juicer-2.32.0.patched/libjuicer/sj-metadata-getter.c --- sound-juicer-2.32.0/libjuicer/sj-metadata-getter.c 2010-05-27 02:53:08.000000000 +0400 +++ sound-juicer-2.32.0.patched/libjuicer/sj-metadata-getter.c 2017-04-05 01:00:59.549862971 +0300 @@ -32,6 +32,9 @@ #ifdef HAVE_MUSICBRAINZ #include "sj-metadata-musicbrainz.h" #endif /* HAVE_MUSICBRAINZ */ +#ifdef HAVE_LIBCDIO +#include "sj-metadata-cdtext.h" +#endif /* HAVE_LIBCDIO */ #include "sj-metadata-gvfs.h" #include "sj-error.h" @@ -181,6 +184,9 @@ #ifdef HAVE_MUSICBRAINZ SJ_TYPE_METADATA_MUSICBRAINZ, #endif /* HAVE_MUSICBRAINZ */ +#ifdef HAVE_LIBCDIO + SJ_TYPE_METADATA_CDTEXT, +#endif /* HAVE_LIBCDIO */ SJ_TYPE_METADATA_GVFS }; --- /dev/null 2017-04-05 01:36:38.000000000 +0300 +++ sound-juicer-2.32.0.patched/libjuicer/sj-metadata-cdtext.h 2017-04-05 01:00:57.425514406 +0300 @@ -0,0 +1,57 @@ +/* + * sj-metadata-cdtext.h + * Copyright (C) 2005 Ross Burton + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + */ + +#ifndef SJ_METADATA_CDTEXT_H +#define SJ_METADATA_CDTEXT_H + +#include +#include "sj-metadata.h" + +G_BEGIN_DECLS + +#define SJ_TYPE_METADATA_CDTEXT (sj_metadata_cdtext_get_type ()) +#define SJ_METADATA_CDTEXT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SJ_TYPE_METADATA_CDTEXT, SjMetadataCdtext)) +#define SJ_METADATA_CDTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), SJ_TYPE_METADATA_CDTEXT, SjMetadataCdtextClass)) +#define SJ_IS_METADATA_CDTEXT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SJ_TYPE_METADATA_CDTEXT)) +#define SJ_IS_METADATA_CDTEXT_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), SJ_TYPE_METADATA_CDTEXT)) +#define SJ_METADATA_CDTEXT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), SJ_TYPE_METADATA_CDTEXT, SjMetadataCdtextClass)) + +typedef struct _SjMetadataCdtext SjMetadataCdtext; +typedef struct _SjMetadataCdtextClass SjMetadataCdtextClass; +typedef struct SjMetadataCdtextPrivate SjMetadataCdtextPrivate; + +struct _SjMetadataCdtext +{ + GObject parent; + SjMetadataCdtextPrivate *priv; +}; + +struct _SjMetadataCdtextClass +{ + GObjectClass parent; +}; + +GType sj_metadata_cdtext_get_type (void); + +GObject *sj_metadata_cdtext_new (void); + +G_END_DECLS + +#endif /* SJ_METADATA_CDTEXT_H */