diff --git a/DMX-2.0/AlsaSeqLib.Wrappers.cs b/DMX-2.0/AlsaSeqLib.Wrappers.cs index 8b58480..d0a75f2 100644 --- a/DMX-2.0/AlsaSeqLib.Wrappers.cs +++ b/DMX-2.0/AlsaSeqLib.Wrappers.cs @@ -5,7 +5,7 @@ namespace DMX2 { public static partial class AlsaSeqLib { - class SeqHandleWrapper : IDisposable + sealed class SeqHandleWrapper : IDisposable { IntPtr _seq = IntPtr.Zero; diff --git a/DMX-2.0/Conduite.cs b/DMX-2.0/Conduite.cs index 953a8a6..e0f10d4 100644 --- a/DMX-2.0/Conduite.cs +++ b/DMX-2.0/Conduite.cs @@ -26,7 +26,7 @@ using System.Xml; namespace DMX2 { - public class Conduite : IDisposable + public sealed class Conduite : IDisposable { // Conduite courante diff --git a/DMX-2.0/DMX-2.0.csproj b/DMX-2.0/DMX-2.0.csproj index 9de3483..4b83913 100644 --- a/DMX-2.0/DMX-2.0.csproj +++ b/DMX-2.0/DMX-2.0.csproj @@ -168,6 +168,7 @@ + diff --git a/DMX-2.0/DriverBoitierV1.cs b/DMX-2.0/DriverBoitierV1.cs index a4d340a..b879d0a 100644 --- a/DMX-2.0/DriverBoitierV1.cs +++ b/DMX-2.0/DriverBoitierV1.cs @@ -23,7 +23,7 @@ using System.Xml; namespace DMX2 { - public class DriverBoitierV1 : DriverDMX, IEventProvider + public sealed class DriverBoitierV1 : DriverDMX, IEventProvider { struct buttonState { @@ -210,17 +210,18 @@ namespace DMX2 } } - public override void Dispose () + protected override void Dispose (bool disposing) { disposed = true; etat = etatAutomate.Fin; - if (loopthread != null) { - loopthread.Join (); - loopthread = null; + if (disposing) { + if (loopthread != null) { + loopthread.Join (); + loopthread = null; + } + if (serial != null) + serial.Dispose (); } - if(serial != null) - serial.Dispose(); - } #region implemented abstract members of DMX2.DriverDMX public override Gtk.Widget GetUI () diff --git a/DMX-2.0/DriverBoitierV2.cs b/DMX-2.0/DriverBoitierV2.cs index e67489b..288ba07 100644 --- a/DMX-2.0/DriverBoitierV2.cs +++ b/DMX-2.0/DriverBoitierV2.cs @@ -24,7 +24,7 @@ using System.Collections.Generic; namespace DMX2 { - public class DriverBoitierV2 : DriverDMX, IEventProvider + public sealed class DriverBoitierV2 : DriverDMX, IEventProvider { struct dmxState { @@ -425,17 +425,18 @@ namespace DMX2 } } - public override void Dispose () + protected override void Dispose (bool disposing) { disposed = true; etat = etatAutomate.Fin; - if (loopthread != null) { - loopthread.Join (); - loopthread = null; + if (disposing) { + if (loopthread != null) { + loopthread.Join (); + loopthread = null; + } + if (serial != null) + serial.Dispose (); } - if(serial != null) - serial.Dispose(); - } #region implemented abstract members of DMX2.DriverDMX public override Gtk.Widget GetUI () diff --git a/DMX-2.0/DriverBoitierV3.cs b/DMX-2.0/DriverBoitierV3.cs index c610c5a..5c1d5d2 100644 --- a/DMX-2.0/DriverBoitierV3.cs +++ b/DMX-2.0/DriverBoitierV3.cs @@ -24,7 +24,7 @@ using System.Collections.Generic; namespace DMX2 { - public class DriverBoitierV3 : DriverDMX, IEventProvider + public sealed class DriverBoitierV3 : DriverDMX, IEventProvider { struct dmxState { @@ -479,17 +479,18 @@ namespace DMX2 } } - public override void Dispose () + protected override void Dispose (bool disposing) { disposed = true; etat = etatAutomate.Fin; - if (loopthread != null) { - loopthread.Join (); - loopthread = null; + if (disposing) { + if (loopthread != null) { + loopthread.Join (); + loopthread = null; + } + if (serial != null) + serial.Dispose (); } - if(serial != null) - serial.Dispose(); - } #region implemented abstract members of DMX2.DriverDMX public override Gtk.Widget GetUI () diff --git a/DMX-2.0/DriverDMX.cs b/DMX-2.0/DriverDMX.cs index 815a642..5a2d1e9 100644 --- a/DMX-2.0/DriverDMX.cs +++ b/DMX-2.0/DriverDMX.cs @@ -62,15 +62,15 @@ namespace DMX2 #region IDisposable implementation - public virtual void Dispose() + protected virtual void Dispose(bool disposing) { disposed = true; } - void IDisposable.Dispose () + public void Dispose () { - if(!disposed) - Dispose(); + Dispose (true); + GC.SuppressFinalize(this); } #endregion } diff --git a/DMX-2.0/HelperFunctions.cs b/DMX-2.0/HelperFunctions.cs index 8ae2ede..1ddc729 100644 --- a/DMX-2.0/HelperFunctions.cs +++ b/DMX-2.0/HelperFunctions.cs @@ -32,7 +32,8 @@ namespace DMX2 { text=_text; st= DateTime.Now; - } #region IDisposable implementation + } + #region IDisposable implementation public void Dispose () { Console.WriteLine("{0} -> {1}",text,DateTime.Now - st); diff --git a/DMX-2.0/Main.cs b/DMX-2.0/Main.cs index 8335159..df0520e 100644 --- a/DMX-2.0/Main.cs +++ b/DMX-2.0/Main.cs @@ -27,6 +27,7 @@ namespace DMX2 { bool fullscreen = false; //WebServer ws = null; bool webserv = false; + OSCServer osc = null; bool oscEn=true; System.IO.FileInfo openfile=null; // Traitement des options en ligne de commande : @@ -37,6 +38,9 @@ namespace DMX2 case "fs": fullscreen = true; break; + case "noosc": + oscEn=false; + break; /*case "ws": webserv = true; break; */ @@ -48,6 +52,7 @@ namespace DMX2 } //if(webserv) ws = new WebServer(); + if(oscEn) osc = new OSCServer(); // Initialisation GTK# Application.Init (); @@ -87,6 +92,8 @@ namespace DMX2 } //if(ws!=null) ws.Dispose(); + + if(osc!=null) osc.Dispose(); } static void HandleUnhandledException (GLib.UnhandledExceptionArgs args) diff --git a/DMX-2.0/MidiEventProvider.cs b/DMX-2.0/MidiEventProvider.cs index 5396cdd..583364c 100644 --- a/DMX-2.0/MidiEventProvider.cs +++ b/DMX-2.0/MidiEventProvider.cs @@ -694,7 +694,7 @@ namespace DMX2 if (disposed) return; disposed = true; - AlsaSeqLib.Close (); + AlsaSeqLib.Close(); } #endregion diff --git a/DMX-2.0/OSCServer.cs b/DMX-2.0/OSCServer.cs new file mode 100644 index 0000000..675435c --- /dev/null +++ b/DMX-2.0/OSCServer.cs @@ -0,0 +1,72 @@ +using System; +using System.Net; +using System.Net.Sockets; +using System.Threading; +using System.Collections.Generic; + +namespace DMX2 +{ + public class OSCServer : IDisposable + { + + UdpClient udpCli=null; + Thread pollThread = null; + bool running=true; + + public OSCServer () + { + pollThread = new Thread(new ThreadStart(Loop)); + pollThread.Start(); + } + + void Loop () + { + udpCli = new UdpClient (7772); + byte[] recv; + IPEndPoint remep = new IPEndPoint (IPAddress.Any, 0); + + + try { + while (running) { + recv = udpCli.Receive (ref remep); + } + } catch (SocketException ex) { + } + finally { + } + } + + public void Flush () + { + } + + + #region IDisposable implementation + + + public void Dispose () + { + Dispose(true); + GC.SuppressFinalize(this); + } + + protected virtual void Dispose (bool disposing) + { + if (disposing) { + running=false; + if(udpCli!=null) + udpCli.Close(); + if(pollThread!=null) + { + if(!pollThread.Join(100)) + pollThread.Abort(); + pollThread=null; + } + } + } + + #endregion + + } +} +