com.shinolab.autd3-sdk 0.6.1 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Client.cs CHANGED
@@ -103,18 +103,21 @@ namespace AUTD3
103
103
 
104
104
  public sealed class Checker : IDisposable
105
105
  {
106
- private IntPtr _handle;
106
+ private readonly CheckerHandle _handle;
107
107
 
108
108
  internal Checker(IntPtr handle)
109
109
  {
110
- _handle = handle;
110
+ _handle = new CheckerHandle(handle);
111
111
  }
112
112
 
113
- public async Task<LinkStatus> CheckAsync()
113
+ public LinkStatus Check()
114
114
  {
115
- var handle = _handle;
116
- var status = await AsyncOps.InvokeAsync((cb, ud) =>
117
- NativeClient.autd3_checker_check(handle, cb, ud)).ConfigureAwait(false);
115
+ var err = new byte[NativeAbi.ErrorBufferLength];
116
+ var status = NativeClient.autd3_checker_check(_handle, err, (UIntPtr)err.Length);
117
+ if (status == IntPtr.Zero)
118
+ {
119
+ throw new Autd3Exception(NativeUtil.Utf8(err));
120
+ }
118
121
  try
119
122
  {
120
123
  var count = (int)NativeClient.autd3_link_status_num_devices(status);
@@ -135,24 +138,7 @@ namespace AUTD3
135
138
  }
136
139
  }
137
140
 
138
- public void Dispose()
139
- {
140
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
141
- if (handle != IntPtr.Zero)
142
- {
143
- NativeClient.autd3_checker_free(handle);
144
- }
145
- GC.SuppressFinalize(this);
146
- }
147
-
148
- ~Checker()
149
- {
150
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
151
- if (handle != IntPtr.Zero)
152
- {
153
- NativeClient.autd3_checker_free(handle);
154
- }
155
- }
141
+ public void Dispose() => _handle.Dispose();
156
142
  }
157
143
 
158
144
  public sealed class Response
@@ -220,19 +206,18 @@ namespace AUTD3
220
206
  }
221
207
  }
222
208
 
223
- public sealed class Client : IDisposable
209
+ public sealed class Client : IDisposable, IAsyncDisposable
224
210
  {
225
211
  public const int MaxInflight = 127;
226
212
 
227
- private IntPtr _handle;
228
-
229
- internal IntPtr Handle => _handle;
230
-
213
+ private readonly ClientHandle _handle;
231
214
  private readonly Geometry _geometry;
232
215
 
233
- private Client(IntPtr handle, Geometry geometry)
216
+ internal ClientHandle Handle => _handle;
217
+
218
+ internal Client(IntPtr handle, Geometry geometry)
234
219
  {
235
- _handle = handle;
220
+ _handle = new ClientHandle(handle);
236
221
  _geometry = geometry;
237
222
  }
238
223
 
@@ -279,10 +264,9 @@ namespace AUTD3
279
264
 
280
265
  public int NumDevices => (int)NativeClient.autd3_client_num_devices(Handle);
281
266
 
267
+ public Geometry Geometry => _geometry;
282
268
 
283
- public DatagramBuilder DatagramBuilder() => new DatagramBuilder(_geometry, Handle);
284
-
285
-
269
+ public DatagramBuilder DatagramBuilder() => new DatagramBuilder(_geometry, this);
286
270
 
287
271
  public Task SendCheckedAsync(Frame frame) =>
288
272
  AsyncOps.InvokeAsync((cb, ud) =>
@@ -360,20 +344,33 @@ namespace AUTD3
360
344
 
361
345
  public void Dispose()
362
346
  {
363
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
364
- if (handle != IntPtr.Zero)
347
+ if (_handle.IsClosed)
365
348
  {
366
- NativeClient.autd3_client_free(handle);
349
+ return;
350
+ }
351
+ try
352
+ {
353
+ CloseAsync().GetAwaiter().GetResult();
354
+ }
355
+ finally
356
+ {
357
+ _handle.Dispose();
367
358
  }
368
- GC.SuppressFinalize(this);
369
359
  }
370
360
 
371
- ~Client()
361
+ public async ValueTask DisposeAsync()
372
362
  {
373
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
374
- if (handle != IntPtr.Zero)
363
+ if (_handle.IsClosed)
364
+ {
365
+ return;
366
+ }
367
+ try
368
+ {
369
+ await CloseAsync().ConfigureAwait(false);
370
+ }
371
+ finally
375
372
  {
376
- NativeClient.autd3_client_free(handle);
373
+ _handle.Dispose();
377
374
  }
378
375
  }
379
376
  }
package/Commands.cs CHANGED
@@ -16,53 +16,53 @@ namespace AUTD3
16
16
 
17
17
  static NativeCommand() => NativeAbi.Verify(Lib, autd3_abi_version());
18
18
 
19
- [DllImport(Lib)]
19
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
20
20
  private static extern uint autd3_abi_version();
21
21
 
22
- [DllImport(Lib)]
22
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
23
23
  internal static extern IntPtr autd3_op_clear();
24
24
 
25
- [DllImport(Lib)]
25
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
26
26
  internal static extern IntPtr autd3_op_synchronize();
27
27
 
28
- [DllImport(Lib)]
28
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
29
29
  internal static extern IntPtr autd3_op_nop();
30
30
 
31
- [DllImport(Lib)]
31
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
32
32
  internal static extern IntPtr autd3_op_force_fan([MarshalAs(UnmanagedType.I1)] bool value);
33
33
 
34
- [DllImport(Lib)]
34
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
35
35
  internal static extern IntPtr autd3_op_set_silencer_completion_time(ulong intensityNs, ulong phaseNs, [MarshalAs(UnmanagedType.I1)] bool strict);
36
36
 
37
- [DllImport(Lib)]
37
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
38
38
  internal static extern IntPtr autd3_op_set_silencer_update_rate(ushort intensity, ushort phase);
39
39
 
40
- [DllImport(Lib)]
40
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
41
41
  internal static extern IntPtr autd3_op_set_silencer_disable();
42
42
 
43
- [DllImport(Lib)]
43
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
44
44
  internal static extern IntPtr autd3_op_set_gpio_out(GpioOutNative[] outputs);
45
45
 
46
- [DllImport(Lib)]
46
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
47
47
  internal static extern IntPtr autd3_op_emulate_gpio_in(byte[] values);
48
48
 
49
- [DllImport(Lib)]
49
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
50
50
  internal static extern IntPtr autd3_op_set_output_mask(byte[] masks, UIntPtr[] lens, UIntPtr numDevices);
51
51
 
52
- [DllImport(Lib)]
52
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
53
53
  internal static extern IntPtr autd3_op_set_phase_correction(byte[] phases, UIntPtr[] lens, UIntPtr numDevices);
54
54
 
55
- [DllImport(Lib)]
55
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
56
56
  internal static extern IntPtr autd3_op_set_pulse_width_table(ushort[] table);
57
57
 
58
- [DllImport(Lib)]
58
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
59
59
  internal static extern void autd3_set_pulse_width_table_default_table([Out] ushort[] outTable);
60
60
 
61
- [DllImport(Lib)]
61
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
62
62
  [return: MarshalAs(UnmanagedType.I1)]
63
63
  internal static extern bool autd3_pulse_width_from_duty(float duty, [Out] ushort[] outValue);
64
64
 
65
- [DllImport(Lib)]
65
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
66
66
  [return: MarshalAs(UnmanagedType.I1)]
67
67
  internal static extern bool autd3_pulse_width_new(ushort pulseWidth, [Out] ushort[] outValue);
68
68
  }
