[banshee] GStreamerSharp: protect call to event delegates
- From: Andrés Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] GStreamerSharp: protect call to event delegates
- Date: Wed, 30 Oct 2013 12:16:00 +0000 (UTC)
commit e26ae39dfb6ee1559ccc0e40606e9449e909bce3
Author: Andrés G. Aragoneses <knocte gmail com>
Date: Wed Oct 30 13:15:49 2013 +0100
GStreamerSharp: protect call to event delegates
This is a good practice to avoid potential race conditions, that
is already used in other events, and is best explained in:
http://www.mono-project.com/Gendarme.Rules.Concurrency#ProtectCallToEventDelegatesRule
or
https://github.com/spouliot/gendarme/wiki/Gendarme.Rules.Concurrency.ProtectCallToEventDelegatesRule%282.10%29
.../Banshee.GStreamerSharp/VideoManager.cs | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
---
diff --git a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
index 64cfb30..bfbdb45 100644
--- a/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
+++ b/src/Backends/Banshee.GStreamerSharp/Banshee.GStreamerSharp/VideoManager.cs
@@ -83,10 +83,17 @@ namespace Banshee.GStreamerSharp
playbin.Bus.SyncMessage += OnSyncMessage;
//if (videosink is Bin) { ((Bin)videosink).ElementAdded += OnVideoSinkElementAdded; }
- if (PrepareWindow != null) {
- PrepareWindow ();
+ RaisePrepareWindow ();
+ }
+
+ private void RaisePrepareWindow ()
+ {
+ var handler = PrepareWindow;
+ if (handler != null) {
+ handler ();
}
}
+
public delegate void PrepareWindowHandler ();
public event PrepareWindowHandler PrepareWindow;
@@ -225,8 +232,10 @@ namespace Banshee.GStreamerSharp
private void RaiseVideoGeometry (int width, int height, int fps_n, int fps_d, int par_n, int par_d)
{
- if (VideoGeometry != null)
- VideoGeometry (width, height, fps_n, fps_d, par_n, par_d);
+ var handler = VideoGeometry;
+ if (handler != null) {
+ handler (width, height, fps_n, fps_d, par_n, par_d);
+ }
}
public void WindowExpose (IntPtr window, bool direct)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]