Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
  • Loading branch information
myd7349 committed Aug 11, 2024
1 parent c8724a8 commit 07ea0ce
Show file tree
Hide file tree
Showing 3 changed files with 464 additions and 78 deletions.
63 changes: 7 additions & 56 deletions Source/SharpLSL/Interop/Inlet.Interop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,74 +73,25 @@ public static unsafe partial class LSL
[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint lsl_pull_chunk_buf(lsl_inlet @in, IntPtr[] data_buffer, uint[] lengths_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);






[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint lsl_pull_chunk_f([NativeTypeName("lsl_inlet")] IntPtr @in, float[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint lsl_pull_chunk_d([NativeTypeName("lsl_inlet")] IntPtr @in, double[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint lsl_pull_chunk_l([NativeTypeName("lsl_inlet")] IntPtr @in, long[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint lsl_pull_chunk_i([NativeTypeName("lsl_inlet")] IntPtr @in, int[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern uint lsl_pull_chunk_s([NativeTypeName("lsl_inlet")] IntPtr @in, short[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

/*
[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("lsl_inlet")]
public static extern IntPtr lsl_create_inlet([NativeTypeName("lsl_streaminfo")] IntPtr info, [NativeTypeName("int32_t")] int max_buflen, [NativeTypeName("int32_t")] int max_chunklen, [NativeTypeName("int32_t")] int recover);
[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("lsl_streaminfo")]
public static extern IntPtr lsl_get_fullinfo([NativeTypeName("lsl_inlet")] IntPtr @in, double timeout, [NativeTypeName("int32_t *")] int* ec);
[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double lsl_pull_sample_c([NativeTypeName("lsl_inlet")] IntPtr @in, [NativeTypeName("char *")] sbyte* buffer, [NativeTypeName("int32_t")] int buffer_elements, double timeout, [NativeTypeName("int32_t *")] int* ec);
[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double lsl_pull_sample_str([NativeTypeName("lsl_inlet")] IntPtr @in, [NativeTypeName("char **")] sbyte** buffer, [NativeTypeName("int32_t")] int buffer_elements, double timeout, [NativeTypeName("int32_t *")] int* ec);
[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double lsl_pull_sample_buf([NativeTypeName("lsl_inlet")] IntPtr @in, [NativeTypeName("char **")] sbyte** buffer, [NativeTypeName("uint32_t *")] uint* buffer_lengths, [NativeTypeName("int32_t")] int buffer_elements, double timeout, [NativeTypeName("int32_t *")] int* ec);
[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
public static extern double lsl_pull_sample_v([NativeTypeName("lsl_inlet")] IntPtr @in, void* buffer, [NativeTypeName("int32_t")] int buffer_bytes, double timeout, [NativeTypeName("int32_t *")] int* ec);
[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("unsigned long")]
public static extern uint lsl_pull_chunk_c([NativeTypeName("lsl_inlet")] IntPtr @in, [NativeTypeName("char *")] sbyte* data_buffer, double* timestamp_buffer, [NativeTypeName("unsigned long")] uint data_buffer_elements, [NativeTypeName("unsigned long")] uint timestamp_buffer_elements, double timeout, [NativeTypeName("int32_t *")] int* ec);
public static extern uint lsl_pull_chunk_c(lsl_inlet @in, sbyte[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("unsigned long")]
public static extern uint lsl_pull_chunk_str([NativeTypeName("lsl_inlet")] IntPtr @in, [NativeTypeName("char **")] sbyte** data_buffer, double* timestamp_buffer, [NativeTypeName("unsigned long")] uint data_buffer_elements, [NativeTypeName("unsigned long")] uint timestamp_buffer_elements, double timeout, [NativeTypeName("int32_t *")] int* ec);
public static extern uint lsl_pull_chunk_s(lsl_inlet @in, short[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("unsigned long")]
public static extern uint lsl_pull_chunk_buf([NativeTypeName("lsl_inlet")] IntPtr @in, [NativeTypeName("char **")] sbyte** data_buffer, [NativeTypeName("uint32_t *")] uint* lengths_buffer, double* timestamp_buffer, [NativeTypeName("unsigned long")] uint data_buffer_elements, [NativeTypeName("unsigned long")] uint timestamp_buffer_elements, double timeout, [NativeTypeName("int32_t *")] int* ec);
public static extern uint lsl_pull_chunk_i(lsl_inlet @in, int[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("uint32_t")]
public static extern uint lsl_samples_available([NativeTypeName("lsl_inlet")] IntPtr @in);
public static extern uint lsl_pull_chunk_l(lsl_inlet @in, long[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("uint32_t")]
public static extern uint lsl_inlet_flush([NativeTypeName("lsl_inlet")] IntPtr @in);
public static extern uint lsl_pull_chunk_f(lsl_inlet @in, float[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("uint32_t")]
public static extern uint lsl_was_clock_reset([NativeTypeName("lsl_inlet")] IntPtr @in);
public static extern uint lsl_pull_chunk_d(lsl_inlet @in, double[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);

[DllImport("lsl", CallingConvention = CallingConvention.Cdecl, ExactSpelling = true)]
[return: NativeTypeName("int32_t")]
public static extern int lsl_smoothing_halftime([NativeTypeName("lsl_inlet")] IntPtr @in, float value);
*/
public static extern uint lsl_pull_chunk_str(lsl_inlet @in, IntPtr[,] data_buffer, double[] timestamp_buffer, uint data_buffer_elements, uint timestamp_buffer_elements, double timeout, ref int ec);
}
}
15 changes: 15 additions & 0 deletions Source/SharpLSL/LSL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,21 @@ internal static int CheckChunkBuffer<T>(T[] chunk, int channelCount)
return chunk.Length / channelCount;
}

#if !NET35
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
internal static void CheckChunkBuffer<T>(T[,] chunk, int channelCount)
{
if (chunk == null)
throw new ArgumentNullException(nameof(chunk));

if (chunk.Length == 0)
throw new ArgumentException(nameof(chunk));

if (chunk.GetLength(1) != channelCount)
throw new ArgumentException($"Chunk's second dimension size ({chunk.GetLength(1)}) does not match the expected channel count ({channelCount}).");
}

#if !NET35
[MethodImpl(MethodImplOptions.AggressiveInlining)]
#endif
Expand Down
Loading

0 comments on commit 07ea0ce

Please sign in to comment.