@@ -136,7 +136,6 @@ namespace AUTD3
136
136
 
137
137
  public FixedCompletionTime(TimeSpan? intensity = null, TimeSpan? phase = null, bool strictMode = true)
138
138
  {
139
- // defaults: intensity = 25us * 10 = 250us, phase = 25us * 40 = 1000us
140
139
  Intensity = intensity ?? TimeSpan.FromTicks(2500);
141
140
  Phase = phase ?? TimeSpan.FromTicks(10000);
142
141
  StrictMode = strictMode;
package/Datagram.cs CHANGED
@@ -1,5 +1,4 @@
1
1
  using System;
2
- using System.Threading;
3
2
  using System.Collections;
4
3
  using System.Collections.Generic;
5
4
 
@@ -117,26 +116,27 @@ namespace AUTD3
117
116
  {
118
117
  private readonly Geometry _geometry;
119
118
  private readonly int _numDevices;
120
- private readonly IntPtr _client;
119
+ private readonly Client? _client;
121
120
 
122
- private IntPtr _handle;
121
+ private readonly DatagramBuilderHandle _handle;
123
122
 
124
- internal IntPtr Handle => _handle;
123
+ internal DatagramBuilderHandle Handle => _handle;
125
124
 
126
- public DatagramBuilder(Geometry geometry) : this(geometry, IntPtr.Zero)
125
+ public DatagramBuilder(Geometry geometry) : this(geometry, null)
127
126
  {
128
127
  }
129
128
 
130
- internal DatagramBuilder(Geometry geometry, IntPtr client)
129
+ internal DatagramBuilder(Geometry geometry, Client? client)
131
130
  {
132
131
  _geometry = geometry;
133
132
  _numDevices = geometry.NumDevices;
134
133
  _client = client;
135
- _handle = NativeClient.autd3_datagram_builder_new(geometry.Handle);
136
- if (Handle == IntPtr.Zero)
134
+ var handle = NativeClient.autd3_datagram_builder_new(geometry.Handle);
135
+ if (handle == IntPtr.Zero)
137
136
  {
138
137
  throw new Autd3Exception("failed to create datagram builder");
139
138
  }
139
+ _handle = new DatagramBuilderHandle(handle);
140
140
  }
141
141
 
142
142
  public DatagramBuilder Push(ICommand command)
@@ -181,7 +181,8 @@ namespace AUTD3
181
181
  public Frames Build()
182
182
  {
183
183
  var err = new byte[NativeAbi.ErrorBufferLength];
184
- var handle = NativeClient.autd3_datagram_builder_build(Handle, _client, err, (UIntPtr)err.Length);
184
+ using var client = new HandleLease(_client?.Handle);
185
+ var handle = NativeClient.autd3_datagram_builder_build(Handle, client.Pointer, err, (UIntPtr)err.Length);
185
186
  if (handle == IntPtr.Zero)
186
187
  {
187
188
  throw new Autd3Exception(NativeUtil.Utf8(err));
@@ -189,24 +190,7 @@ namespace AUTD3
189
190
  return new Frames(handle);
190
191
  }
191
192
 
192
- public void Dispose()
193
- {
194
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
195
- if (handle != IntPtr.Zero)
196
- {
197
- NativeClient.autd3_datagram_builder_free(handle);
198
- }
199
- GC.SuppressFinalize(this);
200
- }
201
-
202
- ~DatagramBuilder()
203
- {
204
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
205
- if (handle != IntPtr.Zero)
206
- {
207
- NativeClient.autd3_datagram_builder_free(handle);
208
- }
209
- }
193
+ public void Dispose() => _handle.Dispose();
210
194
  }
211
195
 
212
196
 
@@ -224,13 +208,13 @@ namespace AUTD3
224
208
 
225
209
  public sealed class Frames : IDisposable, IEnumerable<Frame>
226
210
  {
227
- private IntPtr _handle;
211
+ private readonly FramesHandle _handle;
228
212
 
229
- internal IntPtr Handle => _handle;
213
+ internal FramesHandle Handle => _handle;
230
214
 
231
215
  internal Frames(IntPtr handle)
232
216
  {
233
- _handle = handle;
217
+ _handle = new FramesHandle(handle);
234
218
  }
235
219
 
236
220
  public int Length => (int)NativeClient.autd3_datagrams_num_frames(Handle);
@@ -258,23 +242,6 @@ namespace AUTD3
258
242
 
259
243
  IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
260
244
 
261
- public void Dispose()
262
- {
263
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
264
- if (handle != IntPtr.Zero)
265
- {
266
- NativeClient.autd3_datagrams_free(handle);
267
- }
268
- GC.SuppressFinalize(this);
269
- }
270
-
271
- ~Frames()
272
- {
273
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
274
- if (handle != IntPtr.Zero)
275
- {
276
- NativeClient.autd3_datagrams_free(handle);
277
- }
278
- }
245
+ public void Dispose() => _handle.Dispose();
279
246
  }
280
247
  }
package/Legacy.cs CHANGED
@@ -1,5 +1,4 @@
1
1
  using System;
2
- using System.Threading;
3
2
  using System.Collections;
4
3
  using System.Collections.Generic;
5
4
  using System.Threading.Tasks;
@@ -96,26 +95,27 @@ namespace AUTD3.Legacy
96
95
  {
97
96
  private readonly Geometry _geometry;
98
97
  private readonly int _numDevices;
99
- private readonly IntPtr _client;
98
+ private readonly LegacyClient? _client;
100
99
 
101
- private IntPtr _handle;
100
+ private readonly LegacyDatagramBuilderHandle _handle;
102
101
 
103
- internal IntPtr Handle => _handle;
102
+ internal LegacyDatagramBuilderHandle Handle => _handle;
104
103
 
105
- public LegacyDatagramBuilder(Geometry geometry) : this(geometry, IntPtr.Zero)
104
+ public LegacyDatagramBuilder(Geometry geometry) : this(geometry, null)
106
105
  {
107
106
  }
108
107
 
109
- internal LegacyDatagramBuilder(Geometry geometry, IntPtr client)
108
+ internal LegacyDatagramBuilder(Geometry geometry, LegacyClient? client)
110
109
  {
111
110
  _geometry = geometry;
112
111
  _numDevices = geometry.NumDevices;
113
112
  _client = client;
114
- _handle = NativeLegacyClient.autd3_legacy_datagram_builder_new(geometry.Handle);
115
- if (Handle == IntPtr.Zero)
113
+ var handle = NativeLegacyClient.autd3_legacy_datagram_builder_new(geometry.Handle);
114
+ if (handle == IntPtr.Zero)
116
115
  {
117
116
  throw new Autd3Exception("failed to create legacy datagram builder");
118
117
  }
118
+ _handle = new LegacyDatagramBuilderHandle(handle);
119
119
  }
120
120
 
121
121
  public LegacyDatagramBuilder Push(ICommand command)
@@ -170,7 +170,8 @@ namespace AUTD3.Legacy
170
170
  public LegacyFrames Build()
171
171
  {
172
172
  var err = new byte[NativeAbi.ErrorBufferLength];
173
- var handle = NativeLegacyClient.autd3_legacy_datagram_builder_build(Handle, _client, err, (UIntPtr)err.Length);
173
+ using var client = new HandleLease(_client?.Handle);
174
+ var handle = NativeLegacyClient.autd3_legacy_datagram_builder_build(Handle, client.Pointer, err, (UIntPtr)err.Length);
174
175
  if (handle == IntPtr.Zero)
175
176
  {
176
177
  throw new Autd3Exception(NativeUtil.Utf8(err));
@@ -178,24 +179,7 @@ namespace AUTD3.Legacy
178
179
  return new LegacyFrames(handle);
179
180
  }
180
181
 
181
- public void Dispose()
182
- {
183
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
184
- if (handle != IntPtr.Zero)
185
- {
186
- NativeLegacyClient.autd3_legacy_datagram_builder_free(handle);
187
- }
188
- GC.SuppressFinalize(this);
189
- }
190
-
191
- ~LegacyDatagramBuilder()
192
- {
193
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
194
- if (handle != IntPtr.Zero)
195
- {
196
- NativeLegacyClient.autd3_legacy_datagram_builder_free(handle);
197
- }
198
- }
182
+ public void Dispose() => _handle.Dispose();
199
183
  }
200
184
 
201
185
  public readonly struct LegacyFrame
@@ -212,13 +196,13 @@ namespace AUTD3.Legacy
212
196
 
213
197
  public sealed class LegacyFrames : IDisposable, IEnumerable<LegacyFrame>
214
198
  {
215
- private IntPtr _handle;
199
+ private readonly LegacyFramesHandle _handle;
216
200
 
217
- internal IntPtr Handle => _handle;
201
+ internal LegacyFramesHandle Handle => _handle;
218
202
 
219
203
  internal LegacyFrames(IntPtr handle)
220
204
  {
221
- _handle = handle;
205
+ _handle = new LegacyFramesHandle(handle);
222
206
  }
223
207
 
224
208
  public int Length => (int)NativeLegacyClient.autd3_legacy_frames_num_frames(Handle);
@@ -246,37 +230,19 @@ namespace AUTD3.Legacy
246
230
 
247
231
  IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
248
232
 
249
- public void Dispose()
250
- {
251
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
252
- if (handle != IntPtr.Zero)
253
- {
254
- NativeLegacyClient.autd3_legacy_frames_free(handle);
255
- }
256
- GC.SuppressFinalize(this);
257
- }
258
-
259
- ~LegacyFrames()
260
- {
261
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
262
- if (handle != IntPtr.Zero)
263
- {
264
- NativeLegacyClient.autd3_legacy_frames_free(handle);
265
- }
266
- }
233
+ public void Dispose() => _handle.Dispose();
267
234
  }
268
235
 
269
- public sealed class LegacyClient : IDisposable
236
+ public sealed class LegacyClient : IDisposable, IAsyncDisposable
270
237
  {
271
- private IntPtr _handle;
272
-
273
- internal IntPtr Handle => _handle;
274
-
238
+ private readonly LegacyClientHandle _handle;
275
239
  private readonly Geometry _geometry;
276
240
 
241
+ internal LegacyClientHandle Handle => _handle;
242
+
277
243
  private LegacyClient(IntPtr handle, Geometry geometry)
278
244
  {
279
- _handle = handle;
245
+ _handle = new LegacyClientHandle(handle);
280
246
  _geometry = geometry;
281
247
  }
282
248
 
@@ -323,7 +289,7 @@ namespace AUTD3.Legacy
323
289
 
324
290
  public int NumDevices => (int)NativeLegacyClient.autd3_legacy_client_num_devices(Handle);
325
291
 
326
- public LegacyDatagramBuilder DatagramBuilder() => new LegacyDatagramBuilder(_geometry, Handle);
292
+ public LegacyDatagramBuilder DatagramBuilder() => new LegacyDatagramBuilder(_geometry, this);
327
293
 
328
294
  public Task SendCheckedAsync(LegacyFrame frame) =>
329
295
  AsyncOps.InvokeAsync((cb, ud) =>
@@ -373,20 +339,33 @@ namespace AUTD3.Legacy
373
339
 
374
340
  public void Dispose()
375
341
  {
376
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
377
- if (handle != IntPtr.Zero)
342
+ if (_handle.IsClosed)
343
+ {
344
+ return;
345
+ }
346
+ try
378
347
  {
379
- NativeLegacyClient.autd3_legacy_client_free(handle);
348
+ CloseAsync().GetAwaiter().GetResult();
349
+ }
350
+ finally
351
+ {
352
+ _handle.Dispose();
380
353
  }
381
- GC.SuppressFinalize(this);
382
354
  }
383
355
 
384
- ~LegacyClient()
356
+ public async ValueTask DisposeAsync()
385
357
  {
386
- var handle = Interlocked.Exchange(ref _handle, IntPtr.Zero);
387
- if (handle != IntPtr.Zero)
358
+ if (_handle.IsClosed)
359
+ {
360
+ return;
361
+ }
362
+ try
363
+ {
364
+ await CloseAsync().ConfigureAwait(false);
365
+ }
366
+ finally
388
367
  {
389
- NativeLegacyClient.autd3_legacy_client_free(handle);
368
+ _handle.Dispose();
390
369
  }
391
370
  }
392
371
  }
package/Native.cs CHANGED
@@ -14,153 +14,153 @@ namespace AUTD3
14
14
 
15
15
  static NativeClient() => NativeAbi.Verify(Lib, autd3_abi_version());
16
16
 
17
- [DllImport(Lib)]
17
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
18
18
  private static extern uint autd3_abi_version();
19
19
 
20
- [DllImport(Lib)]
20
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
21
21
  internal static extern IntPtr autd3_client_config_new();
22
22
 
23
- [DllImport(Lib)]
23
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
24
24
  internal static extern int autd3_client_config_set_low_latency(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool value);
25
25
 
26
- [DllImport(Lib)]
26
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
27
27
  internal static extern int autd3_client_config_set_validate_state(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool value);
28
28
 
29
- [DllImport(Lib)]
29
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
30
30
  internal static extern int autd3_client_config_set_require_supported_firmware(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool value);
31
31
 
32
- [DllImport(Lib)]
32
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
33
33
  internal static extern int autd3_client_config_set_timeout_cycles(IntPtr config, uint value);
34
34
 
35
- [DllImport(Lib)]
35
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
36
36
  internal static extern int autd3_client_config_set_max_inflight(IntPtr config, UIntPtr value);
37
37
 
38
- [DllImport(Lib)]
38
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
39
39
  internal static extern int autd3_client_config_set_max_resync_rounds(IntPtr config, uint value);
40
40
 
41
- [DllImport(Lib)]
41
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
42
42
  internal static extern int autd3_client_config_set_reset_resend_cycles(IntPtr config, uint value);
43
43
 
44
- [DllImport(Lib)]
44
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
45
45
  internal static extern int autd3_client_config_set_rt_priority(IntPtr config, byte mode, byte value);
46
46
 
47
- [DllImport(Lib)]
47
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
48
48
  internal static extern int autd3_client_config_set_rt_policy(IntPtr config, byte value);
49
49
 
50
- [DllImport(Lib)]
50
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
51
51
  internal static extern int autd3_client_config_set_rt_affinity(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool hasAffinity, UIntPtr coreId);
52
52
 
53
- [DllImport(Lib)]
53
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
54
54
  internal static extern void autd3_client_config_free(IntPtr config);
55
55
 
56
- [DllImport(Lib)]
56
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
57
57
  internal static extern void autd3_client_opener_free(IntPtr opener);
58
58
 
59
- [DllImport(Lib)]
60
- internal static extern IntPtr autd3_datagram_builder_new(IntPtr geometry);
59
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
60
+ internal static extern IntPtr autd3_datagram_builder_new(GeometryHandle geometry);
61
61
 
62
- [DllImport(Lib)]
63
- internal static extern int autd3_datagram_builder_push(IntPtr builder, IntPtr op);
62
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
63
+ internal static extern int autd3_datagram_builder_push(DatagramBuilderHandle builder, IntPtr op);
64
64
 
65
- [DllImport(Lib)]
66
- internal static extern int autd3_datagram_builder_push_each(IntPtr builder, IntPtr[] ops, UIntPtr numDevices);
65
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
66
+ internal static extern int autd3_datagram_builder_push_each(DatagramBuilderHandle builder, IntPtr[] ops, UIntPtr numDevices);
67
67
 
68
- [DllImport(Lib)]
68
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
69
69
  internal static extern void autd3_op_free(IntPtr op);
70
70
 
71
- [DllImport(Lib)]
71
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
72
72
  internal static extern void autd3_datagram_builder_free(IntPtr builder);
73
73
 
74
- [DllImport(Lib)]
75
- internal static extern IntPtr autd3_datagram_builder_build(IntPtr builder, IntPtr client, byte[] outErr, UIntPtr outErrLen);
74
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
75
+ internal static extern IntPtr autd3_datagram_builder_build(DatagramBuilderHandle builder, IntPtr client, byte[] outErr, UIntPtr outErrLen);
76
76
 
77
- [DllImport(Lib)]
78
- internal static extern UIntPtr autd3_datagrams_num_frames(IntPtr datagrams);
77
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
78
+ internal static extern UIntPtr autd3_datagrams_num_frames(FramesHandle datagrams);
79
79
 
80
- [DllImport(Lib)]
80
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
81
81
  internal static extern void autd3_datagrams_free(IntPtr datagrams);
82
82
 
83
- [DllImport(Lib)]
84
- internal static extern void autd3_client_open(IntPtr geometry, IntPtr link, IntPtr config, CompletionCallback cb, IntPtr userData);
83
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
84
+ internal static extern void autd3_client_open(GeometryHandle geometry, IntPtr link, IntPtr config, CompletionCallback cb, IntPtr userData);
85
85
 
86
- [DllImport(Lib)]
87
- internal static extern UIntPtr autd3_client_num_devices(IntPtr client);
86
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
87
+ internal static extern UIntPtr autd3_client_num_devices(ClientHandle client);
88
88
 
89
- [DllImport(Lib)]
90
- internal static extern void autd3_client_send_checked(IntPtr client, IntPtr datagrams, long frame, CompletionCallback cb, IntPtr userData);
89
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
90
+ internal static extern void autd3_client_send_checked(ClientHandle client, FramesHandle datagrams, long frame, CompletionCallback cb, IntPtr userData);
91
91
 
92
- [DllImport(Lib)]
93
- internal static extern void autd3_client_send(IntPtr client, IntPtr datagrams, long frame, CompletionCallback cb, IntPtr userData);
92
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
93
+ internal static extern void autd3_client_send(ClientHandle client, FramesHandle datagrams, long frame, CompletionCallback cb, IntPtr userData);
94
94
 
95
- [DllImport(Lib)]
95
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
96
96
  internal static extern void autd3_response_token_await(IntPtr token, CompletionCallback cb, IntPtr userData);
97
97
 
98
- [DllImport(Lib)]
98
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
99
99
  internal static extern void autd3_response_token_free(IntPtr token);
100
100
 
101
- [DllImport(Lib)]
101
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
102
102
  [return: MarshalAs(UnmanagedType.I1)]
103
103
  internal static extern bool autd3_response_check(byte[] data, UIntPtr len, byte[] outErr, UIntPtr outErrLen);
104
104
 
105
- [DllImport(Lib)]
106
- internal static extern void autd3_client_stop(IntPtr client, CompletionCallback cb, IntPtr userData);
105
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
106
+ internal static extern void autd3_client_stop(ClientHandle client, CompletionCallback cb, IntPtr userData);
107
107
 
108
- [DllImport(Lib)]
109
- internal static extern void autd3_client_close(IntPtr client, CompletionCallback cb, IntPtr userData);
108
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
109
+ internal static extern void autd3_client_close(ClientHandle client, CompletionCallback cb, IntPtr userData);
110
110
 
111
- [DllImport(Lib)]
111
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
112
112
  internal static extern void autd3_client_free(IntPtr client);
113
113
 
114
- [DllImport(Lib)]
115
- internal static extern void autd3_client_read_firmware_version(IntPtr client, CompletionCallback cb, IntPtr userData);
114
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
115
+ internal static extern void autd3_client_read_firmware_version(ClientHandle client, CompletionCallback cb, IntPtr userData);
116
116
 
117
- [DllImport(Lib)]
118
- internal static extern void autd3_client_read_fpga_state(IntPtr client, CompletionCallback cb, IntPtr userData);
117
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
118
+ internal static extern void autd3_client_read_fpga_state(ClientHandle client, CompletionCallback cb, IntPtr userData);
119
119
 
120
- [DllImport(Lib)]
121
- internal static extern void autd3_client_read_error_detail(IntPtr client, CompletionCallback cb, IntPtr userData);
120
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
121
+ internal static extern void autd3_client_read_error_detail(ClientHandle client, CompletionCallback cb, IntPtr userData);
122
122
 
123
- [DllImport(Lib)]
124
- internal static extern void autd3_client_read_telemetry(IntPtr client, byte counter, CompletionCallback cb, IntPtr userData);
123
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
124
+ internal static extern void autd3_client_read_telemetry(ClientHandle client, byte counter, CompletionCallback cb, IntPtr userData);
125
125
 
126
- [DllImport(Lib)]
126
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
127
127
  internal static extern UIntPtr autd3_byte_array_len(IntPtr array);
128
128
 
129
- [DllImport(Lib)]
129
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
130
130
  internal static extern IntPtr autd3_byte_array_data(IntPtr array);
131
131
 
132
- [DllImport(Lib)]
132
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
133
133
  internal static extern void autd3_byte_array_free(IntPtr array);
134
134
 
135
- [DllImport(Lib)]
135
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
136
136
  internal static extern UIntPtr autd3_string_array_len(IntPtr array);
137
137
 
138
- [DllImport(Lib)]
138
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
139
139
  internal static extern IntPtr autd3_string_array_get(IntPtr array, UIntPtr index);
140
140
 
141
- [DllImport(Lib)]
141
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
142
142
  internal static extern void autd3_string_array_free(IntPtr array);
143
143
 
144
- [DllImport(Lib)]
145
- internal static extern IntPtr autd3_client_checker(IntPtr client);
144
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
145
+ internal static extern IntPtr autd3_client_checker(ClientHandle client);
146
146
 
147
- [DllImport(Lib)]
148
- internal static extern void autd3_checker_check(IntPtr checker, CompletionCallback cb, IntPtr userData);
147
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
148
+ internal static extern IntPtr autd3_checker_check(CheckerHandle checker, byte[] err, UIntPtr errLen);
149
149
 
150
- [DllImport(Lib)]
150
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
151
151
  internal static extern void autd3_checker_free(IntPtr checker);
152
152
 
153
- [DllImport(Lib)]
153
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
154
154
  internal static extern ulong autd3_link_status_recoveries(IntPtr status);
155
155
 
156
- [DllImport(Lib)]
156
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
157
157
  internal static extern UIntPtr autd3_link_status_num_devices(IntPtr status);
158
158
 
159
- [DllImport(Lib)]
159
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
160
160
  [return: MarshalAs(UnmanagedType.I1)]
161
161
  internal static extern bool autd3_link_status_device_state(IntPtr status, UIntPtr index, out byte outKind, out byte outBits);
162
162
 
163
- [DllImport(Lib)]
163
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
164
164
  internal static extern void autd3_link_status_free(IntPtr status);
165
165
  }
166
166
 
@@ -168,85 +168,85 @@ namespace AUTD3
168
168
  {
169
169
  private const string Lib = "autd3capi";
170
170
 
171
- [DllImport(Lib)]
171
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
172
172
  internal static extern IntPtr autd3_legacy_client_config_new();
173
173
 
174
- [DllImport(Lib)]
174
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
175
175
  internal static extern int autd3_legacy_client_config_set_timeout_cycles(IntPtr config, uint value);
176
176
 
177
- [DllImport(Lib)]
177
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
178
178
  internal static extern int autd3_legacy_client_config_set_rt_priority(IntPtr config, byte mode, byte value);
179
179
 
180
- [DllImport(Lib)]
180
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
181
181
  internal static extern int autd3_legacy_client_config_set_rt_policy(IntPtr config, byte value);
182
182
 
183
- [DllImport(Lib)]
183
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
184
184
  internal static extern int autd3_legacy_client_config_set_rt_affinity(IntPtr config, [MarshalAs(UnmanagedType.I1)] bool hasAffinity, UIntPtr coreId);
185
185
 
186
- [DllImport(Lib)]
186
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
187
187
  internal static extern void autd3_legacy_client_config_free(IntPtr config);
188
188
 
189
- [DllImport(Lib)]
189
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
190
190
  internal static extern void autd3_legacy_client_opener_free(IntPtr opener);
191
191
 
192
- [DllImport(Lib)]
193
- internal static extern IntPtr autd3_legacy_datagram_builder_new(IntPtr geometry);
192
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
193
+ internal static extern IntPtr autd3_legacy_datagram_builder_new(GeometryHandle geometry);
194
194
 
195
- [DllImport(Lib)]
196
- internal static extern int autd3_legacy_datagram_builder_push(IntPtr builder, IntPtr op);
195
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
196
+ internal static extern int autd3_legacy_datagram_builder_push(LegacyDatagramBuilderHandle builder, IntPtr op);
197
197
 
198
- [DllImport(Lib)]
198
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
199
199
  internal static extern IntPtr autd3_legacy_op_change_segment(byte kind, byte bank, byte transitionMode, ulong transitionValue);
200
200
 
201
- [DllImport(Lib)]
201
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
202
202
  internal static extern void autd3_legacy_op_free(IntPtr op);
203
203
 
204
- [DllImport(Lib)]
205
- internal static extern int autd3_legacy_datagram_builder_push_legacy(IntPtr builder, IntPtr op);
204
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
205
+ internal static extern int autd3_legacy_datagram_builder_push_legacy(LegacyDatagramBuilderHandle builder, IntPtr op);
206
206
 
207
- [DllImport(Lib)]
208
- internal static extern int autd3_legacy_datagram_builder_push_each(IntPtr builder, IntPtr[] ops, UIntPtr numDevices);
207
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
208
+ internal static extern int autd3_legacy_datagram_builder_push_each(LegacyDatagramBuilderHandle builder, IntPtr[] ops, UIntPtr numDevices);
209
209
 
210
- [DllImport(Lib)]
210
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
211
211
  internal static extern void autd3_legacy_datagram_builder_free(IntPtr builder);
212
212
 
213
- [DllImport(Lib)]
214
- internal static extern IntPtr autd3_legacy_datagram_builder_build(IntPtr builder, IntPtr client, byte[] outErr, UIntPtr outErrLen);
213
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
214
+ internal static extern IntPtr autd3_legacy_datagram_builder_build(LegacyDatagramBuilderHandle builder, IntPtr client, byte[] outErr, UIntPtr outErrLen);
215
215
 
216
- [DllImport(Lib)]
217
- internal static extern UIntPtr autd3_legacy_frames_num_frames(IntPtr frames);
216
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
217
+ internal static extern UIntPtr autd3_legacy_frames_num_frames(LegacyFramesHandle frames);
218
218
 
219
- [DllImport(Lib)]
219
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
220
220
  internal static extern void autd3_legacy_frames_free(IntPtr frames);
221
221
 
222
- [DllImport(Lib)]
223
- internal static extern void autd3_legacy_client_open(IntPtr geometry, IntPtr link, IntPtr config, CompletionCallback cb, IntPtr userData);
222
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
223
+ internal static extern void autd3_legacy_client_open(GeometryHandle geometry, IntPtr link, IntPtr config, CompletionCallback cb, IntPtr userData);
224
224
 
225
- [DllImport(Lib)]
226
- internal static extern UIntPtr autd3_legacy_client_num_devices(IntPtr client);
225
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
226
+ internal static extern UIntPtr autd3_legacy_client_num_devices(LegacyClientHandle client);
227
227
 
228
- [DllImport(Lib)]
229
- internal static extern void autd3_legacy_client_send(IntPtr client, IntPtr frames, long frame, CompletionCallback cb, IntPtr userData);
228
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
229
+ internal static extern void autd3_legacy_client_send(LegacyClientHandle client, LegacyFramesHandle frames, long frame, CompletionCallback cb, IntPtr userData);
230
230
 
231
- [DllImport(Lib)]
232
- internal static extern void autd3_legacy_client_send_checked(IntPtr client, IntPtr frames, long frame, CompletionCallback cb, IntPtr userData);
231
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
232
+ internal static extern void autd3_legacy_client_send_checked(LegacyClientHandle client, LegacyFramesHandle frames, long frame, CompletionCallback cb, IntPtr userData);
233
233
 
234
- [DllImport(Lib)]
235
- internal static extern void autd3_legacy_client_read_firmware_version(IntPtr client, CompletionCallback cb, IntPtr userData);
234
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
235
+ internal static extern void autd3_legacy_client_read_firmware_version(LegacyClientHandle client, CompletionCallback cb, IntPtr userData);
236
236
 
237
- [DllImport(Lib)]
238
- internal static extern void autd3_legacy_client_read_fpga_state(IntPtr client, CompletionCallback cb, IntPtr userData);
237
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
238
+ internal static extern void autd3_legacy_client_read_fpga_state(LegacyClientHandle client, CompletionCallback cb, IntPtr userData);
239
239
 
240
- [DllImport(Lib)]
241
- internal static extern IntPtr autd3_legacy_client_checker(IntPtr client);
240
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
241
+ internal static extern IntPtr autd3_legacy_client_checker(LegacyClientHandle client);
242
242
 
243
- [DllImport(Lib)]
244
- internal static extern void autd3_legacy_client_stop(IntPtr client, CompletionCallback cb, IntPtr userData);
243
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
244
+ internal static extern void autd3_legacy_client_stop(LegacyClientHandle client, CompletionCallback cb, IntPtr userData);
245
245
 
246
- [DllImport(Lib)]
247
- internal static extern void autd3_legacy_client_close(IntPtr client, CompletionCallback cb, IntPtr userData);
246
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
247
+ internal static extern void autd3_legacy_client_close(LegacyClientHandle client, CompletionCallback cb, IntPtr userData);
248
248
 
249
- [DllImport(Lib)]
249
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
250
250
  internal static extern void autd3_legacy_client_free(IntPtr client);
251
251
  }
252
252
  }
Binary file
Binary file
package/SafeHandles.cs ADDED
@@ -0,0 +1,95 @@
1
+ using System;
2
+
3
+ namespace AUTD3
4
+ {
5
+ internal sealed class DatagramBuilderHandle : Autd3SafeHandle
6
+ {
7
+ internal DatagramBuilderHandle(IntPtr handle) : base(handle)
8
+ {
9
+ }
10
+
11
+ protected override bool ReleaseHandle()
12
+ {
13
+ NativeClient.autd3_datagram_builder_free(handle);
14
+ return true;
15
+ }
16
+ }
17
+
18
+ internal sealed class FramesHandle : Autd3SafeHandle
19
+ {
20
+ internal FramesHandle(IntPtr handle) : base(handle)
21
+ {
22
+ }
23
+
24
+ protected override bool ReleaseHandle()
25
+ {
26
+ NativeClient.autd3_datagrams_free(handle);
27
+ return true;
28
+ }
29
+ }
30
+
31
+ internal sealed class ClientHandle : Autd3SafeHandle
32
+ {
33
+ internal ClientHandle(IntPtr handle) : base(handle)
34
+ {
35
+ }
36
+
37
+ protected override bool ReleaseHandle()
38
+ {
39
+ NativeClient.autd3_client_free(handle);
40
+ return true;
41
+ }
42
+ }
43
+
44
+ internal sealed class CheckerHandle : Autd3SafeHandle
45
+ {
46
+ internal CheckerHandle(IntPtr handle) : base(handle)
47
+ {
48
+ }
49
+
50
+ protected override bool ReleaseHandle()
51
+ {
52
+ NativeClient.autd3_checker_free(handle);
53
+ return true;
54
+ }
55
+ }
56
+
57
+ internal sealed class LegacyDatagramBuilderHandle : Autd3SafeHandle
58
+ {
59
+ internal LegacyDatagramBuilderHandle(IntPtr handle) : base(handle)
60
+ {
61
+ }
62
+
63
+ protected override bool ReleaseHandle()
64
+ {
65
+ NativeLegacyClient.autd3_legacy_datagram_builder_free(handle);
66
+ return true;
67
+ }
68
+ }
69
+
70
+ internal sealed class LegacyFramesHandle : Autd3SafeHandle
71
+ {
72
+ internal LegacyFramesHandle(IntPtr handle) : base(handle)
73
+ {
74
+ }
75
+
76
+ protected override bool ReleaseHandle()
77
+ {
78
+ NativeLegacyClient.autd3_legacy_frames_free(handle);
79
+ return true;
80
+ }
81
+ }
82
+
83
+ internal sealed class LegacyClientHandle : Autd3SafeHandle
84
+ {
85
+ internal LegacyClientHandle(IntPtr handle) : base(handle)
86
+ {
87
+ }
88
+
89
+ protected override bool ReleaseHandle()
90
+ {
91
+ NativeLegacyClient.autd3_legacy_client_free(handle);
92
+ return true;
93
+ }
94
+ }
95
+ }
@@ -0,0 +1,11 @@
1
+ fileFormatVersion: 2
2
+ guid: 6ca30589f39168c1d48237309f6a8536
3
+ MonoImporter:
4
+ externalObjects: {}
5
+ serializedVersion: 2
6
+ defaultReferences: []
7
+ executionOrder: 0
8
+ icon: {instanceID: 0}
9
+ userData:
10
+ assetBundleName:
11
+ assetBundleVariant:
@@ -11,7 +11,7 @@ namespace AUTD3.Samples
11
11
  // Coordinates are in the Unity frame (metres, left-handed): a device emits along its
12
12
  // local -z, so the focus that the dotnet sample writes as new Vector3(0, 0, 150) is
13
13
  // new Vector3(0, 0, -0.15f) here.
14
- // The Nop link runs without hardware; swap it for new EtherCrab(...) on a real device.
14
+ // The Nop link runs without hardware; swap it for new Echocat(...) on a real device.
15
15
  public sealed class FocusSineSample : MonoBehaviour
16
16
  {
17
17
  private Client _client;
package/Stm.cs CHANGED
@@ -27,43 +27,43 @@ namespace AUTD3
27
27
 
28
28
  static NativeStm() => NativeAbi.Verify(Lib, autd3_abi_version());
29
29
 
30
- [DllImport(Lib)]
30
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
31
31
  private static extern uint autd3_abi_version();
32
32
 
33
- [DllImport(Lib)]
33
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
34
34
  internal static extern IntPtr autd3_stm_config_freq(float hz);
35
35
 
36
- [DllImport(Lib)]
36
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
37
37
  internal static extern IntPtr autd3_stm_config_freq_nearest(float hz);
38
38
 
39
- [DllImport(Lib)]
39
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
40
40
  internal static extern IntPtr autd3_stm_config_period(float secs);
41
41
 
42
- [DllImport(Lib)]
42
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
43
43
  internal static extern IntPtr autd3_stm_config_period_nearest(float secs);
44
44
 
45
- [DllImport(Lib)]
45
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
46
46
  internal static extern IntPtr autd3_stm_config_sampling(ushort divide);
47
47
 
48
- [DllImport(Lib)]
48
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
49
49
  internal static extern int autd3_stm_config_into_sampling_config(IntPtr config, UIntPtr size, out ushort @out);
50
50
 
51
- [DllImport(Lib)]
51
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
52
52
  internal static extern void autd3_stm_config_free(IntPtr config);
53
53
 
54
- [DllImport(Lib)]
54
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
55
55
  internal static extern IntPtr autd3_op_foci_stm(IntPtr config, Autd3StmControlPointNative[] points, UIntPtr numSamples, byte numFoci, byte[] intensities, byte bank, float soundSpeedMS, ushort loopRep, byte transitionMode, ulong transitionValue, uint transitionMarginNs);
56
56
 
57
- [DllImport(Lib)]
57
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
58
58
  internal static extern IntPtr autd3_op_write_foci_buffer(byte bank, uint indexOffset, Autd3StmControlPointNative[] points, UIntPtr numSamples, byte numFoci, byte[] intensities);
59
59
 
60
- [DllImport(Lib)]
60
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
61
61
  internal static extern IntPtr autd3_op_pattern_stm(IntPtr config, IntPtr[] patterns, UIntPtr numPatterns, byte bank, byte mode, ushort loopRep, byte transitionMode, ulong transitionValue, uint transitionMarginNs);
62
62
 
63
- [DllImport(Lib)]
63
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
64
64
  internal static extern int autd3_stm_circle(float[] center, float radiusMm, UIntPtr numPoints, float[] normal, byte intensity, Autd3StmControlPointNative[] outPoints, byte[] outIntensities);
65
65
 
66
- [DllImport(Lib)]
66
+ [DllImport(Lib, CallingConvention = CallingConvention.Cdecl)]
67
67
  internal static extern int autd3_stm_line(float[] start, float[] end, UIntPtr numPoints, byte intensity, Autd3StmControlPointNative[] outPoints, byte[] outIntensities);
68
68
  }
69
69
 
@@ -264,7 +264,7 @@ namespace AUTD3
264
264
  try
265
265
  {
266
266
  return NativeStm.autd3_op_foci_stm(configHandle, points, (UIntPtr)_points.Length, numFoci, intensities,
267
- (byte)_option.Bank, _option.SoundSpeed.MPerS, _option.LoopBehavior.Rep, _option.TransitionMode.Mode, _option.TransitionMode.Value, _option.TransitionMode.MarginNs);
267
+ (byte)_option.Bank, _option.SoundSpeed.MS, _option.LoopBehavior.Rep, _option.TransitionMode.Mode, _option.TransitionMode.Value, _option.TransitionMode.MarginNs);
268
268
  }
