[banshee/gst#] gst#: Add ReplayGain support.
- From: Christopher James Halse Rogers <chrishr src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee/gst#] gst#: Add ReplayGain support.
- Date: Thu, 19 May 2011 12:29:07 +0000 (UTC)
commit 8f3c19bff122103fbc03621b297d8eafd8e5cadb
Author: Christopher James Halse Rogers <chrishr src gnome org>
Date: Mon May 16 19:31:54 2011 +1000
gst#: Add ReplayGain support.
.../Banshee.GStreamerSharp/PlayerEngine.cs | 50 +++++++++++++++++++-
1 files changed, 49 insertions(+), 1 deletions(-)
---
diff --git a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/PlayerEngine.cs b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/PlayerEngine.cs
index ceceb5b..070a42f 100644
--- a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/PlayerEngine.cs
+++ b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/PlayerEngine.cs
@@ -57,7 +57,10 @@ namespace Banshee.GStreamerSharp
{
Element hw_audio_sink;
Element volume;
+ Element rgvolume;
Element first;
+ GhostPad visible_sink;
+ object pipeline_lock = new object ();
public AudioSinkBin (string elementName) : base(elementName)
{
@@ -78,7 +81,8 @@ namespace Banshee.GStreamerSharp
first = volume;
}
- AddPad (new GhostPad ("sink", first.GetStaticPad ("sink")));
+ visible_sink = new GhostPad ("sink", first.GetStaticPad ("sink"));
+ AddPad (visible_sink);
}
static Element FindVolumeProvider (Element sink)
@@ -131,6 +135,48 @@ namespace Banshee.GStreamerSharp
return audiosink;
}
+ public bool ReplayGainEnabled {
+ get { return rgvolume != null; }
+ set {
+ if (value && rgvolume == null) {
+ visible_sink.SetBlocked (true, InsertReplayGain);
+ } else if (!value && rgvolume != null) {
+ visible_sink.SetBlocked (false, RemoveReplayGain);
+ }
+ }
+ }
+
+ void InsertReplayGain (Pad pad, bool blocked)
+ {
+ lock (pipeline_lock) {
+ if (rgvolume == null) {
+ rgvolume = ElementFactory.Make ("rgvolume", "rgvolume");
+ Add (rgvolume);
+ rgvolume.SyncStateWithParent ();
+ visible_sink.SetTarget (rgvolume.GetStaticPad ("sink"));
+ rgvolume.Link (first);
+ first = rgvolume;
+ }
+ }
+ visible_sink.SetBlocked (false, (_, __) => { });
+ }
+
+ void RemoveReplayGain (Pad pad, bool blocked)
+ {
+ lock (pipeline_lock) {
+ if (rgvolume != null) {
+ first = rgvolume.GetStaticPad ("src").Peer.Parent as Element;
+ rgvolume.Unlink (first);
+ rgvolume.SetState (State.Null);
+ Remove (rgvolume);
+ rgvolume = null;
+ visible_sink.SetTarget (first.GetStaticPad ("sink"));
+ }
+ }
+ visible_sink.SetBlocked (false, (_, __) => { });
+ }
+
+
public bool VolumeNeedsSaving { get; private set; }
public double Volume {
get {
@@ -183,6 +229,8 @@ namespace Banshee.GStreamerSharp
audio_sink = new AudioSinkBin ("audiobin");
+ audio_sink.ReplayGainEnabled = true;
+
playbin["audio-sink"] = audio_sink;
if (audio_sink.VolumeNeedsSaving) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]