Skip to content

Commit eecf818

Browse files
Reef-7sanchitmonga22
authored andcommitted
Fix VAD signature and make racFree safe optional lookup
1 parent 7fdd55a commit eecf818

1 file changed

Lines changed: 27 additions & 10 deletions

File tree

sdk/runanywhere-flutter/packages/runanywhere/lib/native/native_functions.dart

Lines changed: 27 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,25 @@ abstract class NativeFunctions {
196196
Int32 Function(RacHandle),
197197
int Function(RacHandle)>('rac_vad_component_cleanup');
198198

199-
static final int Function(RacHandle, Pointer<Float>, int, Pointer<Void>)
200-
vadProcess =
201-
_lib.lookupFunction<
202-
Int32 Function(RacHandle, Pointer<Float>, IntPtr, Pointer<Void>),
203-
int Function(
204-
RacHandle, Pointer<Float>, int, Pointer<Void>)>('rac_vad_component_process');
199+
static final int Function(
200+
RacHandle,
201+
Pointer<Float>,
202+
int,
203+
Pointer<RacVadResultStruct>,
204+
) vadProcess =
205+
_lib.lookupFunction<
206+
Int32 Function(
207+
RacHandle,
208+
Pointer<Float>,
209+
IntPtr,
210+
Pointer<RacVadResultStruct>,
211+
),
212+
int Function(
213+
RacHandle,
214+
Pointer<Float>,
215+
int,
216+
Pointer<RacVadResultStruct>,
217+
)>('rac_vad_component_process');
205218

206219
static final void Function(RacHandle) vadDestroy =
207220
_lib.lookupFunction<
@@ -309,7 +322,11 @@ abstract class NativeFunctions {
309322
_lib.lookupFunction<Void Function(RacHandle),
310323
void Function(RacHandle)>('rac_voice_agent_destroy');
311324

312-
static final void Function(Pointer<Void>) racFree =
313-
_lib.lookupFunction<Void Function(Pointer<Void>),
314-
void Function(Pointer<Void>)>('rac_free');
315-
}
325+
static final void Function(Pointer<Void>)? racFree = (() {
326+
try {
327+
return _lib.lookupFunction<Void Function(Pointer<Void>),
328+
void Function(Pointer<Void>)>('rac_free');
329+
} catch (_) {
330+
return null;
331+
}
332+
})();

0 commit comments

Comments
 (0)