--- configure.in.orig 2005-08-18 19:41:42.591059200 -0500 +++ configure.in 2005-08-18 19:48:06.499696216 -0500 @@ -19,6 +19,7 @@ m4_define(xml_minver, 2.4.7) m4_define(startup_notification_minver, 0.8) m4_define(exif_minver, 0.5.12) +m4_define(gstreamer_minver, 0.6.0) AC_INIT(nautilus, 2.11.91, [http://bugzilla.gnome.org/enter_bug.cgi?product=nautilus]) @@ -48,7 +49,7 @@ AC_SUBST(RSVG_REQUIRED, [rsvg_minver]) AC_SUBST(XML_REQUIRED, [xml_minver]) AC_SUBST(STARTUP_NOTIFICATION_REQUIRED, [startup_notification_minver]) - +AC_SUBST(GSTREAMER_REQUIRED, [gstreamer_minver]) AC_C_BIGENDIAN AC_C_CONST @@ -270,6 +271,52 @@ dnl ========================================================================== +dnl gstreamer checking + +AC_ARG_ENABLE(gstreamer, + AC_HELP_STRING([--enable-gstreamer],[use GStreamer for sound preview]), + [case "${enableval}" in + yes) ENABLE_GST=yes ;; + no) ENABLE_GST=no ;; + *) AC_MSG_ERROR(bad value ${enableval} for --enable-gstreamer) ;; + esac], + [ENABLE_GST=no]) dnl Default value + +AC_MSG_CHECKING(for backend libraries) + +if test x$ENABLE_GST = xyes; then + +dnl Now we're ready to ask for gstreamer libs and cflags +dnl And we can also ask for the right version of gstreamer + HAVE_GSTREAMER=no + +dnl start with 0.7 + GST_MAJORMINOR=0.8 + PKG_CHECK_MODULES(GST, \ + gstreamer-gconf-$GST_MAJORMINOR >= $GSTREAMER_REQUIRED, + HAVE_GSTREAMER=yes,HAVE_GSTREAMER=no) + +dnl try 0.6 + if test "x$HAVE_GSTREAMER" = "xno"; then + GST_MAJORMINOR=0.6 + PKG_CHECK_MODULES(GST, \ + gstreamer-gconf-$GST_MAJORMINOR >= $GSTREAMER_REQUIRED, + HAVE_GSTREAMER=yes,HAVE_GSTREAMER=no) + fi + +dnl Give error and exit if we don't have gstreamer + if test "x$HAVE_GSTREAMER" = "xno"; then + AC_MSG_ERROR(you need gstreamer development packages installed !) + fi + + MM="gstreamer-libs-$GST_MAJORMINOR >= $GSTREAMER_REQUIRED gstreamer-gconf-$GST_MAJORMINOR >= $GSTREAMER_REQUIRED" + + AC_MSG_RESULT(GStreamer) + AC_DEFINE(USE_GST_AUDIO_PREVIEW,1,[Define if you want to use the GStreamer media framework]) + +fi + + dnl gimphwrapbox GIMPHWRAPBOX_MODULES="gtk+-2.0" GIMPHWRAPBOX_CFLAGS="`$PKG_CONFIG --cflags $GIMPHWRAPBOX_MODULES`" @@ -293,7 +340,7 @@ AC_SUBST(LIBNAUTILUS_EXTENSION_LIBS) dnl core nautilus (must list bonobo-activation and libbonobo because idldir does not respect "requires") -CORE_MODULES="eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 esound gnome-desktop-2.0 $EXTRA_CORE_MODULES" +CORE_MODULES="eel-2.0 librsvg-2.0 bonobo-activation-2.0 libbonobo-2.0 esound gnome-desktop-2.0 $MM $EXTRA_CORE_MODULES" CORE_CFLAGS="`$PKG_CONFIG --cflags $CORE_MODULES` $x_cflags" AC_SUBST(CORE_CFLAGS) CORE_LIBS="`$PKG_CONFIG --libs $CORE_MODULES` $CDDA_LIBS $LIBJPEG $x_libs" diff -urN nautilus-2.11.91.org/src/file-manager/fm-icon-view.c nautilus-2.11.91/src/file-manager/fm-icon-view.c --- nautilus-2.11.91.org/src/file-manager/fm-icon-view.c 2005-08-18 18:31:25.411167992 -0500 +++ nautilus-2.11.91/src/file-manager/fm-icon-view.c 2005-08-18 18:45:05.592481480 -0500 @@ -79,8 +79,13 @@ #include #include -#define USE_OLD_AUDIO_PREVIEW 1 -#define READ_CHUNK_SIZE 16384 +#ifdef USE_GST_AUDIO_PREVIEW +#include +#include +#else + #define USE_OLD_AUDIO_PREVIEW 1 + #define READ_CHUNK_SIZE 16384 +#endif #define POPUP_PATH_ICON_APPEARANCE "/selection/Icon Appearance Items" @@ -168,6 +173,10 @@ static int preview_sound_auto_value; static gboolean gnome_esd_enabled_auto_value; +#ifdef USE_GST_AUDIO_PREVIEW +static GstElement *thread; +#endif + #if USE_OLD_AUDIO_PREVIEW static pid_t audio_preview_pid = 0; #endif @@ -1688,6 +1697,22 @@ fm_directory_view_stop_batching_selection_changes (FM_DIRECTORY_VIEW (icon_view)); } +#ifdef USE_GST_AUDIO_PREVIEW +static void +gst_end_of_stream_callback (GstElement *src, gpointer callback_data) +{ + FMIconView *icon_view; + icon_view = FM_ICON_VIEW (callback_data); + + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL); + + if (icon_view->details->audio_preview_timeout != 0 ) { + g_source_remove (icon_view->details->audio_preview_timeout); + icon_view->details->audio_preview_timeout = 0; + } +} +#endif + /* handle the preview signal by inspecting the mime type. For now, we only preview local sound files. */ /* here's the timer task that actually plays the file using mpg123, ogg123 or play. */ @@ -1695,6 +1720,35 @@ static gboolean play_file (gpointer callback_data) { +#ifdef USE_GST_AUDIO_PREVIEW + gchar *file_uri; + GstElement *filesrc, *decoder, *audiosink; + FMIconView *icon_view; + + icon_view = FM_ICON_VIEW (callback_data); + file_uri = nautilus_file_get_uri (icon_view->details->audio_preview_file); + + if (file_uri != NULL && gst_init_check (NULL, NULL)) { + thread = gst_thread_new ("thread"); + filesrc = gst_element_factory_make ("gnomevfssrc", "disk_source"); + decoder = gst_element_factory_make ("spider", "spider"); + audiosink = gst_gconf_get_default_audio_sink (); + + g_object_set (G_OBJECT (filesrc), "location", file_uri, NULL); + g_signal_connect (G_OBJECT (filesrc), "eos", G_CALLBACK (gst_end_of_stream_callback), icon_view); + + gst_bin_add_many (GST_BIN (thread), filesrc, decoder, audiosink, NULL); + gst_element_link_many (filesrc, decoder, audiosink, NULL); + + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_PLAYING); + } + + g_free (file_uri); + + icon_view->details->audio_preview_file = NULL; + icon_view->details->audio_preview_timeout = 0; +#else + #if USE_OLD_AUDIO_PREVIEW NautilusFile *file; FMIconView *icon_view; @@ -1823,6 +1877,7 @@ icon_view->details->audio_preview_timeout = 0; icon_view->details->audio_preview_file = NULL; #endif +#endif /* End USE_GST_AUDIO_PREVIEW */ return FALSE; } @@ -1836,7 +1891,24 @@ static void preview_audio (FMIconView *icon_view, NautilusFile *file, gboolean start_flag) -{ +{ + +#ifdef USE_GST_AUDIO_PREVIEW + if (thread != NULL) { + gst_element_set_state (GST_ELEMENT (thread), GST_STATE_NULL); + } + + if (icon_view->details->audio_preview_timeout != 0) { + g_source_remove (icon_view->details->audio_preview_timeout); + icon_view->details->audio_preview_timeout = 0; + } + + if (start_flag) { + icon_view->details->audio_preview_file = file; + icon_view->details->audio_preview_timeout = g_timeout_add (1000, play_file, icon_view); + } +#else + /* Stop current audio playback */ #if USE_OLD_AUDIO_PREVIEW if (audio_preview_pid > 0) { @@ -1870,11 +1942,13 @@ static gboolean should_preview_sound (NautilusFile *file) { +#ifndef USE_GST_AUDIO_PREVIEW + /* Check gnome config sound preference */ if (!gnome_esd_enabled_auto_value) { return FALSE; } - +#endif /* USE_GST_AUDIO_PREVIEW * /* Check user performance preference */ if (preview_sound_auto_value == NAUTILUS_SPEED_TRADEOFF_NEVER) { return FALSE; @@ -1927,11 +2001,24 @@ mime_type = nautilus_file_get_mime_type (file); if ((eel_istr_has_prefix (mime_type, "audio/") +#ifdef USE_GST_AUDIO_PREVIEW + || eel_istr_has_prefix (mime_type, "application/ogg") + || eel_istr_has_prefix (mime_type, "application/x-ogg") + || eel_istr_has_prefix (mime_type, "application/flac") + || eel_istr_has_prefix (mime_type, "application/x-flac")) + && eel_strcasecmp (mime_type, "audio/x-pn-realaudio") != 0 + && eel_strcasecmp (mime_type, "audio/x-mpegurl") != 0 + ) { +#else + + || eel_istr_has_prefix (mime_type, "application/ogg") || eel_istr_has_prefix (mime_type, "application/x-ogg")) && eel_strcasecmp (mime_type, "audio/x-pn-realaudio") != 0 && eel_strcasecmp (mime_type, "audio/x-mpegurl") != 0 && can_play_sound ()) { + +#endif result = 1; preview_audio (icon_view, file, start_flag); }