Skip to content

Commit ccb6530

Browse files
HaowenWeiJohnclaude
andcommitted
feat: Add complete int64 support for LSL streams
Added FFI function declarations in lib/index.ts: - lsl_push_sample_l: Push single int64 sample with timestamp and pushthrough - lsl_push_chunk_l: Push int64 chunk with single timestamp - lsl_push_chunk_lt: Push int64 chunk with per-sample timestamps - lsl_pull_sample_l: Pull single int64 sample from inlet - lsl_pull_chunk_l: Pull int64 chunk with timestamps Updated function mapping dictionaries in lib/index.ts: - fmt2push_sample: Added mapping from cf_int64 (7) to lsl_push_sample_l - fmt2push_chunk: Added mapping from cf_int64 to lsl_push_chunk_l - fmt2push_chunk_n: Added mapping from cf_int64 to lsl_push_chunk_lt - fmt2pull_sample: Added mapping from cf_int64 to lsl_pull_sample_l - fmt2pull_chunk: Added mapping from cf_int64 to lsl_pull_chunk_l Added BigInt64Array support in outlet.ts: - Added case 7 (cf_int64) in pushSample TypedArray switch statement - Added case 7 (cf_int64) in pushChunk TypedArray switch statement - Both cases now use BigInt64Array for 64-bit integer data Added BigInt64Array support in inlet.ts: - Added case 7 (cf_int64) in _createSampleBuffer TypedArray switch - Added case 7 (cf_int64) in pullChunk buffer creation switch - Both cases now use BigInt64Array for 64-bit integer data This completes the missing int64 implementation that was defined as cf_int64 = 7 but lacked the necessary function bindings and TypedArray support. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent d1a0b1f commit ccb6530

3 files changed

Lines changed: 22 additions & 0 deletions

File tree

node-labstreaminglayer/src/inlet.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ export class StreamInlet {
115115
case 6: // cf_int8
116116
TypedArray = Int8Array;
117117
break;
118+
case 7: // cf_int64
119+
TypedArray = BigInt64Array;
120+
break;
118121
default:
119122
throw new Error(`Unsupported channel format: ${this.channelFormat}`);
120123
}
@@ -261,6 +264,9 @@ export class StreamInlet {
261264
case 6: // cf_int8
262265
TypedArray = Int8Array;
263266
break;
267+
case 7: // cf_int64
268+
TypedArray = BigInt64Array;
269+
break;
264270
default:
265271
throw new Error(`Unsupported channel format: ${this.channelFormat}`);
266272
}

