[banshee/gapless-ng] [libbanshee, Banshee.GStreamer] Remove #ifdef's from managed code.
- From: Christopher James Halse Rogers <chrishr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gapless-ng] [libbanshee, Banshee.GStreamer] Remove #ifdef's from managed code.
- Date: Tue, 9 Mar 2010 10:42:39 +0000 (UTC)
commit cf21dcc29e0d0bcac1a7b45036b332a5b6917d48
Author: Christopher James Halse Rogers <chrishr src gnome org>
Date: Tue Mar 9 21:40:43 2010 +1100
[libbanshee, Banshee.GStreamer] Remove #ifdef's from managed code.
Add a bp_supports_gapless function to libbanshee, and use it in the managed code
to do runtime detection.
libbanshee/banshee-player.c | 10 ++++
.../Banshee.GStreamer/PlayerEngine.cs | 48 +++++++++-----------
2 files changed, 31 insertions(+), 27 deletions(-)
---
diff --git a/libbanshee/banshee-player.c b/libbanshee/banshee-player.c
index fe47eb5..2c0cfb0 100644
--- a/libbanshee/banshee-player.c
+++ b/libbanshee/banshee-player.c
@@ -283,6 +283,16 @@ bp_can_seek (BansheePlayer *player)
return can_seek && bp_get_duration (player) > 0;
}
+P_INVOKE gboolean
+bp_supports_gapless (BansheePlayer *player)
+{
+#ifdef ENABLE_GAPLESS
+ return TRUE;
+#else
+ return FALSE;
+#endif //ENABLE_GAPLESS
+}
+
P_INVOKE void
bp_set_volume (BansheePlayer *player, gdouble volume)
{
diff --git a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
index 61d95c8..2b25e23 100644
--- a/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
+++ b/src/Backends/Banshee.GStreamer/Banshee.GStreamer/PlayerEngine.cs
@@ -86,9 +86,7 @@ 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 next_track_pending;
private SafeUri pending_uri;
@@ -97,9 +95,7 @@ namespace Banshee.GStreamer
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;
@@ -154,9 +150,7 @@ 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);
@@ -314,7 +308,6 @@ namespace Banshee.GStreamer
}
}
-#if ENABLE_GAPLESS
private void OnAboutToFinish (IntPtr player)
{
// This is needed to make Shuffle-by-* work.
@@ -339,7 +332,6 @@ namespace Banshee.GStreamer
next_track_set.Set ();
}
}
-#endif
private void OnIterate (IntPtr player)
{
@@ -599,21 +591,20 @@ namespace Banshee.GStreamer
}
private bool GaplessEnabled {
-#if ENABLE_GAPLESS
get { return gapless_enabled; }
set
{
- gapless_enabled = value;
- if (value) {
- bp_set_about_to_finish_callback (handle, about_to_finish_callback);
+ if (bp_supports_gapless (handle)) {
+ gapless_enabled = value;
+ if (value) {
+ bp_set_about_to_finish_callback (handle, about_to_finish_callback);
+ } else {
+ bp_set_about_to_finish_callback (handle, null);
+ }
} else {
- bp_set_about_to_finish_callback (handle, null);
+ gapless_enabled = false;
}
}
-#else
- get {return false;}
- set {}
-#endif
}
@@ -686,13 +677,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
+ if (bp_supports_gapless (handle)) {
+ 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 (); }
+ ));
+ }
}
private void UninstallPreferences ()
@@ -703,7 +694,9 @@ namespace Banshee.GStreamer
}
service["general"]["misc"].Remove (replaygain_preference);
- service["general"]["misc"].Remove (gapless_preference);
+ if (bp_supports_gapless (handle)) {
+ service["general"]["misc"].Remove (gapless_preference);
+ }
replaygain_preference = null;
gapless_preference = null;
}
@@ -767,11 +760,12 @@ 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_supports_gapless (HandleRef player);
[DllImport ("libbanshee.dll")]
private static extern bool bp_open (HandleRef player, IntPtr uri);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]