This commit is contained in:
tzim 2014-12-04 11:55:15 +00:00
parent c97b7806b0
commit 76f2e55883
11 changed files with 116 additions and 32 deletions

View file

@ -5,7 +5,7 @@ namespace DMX2
{
public static partial class AlsaSeqLib
{
class SeqHandleWrapper : IDisposable
sealed class SeqHandleWrapper : IDisposable
{
IntPtr _seq = IntPtr.Zero;

View file

@ -26,7 +26,7 @@ using System.Xml;
namespace DMX2
{
public class Conduite : IDisposable
public sealed class Conduite : IDisposable
{
// Conduite courante

View file

@ -168,6 +168,7 @@
<Compile Include="SequenceurSon.cs" />
<Compile Include="SeqSonUI.cs" />
<Compile Include="gtk-gui\DMX2.SeqSonUI.cs" />
<Compile Include="OSCServer.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ProjectExtensions>

View file

@ -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 (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 ()

View file

@ -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 (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 ()

View file

@ -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 (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 ()

View file

@ -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
}

View file

@ -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);

View file

@ -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)

View file

@ -694,7 +694,7 @@ namespace DMX2
if (disposed)
return;
disposed = true;
AlsaSeqLib.Close ();
AlsaSeqLib.Close();
}
#endregion

72
DMX-2.0/OSCServer.cs Normal file
View file

@ -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
}
}