rhythmbox r5897 - in trunk: . plugins/audiocd



Author: hadess
Date: Mon Sep  8 23:38:22 2008
New Revision: 5897
URL: http://svn.gnome.org/viewvc/rhythmbox?rev=5897&view=rev

Log:
2008-09-09  Bastien Nocera  <hadess hadess net>

	* configure.ac:
	* plugins/audiocd/Makefile.am:
	* plugins/audiocd/rb-audiocd-source.c
	(rb_audiocd_create_track_entry): Link against libgstcdda,
	and access the tags directly to get the duration of the tracks,
	avoids a lot of slow seeking on the CD, and makes loading CDs
	awfully fast (Helps: #551011)



Modified:
   trunk/ChangeLog
   trunk/configure.ac
   trunk/plugins/audiocd/Makefile.am
   trunk/plugins/audiocd/rb-audiocd-source.c

Modified: trunk/configure.ac
==============================================================================
--- trunk/configure.ac	(original)
+++ trunk/configure.ac	Mon Sep  8 23:38:22 2008
@@ -425,6 +425,10 @@
 
 AC_CHECK_LIB(z, uncompress)
 
+dnl check for libgstcdda, needed to list the audio tracks
+PKG_CHECK_MODULES(GSTCDDA, gstreamer-cdda-0.10)
+AC_SUBST(GSTCDDA_LIBS)
+AC_SUBST(GSTCDDA_CFLAGS)
 
 dnl check for MusicBrainz
 AC_ARG_ENABLE(musicbrainz, AC_HELP_STRING([--disable-musicbrainz],

Modified: trunk/plugins/audiocd/Makefile.am
==============================================================================
--- trunk/plugins/audiocd/Makefile.am	(original)
+++ trunk/plugins/audiocd/Makefile.am	Mon Sep  8 23:38:22 2008
@@ -9,9 +9,10 @@
 libaudiocd_la_LDFLAGS = $(PLUGIN_LIBTOOL_FLAGS)
 
 libaudiocd_la_LIBADD = \
-	$(top_builddir)/corelib/librhythmbox-core.la \
-	$(TOTEM_PLPARSER_LIBS)       \
-	$(LIBNAUTILUS_BURN_LIBS)
+	$(top_builddir)/corelib/librhythmbox-core.la	\
+	$(TOTEM_PLPARSER_LIBS)				\
+	$(LIBNAUTILUS_BURN_LIBS)			\
+	$(GSTCDDA_LIBS)
 
 if HAVE_MUSICBRAINZ
 libaudiocd_la_LIBADD += $(MUSICBRAINZ_LIBS)
@@ -44,6 +45,7 @@
 	-DDATADIR=\""$(datadir)"\"			\
 	$(TOTEM_PLPARSER_CFLAGS)			\
 	$(RHYTHMBOX_CFLAGS)				\
+	$(GSTCDDA_CFLAGS)				\
 	$(MUSICBRAINZ_CFLAGS) $(MUSICBRAINZ3_CFLAGS)	\
 	$(LIBNAUTILUS_BURN_CFLAGS)			\
 	-DUSE_TOTEM_PL_PARSER				\

Modified: trunk/plugins/audiocd/rb-audiocd-source.c
==============================================================================
--- trunk/plugins/audiocd/rb-audiocd-source.c	(original)
+++ trunk/plugins/audiocd/rb-audiocd-source.c	Mon Sep  8 23:38:22 2008
@@ -39,6 +39,7 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 #include <gst/gst.h>
+#include <gst/cdda/gstcddabasesrc.h>
 
 #include "rb-plugin.h"
 #include "rhythmdb.h"
@@ -238,6 +239,7 @@
 	RhythmDBEntry *entry;
 	RBAudioCdSourcePrivate *priv = AUDIOCD_SOURCE_GET_PRIVATE (source);
 	char *audio_path;
+	guint64 duration;
 	GValue value = {0, };
 	gchar *str;
 	RhythmDBEntryType entry_type;
@@ -270,27 +272,17 @@
 			    &value);
 	g_value_unset (&value);
 
-	/* determine the duration */
-	{
-		GstFormat time_format = GST_FORMAT_TIME;
-		GstFormat track_format = gst_format_get_by_nick ("track");
-		gint64 duration;
-		gboolean result;
-                result = gst_element_seek (priv->fakesink, 1.0, track_format, GST_SEEK_FLAG_FLUSH, GST_SEEK_TYPE_SET, (guint64) track_number - 1, GST_SEEK_TYPE_NONE, -1);
-		if (result) {
-			result = gst_element_query_duration (priv->fakesink, &time_format, &duration) && time_format == GST_FORMAT_TIME;
-		}
-
-		if (result) {
-			g_value_init (&value, G_TYPE_ULONG);
-			g_value_set_ulong (&value, (gulong)(duration / GST_SECOND));
-			rhythmdb_entry_set (db, entry,
-					    RHYTHMDB_PROP_DURATION,
-					    &value);
-			g_value_unset (&value);
-		} else {
-			g_warning ("Failed to query cd track duration");
-		}
+	/* determine the duration
+	 * FIXME: http://bugzilla.gnome.org/show_bug.cgi?id=551011 */
+	if (gst_tag_list_get_uint64 (GST_CDDA_BASE_SRC(priv->cdda)->tracks[track_number - 1].tags, GST_TAG_DURATION, &duration)) {
+		g_value_init (&value, G_TYPE_ULONG);
+		g_value_set_ulong (&value, (gulong)(duration / GST_SECOND));
+		rhythmdb_entry_set (db, entry,
+				    RHYTHMDB_PROP_DURATION,
+				    &value);
+		g_value_unset (&value);
+	} else {
+		g_warning ("Failed to query cd track duration");
 	}
 
 	entry_set_string_prop (db, entry, FALSE, RHYTHMDB_PROP_ARTIST, NULL);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]