node-labstreaminglayer/src/lib/index.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ export const lsl_push_sample_d = lib.func('int32 lsl_push_sample_dtp(void* outle
197197
export const lsl_push_sample_i = lib.func('int32 lsl_push_sample_itp(void* outlet, int32* sample, double timestamp, int32 pushthrough)');
198198
export const lsl_push_sample_s = lib.func('int32 lsl_push_sample_stp(void* outlet, int16* sample, double timestamp, int32 pushthrough)');
199199
export const lsl_push_sample_c = lib.func('int32 lsl_push_sample_ctp(void* outlet, int8* sample, double timestamp, int32 pushthrough)');
200+
export const lsl_push_sample_l = lib.func('int32 lsl_push_sample_ltp(void* outlet, int64* sample, double timestamp, int32 pushthrough)');
200201
export const lsl_push_sample_str = lib.func('int32 lsl_push_sample_strtp(void* outlet, char** sample, double timestamp, int32 pushthrough)');
201202
export const lsl_push_sample_v = lib.func('int32 lsl_push_sample_vtp(void* outlet, void* sample, double timestamp, int32 pushthrough)');
202203

@@ -218,6 +219,8 @@ export const lsl_push_chunk_s = lib.func('int32 lsl_push_chunk_stp(void* outlet,
218219
export const lsl_push_chunk_st = lib.func('int32 lsl_push_chunk_stnp(void* outlet, int16* data, ulong data_elements, double* timestamps, int32 pushthrough)');
219220
export const lsl_push_chunk_c = lib.func('int32 lsl_push_chunk_ctp(void* outlet, int8* data, ulong data_elements, double timestamp, int32 pushthrough)');
220221
export const lsl_push_chunk_ct = lib.func('int32 lsl_push_chunk_ctnp(void* outlet, int8* data, ulong data_elements, double* timestamps, int32 pushthrough)');
222+
export const lsl_push_chunk_l = lib.func('int32 lsl_push_chunk_ltp(void* outlet, int64* data, ulong data_elements, double timestamp, int32 pushthrough)');
223+
export const lsl_push_chunk_lt = lib.func('int32 lsl_push_chunk_ltnp(void* outlet, int64* data, ulong data_elements, double* timestamps, int32 pushthrough)');
221224
export const lsl_push_chunk_str = lib.func('int32 lsl_push_chunk_strtp(void* outlet, char** data, ulong data_elements, double timestamp, int32 pushthrough)');
222225
export const lsl_push_chunk_strt = lib.func('int32 lsl_push_chunk_strtnp(void* outlet, char** data, ulong data_elements, double* timestamps, int32 pushthrough)');
223226

@@ -251,6 +254,7 @@ export const lsl_pull_sample_d = lib.func('double lsl_pull_sample_d(void* inlet,
251254
export const lsl_pull_sample_i = lib.func('double lsl_pull_sample_i(void* inlet, _Out_ int32* sample, int32 buffer_elements, double timeout, _Out_ int32* errcode)');
252255
export const lsl_pull_sample_s = lib.func('double lsl_pull_sample_s(void* inlet, _Out_ int16* sample, int32 buffer_elements, double timeout, _Out_ int32* errcode)');
253256
export const lsl_pull_sample_c = lib.func('double lsl_pull_sample_c(void* inlet, _Out_ int8* sample, int32 buffer_elements, double timeout, _Out_ int32* errcode)');
257+
export const lsl_pull_sample_l = lib.func('double lsl_pull_sample_l(void* inlet, _Out_ int64* sample, int32 buffer_elements, double timeout, _Out_ int32* errcode)');
254258
export const lsl_pull_sample_str = lib.func('double lsl_pull_sample_str(void* inlet, _Out_ char** sample, int32 buffer_elements, double timeout, _Out_ int32* errcode)');
255259
export const lsl_pull_sample_v = lib.func('double lsl_pull_sample_v(void* inlet, _Out_ void* sample, int32 buffer_elements, double timeout, _Out_ int32* errcode)');
256260

@@ -266,6 +270,7 @@ export const lsl_pull_chunk_d = lib.func('ulong lsl_pull_chunk_d(void* inlet, _O
266270
export const lsl_pull_chunk_i = lib.func('ulong lsl_pull_chunk_i(void* inlet, _Out_ int32* data_buffer, _Out_ double* timestamp_buffer, ulong data_buffer_elements, ulong timestamp_buffer_elements, double timeout, _Out_ int32* errcode)');
267271
export const lsl_pull_chunk_s = lib.func('ulong lsl_pull_chunk_s(void* inlet, _Out_ int16* data_buffer, _Out_ double* timestamp_buffer, ulong data_buffer_elements, ulong timestamp_buffer_elements, double timeout, _Out_ int32* errcode)');
268272
export const lsl_pull_chunk_c = lib.func('ulong lsl_pull_chunk_c(void* inlet, _Out_ int8* data_buffer, _Out_ double* timestamp_buffer, ulong data_buffer_elements, ulong timestamp_buffer_elements, double timeout, _Out_ int32* errcode)');
273+
export const lsl_pull_chunk_l = lib.func('ulong lsl_pull_chunk_l(void* inlet, _Out_ int64* data_buffer, _Out_ double* timestamp_buffer, ulong data_buffer_elements, ulong timestamp_buffer_elements, double timeout, _Out_ int32* errcode)');
269274
export const lsl_pull_chunk_str = lib.func('ulong lsl_pull_chunk_str(void* inlet, _Out_ char** data_buffer, _Out_ double* timestamp_buffer, ulong data_buffer_elements, ulong timestamp_buffer_elements, double timeout, _Out_ int32* errcode)');
270275

271276

@@ -368,6 +373,7 @@ export const fmt2push_sample: { [key: number]: any } = {
368373
[cf_int32]: lsl_push_sample_i,
369374
[cf_int16]: lsl_push_sample_s,
370375
[cf_int8]: lsl_push_sample_c,
376+
[cf_int64]: lsl_push_sample_l,
371377
};
372378

373379
/**
@@ -381,6 +387,7 @@ export const fmt2push_chunk: { [key: number]: any } = {
381387
[cf_int32]: lsl_push_chunk_i,
382388
[cf_int16]: lsl_push_chunk_s,
383389
[cf_int8]: lsl_push_chunk_c,
390+
[cf_int64]: lsl_push_chunk_l,
384391
};
385392

386393
/**
@@ -394,6 +401,7 @@ export const fmt2push_chunk_n: { [key: number]: any } = {
394401
[cf_int32]: lsl_push_chunk_it,
395402
[cf_int16]: lsl_push_chunk_st,
396403
[cf_int8]: lsl_push_chunk_ct,
404+
[cf_int64]: lsl_push_chunk_lt,
397405
};
398406

399407
/**
@@ -407,6 +415,7 @@ export const fmt2pull_sample: { [key: number]: any } = {
407415
[cf_int32]: lsl_pull_sample_i,
408416
[cf_int16]: lsl_pull_sample_s,
409417
[cf_int8]: lsl_pull_sample_c,
418+
[cf_int64]: lsl_pull_sample_l,
410419
};
411420

412421
/**
@@ -420,4 +429,5 @@ export const fmt2pull_chunk: { [key: number]: any } = {
420429
[cf_int32]: lsl_pull_chunk_i,
421430
[cf_int16]: lsl_pull_chunk_s,
422431
[cf_int8]: lsl_pull_chunk_c,
432+
[cf_int64]: lsl_pull_chunk_l,
423433
};

node-labstreaminglayer/src/outlet.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,9 @@ export class StreamOutlet {
192192
case 6: // cf_int8 - 8-bit signed integer
193193
TypedArray = Int8Array;
194194
break;
195+
case 7: // cf_int64 - 64-bit signed integer
196+
TypedArray = BigInt64Array;
197+
break;
195198
default:
196199
throw new Error(`Unsupported channel format: ${this.channelFormat}`);
197200
}
@@ -297,6 +300,9 @@ export class StreamOutlet {
297300
case 6: // cf_int8
298301
TypedArray = Int8Array;
299302
break;
303+
case 7: // cf_int64
304+
TypedArray = BigInt64Array;
305+
break;
300306
default:
301307
throw new Error(`Unsupported channel format: ${this.channelFormat}`);
302308
}

0 commit comments

Comments
 (0)