[banshee/gapless-ng: 824/836] Make gapless playback a build-time option.



commit 6d010371906b56d3bf86fa5aaac7f05c6d1d419f
Author: Christopher James Halse Rogers <raof ubuntu com>
Date:   Fri Feb 5 14:56:18 2010 +1100

    Make gapless playback a build-time option.
    
    It is enabled by default if you have a new-enough playbin2 (from gst-plugins-base > 0.10.25.2).

 configure.ac                                       |   16 ++++++++++++++++
 libbanshee/Makefile.am                             |    4 ++++
 libbanshee/banshee-player-pipeline.c               |   11 +++++++++--
 .../Banshee.GStreamer/PlayerEngine.cs              |   18 +++++++++++++++++-
 src/Backends/Banshee.GStreamer/Makefile.am         |    4 ++++
 5 files changed, 50 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index a07e7e4..590cdab 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,6 +153,21 @@ BANSHEE_CHECK_TORRENT
 dnl Moblin integration (optional)
 BANSHEE_CHECK_MOBLIN
 
+dnl Gapless, if we have a new-enough playbin2
+ENABLE_GAPLESS="no"
+AC_ARG_ENABLE(gapless-playback,
+	AC_HELP_STRING([--enable-gapless-playback],
+		[Enable gapless playback engine (requires gst-plugins-base > 0.10.25.2)]),
+		enable_gapless=$enableval,
+		enable_gapless=auto)
+if test "x$enable_gapless" != "xno" ; then
+   	PKG_CHECK_MODULES([GST_PLUGINS_BASE], [gstreamer-plugins-base-0.10 > 0.10.25.2], ENABLE_GAPLESS=yes, ENABLE_GAPLESS=no)
+   	if test "x$enable_gapless" == "xyes" -a "x$ENABLE_GAPLESS" == "xno" ; then
+	   	AC_MSG_ERROR([Gapless playback requires gstreamer-plugins-base > 0.10.25.2])
+	fi
+fi
+AM_CONDITIONAL(ENABLE_GAPLESS, test "x$ENABLE_GAPLESS" = "xyes")   
+
 dnl i18n
 SHAMROCK_CONFIGURE_I18N($PACKAGE)
 
@@ -347,6 +362,7 @@ ${PACKAGE}-${VERSION}
     Library Watcher:   ${HAVE_MONO_2_4_3} (requires Mono >= 2.4.3)
     Podcasts:          ${enable_podcast}
     Wikipedia:         ${enable_webkit} (requires webkit-sharp)
+    Gapless playback:  ${ENABLE_GAPLESS} (requires gstreamer-plugins-base > 0.10.25.2)
 
   Build/Development:
     Unit Tests:        ${do_tests} (requires nunit >= ${NUNIT_REQUIRED})
diff --git a/libbanshee/Makefile.am b/libbanshee/Makefile.am
index a35eeb3..415b329 100644
--- a/libbanshee/Makefile.am
+++ b/libbanshee/Makefile.am
@@ -6,6 +6,10 @@ INCLUDES = \
 	$(LIBBANSHEE_CFLAGS) \
 	$(GST_CFLAGS) 
 
+if ENABLE_GAPLESS
+INCLUDES += -DENABLE_GAPLESS
+endif
+
 bansheelibdir = $(pkglibdir)
 bansheelib_LTLIBRARIES = libbanshee.la
 
diff --git a/libbanshee/banshee-player-pipeline.c b/libbanshee/banshee-player-pipeline.c
index e9b89c8..568a49d 100644
--- a/libbanshee/banshee-player-pipeline.c
+++ b/libbanshee/banshee-player-pipeline.c
@@ -188,6 +188,7 @@ bp_pipeline_bus_callback (GstBus *bus, GstMessage *message, gpointer userdata)
     return TRUE;
 }
 
+#ifdef ENABLE_GAPLESS
 static void bp_about_to_finish_callback (GstElement *playbin, BansheePlayer *player)
 {
     g_return_if_fail (IS_BANSHEE_PLAYER (player));
@@ -196,6 +197,7 @@ static void bp_about_to_finish_callback (GstElement *playbin, BansheePlayer *pla
         player->about_to_finish_cb (player);
     }
 }
+#endif //ENABLE_GAPLESS
 
 // ---------------------------------------------------------------------------
 // Internal Functions
@@ -215,12 +217,17 @@ _bp_pipeline_construct (BansheePlayer *player)
     
     // Playbin is the core element that handles autoplugging (finding the right
     // source and decoder elements) based on source URI and stream content
+#ifdef ENABLE_GAPLESS
     player->playbin = gst_element_factory_make ("playbin2", "playbin");
-    g_return_val_if_fail (player->playbin != NULL, FALSE);
-    
+
     // Connect a proxy about-to-finish callback that will generate a next-track-starting callback.
     // This can be removed once playbin2 generates its own next-track signal.
     g_signal_connect (player->playbin, "about-to-finish", G_CALLBACK (bp_about_to_finish_callback), player);