269
269
  finally
270
270
  {
@@ -288,15 +288,16 @@ namespace AUTD3
288
288
 
289
289
  IntPtr ICommand.CreateOp()
290
290
  {
291
- var handles = new IntPtr[_patterns.Length];
291
+ var handles = new SafeHandle[_patterns.Length];
292
292
  for (var i = 0; i < _patterns.Length; i++)
293
293
  {
294
294
  handles[i] = _patterns[i].Handle;
295
295
  }
296
+ using var lease = new HandleArray(handles);
296
297
  var configHandle = _config.CreateHandle();
297
298
  try
298
299
  {
299
- return NativeStm.autd3_op_pattern_stm(configHandle, handles, (UIntPtr)handles.Length,
300
+ return NativeStm.autd3_op_pattern_stm(configHandle, lease.Pointers, (UIntPtr)lease.Pointers.Length,
300
301
  (byte)_option.Bank, (byte)_option.Mode, _option.LoopBehavior.Rep, _option.TransitionMode.Mode, _option.TransitionMode.Value, _option.TransitionMode.MarginNs);
301
302
  }
302
303
  finally
@@ -5,7 +5,7 @@ The following is a list of those components and the full text of their licenses.
5
5
 
6
6
  ## Overview
7
7
 
8
- - MIT License (53)
8
+ - MIT License (59)
9
9
  - Apache License 2.0 (3)
10
10
  - Unicode License v3 (1)
11
11
 
@@ -835,38 +835,6 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
835
835
 
836
836
  Used by:
837
837
 
838
- - tokio-macros 2.7.0 — https://github.com/tokio-rs/tokio
839
-
840
- ```
841
- MIT License
842
-
843
- Copyright (c) 2019 Yoshua Wuyts
844
- Copyright (c) Tokio Contributors
845
-
846
- Permission is hereby granted, free of charge, to any person obtaining a copy
847
- of this software and associated documentation files (the "Software"), to deal
848
- in the Software without restriction, including without limitation the rights
849
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
850
- copies of the Software, and to permit persons to whom the Software is
851
- furnished to do so, subject to the following conditions:
852
-
853
- The above copyright notice and this permission notice shall be included in all
854
- copies or substantial portions of the Software.
855
-
856
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
857
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
858
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
859
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
860
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
861
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
862
- SOFTWARE.
863
-
864
- ```
865
-
866
- ## MIT License
867
-
868
- Used by:
869
-
870
838
  - safe_arch 1.0.0 — https://github.com/Lokathor/safe_arch
871
839
 
872
840
  ```
@@ -886,8 +854,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
886
854
 
887
855
  Used by:
888
856
 
889
- - autd3-rs 0.6.1 — https://github.com/shinolab/autd3-sdk
890
- - autd3-rs-core 0.6.1 — https://github.com/shinolab/autd3-sdk
857
+ - autd3-rs 0.8.0 — https://github.com/shinolab/autd3-sdk
858
+ - autd3-rs-core 0.8.0 — https://github.com/shinolab/autd3-sdk
891
859
  - autd3-cpu-wire 0.6.0 — https://github.com/shinolab/autd3-sdk
892
860
 
893
861
  ```
@@ -919,8 +887,8 @@ SOFTWARE.
919
887
 
920
888
  Used by:
921
889
 
922
- - autd3-ffi 0.6.1 — https://github.com/shinolab/autd3-sdk
923
- - autd3-ffi-abi 0.6.1 — https://github.com/shinolab/autd3-sdk
890
+ - autd3-ffi 0.8.0 — https://github.com/shinolab/autd3-sdk
891
+ - autd3-ffi-abi 0.8.0 — https://github.com/shinolab/autd3-sdk
924
892
  - chrono 0.4.45 — https://github.com/chronotope/chrono
925
893
  - wide 1.5.0 — https://github.com/Lokathor/wide
926
894
  - winapi-i686-pc-windows-gnu 0.4.0 — https://github.com/retep998/winapi-rs
@@ -964,46 +932,21 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
964
932
 
965
933
  Used by:
966
934
 
967
- - tokio 1.53.0 — https://github.com/tokio-rs/tokio
968
-
969
- ```
970
- MIT License
971
-
972
- Copyright (c) Tokio Contributors
973
-
974
- Permission is hereby granted, free of charge, to any person obtaining a copy
975
- of this software and associated documentation files (the "Software"), to deal
976
- in the Software without restriction, including without limitation the rights
977
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
978
- copies of the Software, and to permit persons to whom the Software is
979
- furnished to do so, subject to the following conditions:
980
-
981
- The above copyright notice and this permission notice shall be included in all
982
- copies or substantial portions of the Software.
983
-
984
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
985
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
986
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
987
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
988
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
989
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
990
- SOFTWARE.
991
-
992
- ```
993
-
994
- ## MIT License
995
-
996
- Used by:
997
-
998
935
  - hermit-abi 0.5.2 — https://github.com/hermit-os/hermit-rs
936
+ - itoa 1.0.18 — https://github.com/dtolnay/itoa
999
937
  - pin-project-lite 0.2.17 — https://github.com/taiki-e/pin-project-lite
1000
938
  - proc-macro2 1.0.106 — https://github.com/dtolnay/proc-macro2
1001
939
  - quote 1.0.46 — https://github.com/dtolnay/quote
1002
940
  - rustversion 1.0.22 — https://github.com/dtolnay/rustversion
941
+ - serde 1.0.228 — https://github.com/serde-rs/serde
942
+ - serde_core 1.0.228 — https://github.com/serde-rs/serde
943
+ - serde_derive 1.0.228 — https://github.com/serde-rs/serde
944
+ - serde_json 1.0.150 — https://github.com/serde-rs/json
1003
945
  - syn 2.0.118 — https://github.com/dtolnay/syn
1004
946
  - thiserror-impl 2.0.18 — https://github.com/dtolnay/thiserror
1005
947
  - thiserror 2.0.18 — https://github.com/dtolnay/thiserror
1006
948
  - unicode-ident 1.0.24 — https://github.com/dtolnay/unicode-ident
949
+ - zmij 1.0.21 — https://github.com/dtolnay/zmij
1007
950
 
1008
951
  ```
1009
952
  Permission is hereby granted, free of charge, to any
@@ -1036,6 +979,37 @@ DEALINGS IN THE SOFTWARE.
1036
979
 
1037
980
  Used by:
1038
981
 
982
+ - tracing-core 0.1.36 — https://github.com/tokio-rs/tracing
983
+
984
+ ```
985
+ The MIT License (MIT)
986
+
987
+ Copyright (c) 2014 Mathijs van de Nes
988
+
989
+ Permission is hereby granted, free of charge, to any person obtaining a copy
990
+ of this software and associated documentation files (the "Software"), to deal
991
+ in the Software without restriction, including without limitation the rights
992
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
993
+ copies of the Software, and to permit persons to whom the Software is
994
+ furnished to do so, subject to the following conditions:
995
+
996
+ The above copyright notice and this permission notice shall be included in all
997
+ copies or substantial portions of the Software.
998
+
999
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1000
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1001
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1002
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1003
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1004
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
1005
+ SOFTWARE.
1006
+
1007
+ ```
1008
+
1009
+ ## MIT License
1010
+
1011
+ Used by:
1012
+
1039
1013
  - typenum 1.20.1 — https://github.com/paholg/typenum
1040
1014
 
1041
1015
  ```
@@ -1063,6 +1037,37 @@ SOFTWARE.
1063
1037
 
1064
1038
  ```
1065
1039
 
1040
+ ## MIT License
1041
+
1042
+ Used by:
1043
+
1044
+ - memchr 2.8.2 — https://github.com/BurntSushi/memchr
1045
+
1046
+ ```
1047
+ The MIT License (MIT)
1048
+
1049
+ Copyright (c) 2015 Andrew Gallant
1050
+
1051
+ Permission is hereby granted, free of charge, to any person obtaining a copy
1052
+ of this software and associated documentation files (the "Software"), to deal
1053
+ in the Software without restriction, including without limitation the rights
1054
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
1055
+ copies of the Software, and to permit persons to whom the Software is
1056
+ furnished to do so, subject to the following conditions:
1057
+
1058
+ The above copyright notice and this permission notice shall be included in
1059
+ all copies or substantial portions of the Software.
1060
+
1061
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
1062
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
1063
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
1064
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1065
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
1066
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
1067
+ THE SOFTWARE.
1068
+
1069
+ ```
1070
+
1066
1071
  ## Unicode License v3
1067
1072
 
1068
1073
  Used by:
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "url": "git+https://github.com/shinolab/autd3-sdk.git",
6
6
  "directory": "bindings/unity/com.shinolab.autd3-sdk"
7
7
  },
8
- "version": "0.6.1",
8
+ "version": "0.8.0",
9
9
  "displayName": "AUTD3",
10
10
  "description": "AUTD3 client, datagrams and STM (Unity binding).",
11
11
  "unity": "6000.0",
@@ -15,9 +15,9 @@
15
15
  "url": "https://github.com/shinolab"
16
16
  },
17
17
  "dependencies": {
18
- "com.shinolab.autd3-sdk.core": "0.6.1",
19
- "com.shinolab.autd3-sdk.pattern": "0.6.1",
20
- "com.shinolab.autd3-sdk.modulation": "0.6.1"
18
+ "com.shinolab.autd3-sdk.core": "0.8.0",
19
+ "com.shinolab.autd3-sdk.pattern": "0.8.0",
20
+ "com.shinolab.autd3-sdk.modulation": "0.8.0"
21
21
  },
22
22
  "samples": [
23
23
  {