@@ -29,19 +29,25 @@ public abstract class ZeDMDBase
2929
3030 protected void LogHandler ( string format , IntPtr args , IntPtr pUserData )
3131 {
32+ #if PLATFORM_X64
3233 Logger . Debug ( "Trying to convert libzedmd log message: " + format ) ;
3334 Logger . Info ( "libzedmd: " + Marshal . PtrToStringAnsi ( ZeDMD_FormatLogMessage ( format , args , pUserData ) ) ) ;
35+ #endif
3436 }
3537
3638 protected void Init ( )
3739 {
3840 _pZeDMD = ZeDMD_GetInstance ( ) ;
3941 Logger . Info ( "Using libzedmd version " + DriverVersion ) ;
4042
43+ #if PLATFORM_X64
4144 ZeDMD_LogCallback callbackDelegate = new ZeDMD_LogCallback ( LogHandler ) ;
4245 // Keep a reference to the delegate to prevent GC from collecting it
4346 handle = GCHandle . Alloc ( callbackDelegate ) ;
4447 ZeDMD_SetLogCallback ( _pZeDMD , callbackDelegate , IntPtr . Zero ) ;
48+ #else
49+ Logger . Warn ( "Forwarding libzedmd and libserialport logging is not working on x86." ) ;
50+ #endif
4551 }
4652
4753 protected void SendConfiguration ( )
@@ -70,6 +76,10 @@ public void Dispose()
7076 }
7177 IsAvailable = false ;
7278 }
79+
80+ if ( handle . IsAllocated ) {
81+ handle . Free ( ) ;
82+ }
7383 }
7484
7585 public void RenderRgb24 ( DmdFrame frame )
@@ -112,25 +122,18 @@ public void ClearColor()
112122 [ DllImport ( "zedmd64.dll" , CharSet = CharSet . Ansi , CallingConvention = CallingConvention . Cdecl ) ]
113123#else
114124 [ DllImport ( "zedmd.dll" , CharSet = CharSet . Ansi , CallingConvention = CallingConvention . Cdecl ) ]
115- #endif
116125 protected static extern IntPtr ZeDMD_GetInstance ( ) ;
117126
127+ #if PLATFORM_X64
118128 [ UnmanagedFunctionPointer ( CallingConvention . Cdecl ) ]
119129 protected delegate void ZeDMD_LogCallback ( string format , IntPtr args , IntPtr pUserData ) ;
120130
121- #if PLATFORM_X64
122131 [ DllImport ( "zedmd64.dll" , CharSet = CharSet . Ansi , CallingConvention = CallingConvention . Cdecl ) ]
123- #else
124- [ DllImport ( "zedmd.dll" , CharSet = CharSet . Ansi , CallingConvention = CallingConvention . Cdecl ) ]
125- #endif
126132 protected static extern void ZeDMD_SetLogCallback ( IntPtr pZeDMD , ZeDMD_LogCallback callback , IntPtr pUserData ) ;
127133
128- #if PLATFORM_X64
129134 [ DllImport ( "zedmd64.dll" , CharSet = CharSet . Ansi , CallingConvention = CallingConvention . Cdecl ) ]
130- #else
131- [ DllImport ( "zedmd.dll" , CharSet = CharSet . Ansi , CallingConvention = CallingConvention . Cdecl ) ]
132- #endif
133135 protected static extern IntPtr ZeDMD_FormatLogMessage ( string format , IntPtr args , IntPtr pUserData ) ;
136+ #endif
134137
135138#if PLATFORM_X64
136139 [ DllImport ( "zedmd64.dll" , CharSet = CharSet . Ansi , CallingConvention = CallingConvention . Cdecl ) ]
0 commit comments