+#else //ENABLE_GAPLESS
+    player->playbin = gst_element_factory_make ("playbin", "playbin");
+#endif //ENABLE_GAPLESS
+
+    g_return_val_if_fail (player->playbin != NULL, FALSE);
 
     // Try to find an audio sink, prefer gconf, which typically is set to auto these days,
     // fall back on auto, which should work on windows, and as a last ditch, try alsa
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
index 689bcc4..a9e27c8 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
@@ -86,13 +86,17 @@ namespace Banshee.GStreamer
         private VideoPipelineSetupHandler video_pipeline_setup_callback;
         private GstTaggerTagFoundCallback tag_found_callback;
         private BansheePlayerNextTrackStartingCallback next_track_starting_callback;
+#if ENABLE_GAPLESS
         private BansheePlayerAboutToFinishCallback about_to_finish_callback;
+#endif
 
         private bool buffering_finished;
         private int pending_volume = -1;
         private bool xid_is_set = false;
 
+#if ENABLE_GAPLESS
         private bool gapless_enabled;
+#endif
         private EventWaitHandle next_track_set;
 
         private event VisualizationDataHandler data_available = null;
@@ -147,8 +151,9 @@ namespace Banshee.GStreamer
             video_pipeline_setup_callback = new VideoPipelineSetupHandler (OnVideoPipelineSetup);
             tag_found_callback = new GstTaggerTagFoundCallback (OnTagFound);
             next_track_starting_callback = new BansheePlayerNextTrackStartingCallback (OnNextTrackStarting);
+#if ENABLE_GAPLESS
             about_to_finish_callback = new BansheePlayerAboutToFinishCallback (OnAboutToFinish);
-
+#endif
             bp_set_eos_callback (handle, eos_callback);
 #if !WIN32
             bp_set_iterate_callback (handle, iterate_callback);
@@ -278,6 +283,7 @@ namespace Banshee.GStreamer
             }
         }
 
+#if ENABLE_GAPLESS
         private void OnAboutToFinish (IntPtr player)
         {
             // This is needed to make Shuffle-by-* work.
@@ -297,6 +303,7 @@ namespace Banshee.GStreamer
                 Log.Debug ("[Gapless] Timed out while waiting for next_track_set to be raised");
             }
         }
+#endif
 
         private void OnIterate (IntPtr player)
         {
@@ -556,6 +563,7 @@ namespace Banshee.GStreamer
         }
 
         private bool GaplessEnabled {
+#if ENABLE_GAPLESS
             get { return gapless_enabled; }
             set
             {
@@ -566,6 +574,10 @@ namespace Banshee.GStreamer
                     bp_set_about_to_finish_callback (handle, null);
                 }
             }
+#else
+            get {return false;}
+            set {}
+#endif
         }
 
 
@@ -638,11 +650,13 @@ namespace Banshee.GStreamer
                 Catalog.GetString ("For tracks that have ReplayGain data, automatically scale (normalize) playback volume"),
                 delegate { ReplayGainEnabled = ReplayGainEnabledSchema.Get (); }
             ));
+#if ENABLE_GAPLESS
             gapless_preference = service["general"]["misc"].Add (new SchemaPreference<bool> (GaplessEnabledSchema,
                 Catalog.GetString ("Enable _gapless playback"),
                 Catalog.GetString ("Eliminate the small playback gap on track change.  Useful for concept albums and classical music."),
                 delegate { GaplessEnabled = GaplessEnabledSchema.Get (); }
             ));
+#endif
         }
 
         private void UninstallPreferences ()
@@ -717,9 +731,11 @@ namespace Banshee.GStreamer
         private static extern void bp_set_next_track_starting_callback (HandleRef player,
             BansheePlayerNextTrackStartingCallback cb);
 
+#if ENABLE_GAPLESS
         [DllImport ("libbanshee.dll")]
         private static extern void bp_set_about_to_finish_callback (HandleRef player,
             BansheePlayerAboutToFinishCallback cb);
+#endif
 
         [DllImport ("libbanshee.dll")]
         private static extern bool bp_open (HandleRef player, IntPtr uri);
diff --git a/src/Backends/Banshee.GStreamer/Makefile.am b/src/Backends/Banshee.GStreamer/Makefile.am
index 321b270..118e525 100644
--- a/src/Backends/Banshee.GStreamer/Makefile.am
+++ b/src/Backends/Banshee.GStreamer/Makefile.am
@@ -16,3 +16,7 @@ include $(top_srcdir)/build/build.mk
 
 EXTRA_DIST += Banshee.GStreamer.dll.config
 module_SCRIPTS += Banshee.GStreamer.dll.config
+
+if ENABLE_GAPLESS
+BUILD_DEFINES="-define:ENABLE_GAPLESS"
+endif
\ No newline at end of file



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