Skip to content

Commit 56392dd

Browse files
Reef-7sanchitmonga22
authored andcommitted
Fix nullable racFree call, improve getHandle safety, remove unused import
1 parent eecf818 commit 56392dd

2 files changed

Lines changed: 14 additions & 11 deletions

File tree

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import 'package:ffi/ffi.dart';
1313
import 'package:runanywhere/foundation/logging/sdk_logger.dart';
1414
import 'package:runanywhere/native/ffi_types.dart';
1515
import 'package:runanywhere/native/native_functions.dart';
16-
import 'package:runanywhere/native/platform_loader.dart';
1716

1817
/// VAD component bridge for C++ interop.
1918
///
@@ -226,7 +225,12 @@ class DartBridgeVAD {
226225
samplesPtr[i] = samples[i];
227226
}
228227

229-
final status = NativeFunctions.vadProcess(handle, samplesPtr, samples.length, resultPtr);
228+
final status = NativeFunctions.vadProcess(
229+
handle,
230+
samplesPtr,
231+
samples.length,
232+
resultPtr.cast<Void>(),
233+
);
230234

231235
if (status != RAC_SUCCESS) {
232236
throw StateError(

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ void _safeRacFree(Pointer<Void> ptr) {
2424
if (ptr == nullptr) return;
2525

2626
try {
27-
NativeFunctions.racFree(ptr);
27+
NativeFunctions.racFree?.call(ptr);
2828
} catch (_) {
2929
// rac_free may not exist in some native builds
3030
}
@@ -73,10 +73,8 @@ class DartBridgeVoiceAgent {
7373
return _handle!;
7474
}
7575

76-
final initFuture = _initFuture;
77-
if (initFuture != null) {
78-
await initFuture;
79-
return _handle!;
76+
if (_initFuture != null) {
77+
return _initFuture!;
8078
}
8179

8280
final completer = Completer<RacHandle>();
@@ -618,10 +616,11 @@ final int Function(
618616
int,
619617
Pointer<RacVoiceAgentResultStruct>,
620618
) _processVoiceTurnFn = _voiceAgentLib.lookupFunction<
621-
Int32 Function(RacHandle, Pointer<Void>, IntPtr,
622-
Pointer<RacVoiceAgentResultStruct>),
623-
int Function(RacHandle, Pointer<Void>, int,
624-
Pointer<RacVoiceAgentResultStruct>)>('rac_voice_agent_process_voice_turn');
619+
Int32 Function(RacHandle, Pointer<Void>, IntPtr,
620+
Pointer<RacVoiceAgentResultStruct>),
621+
int Function(
622+
RacHandle, Pointer<Void>, int, Pointer<RacVoiceAgentResultStruct>)>(
623+
'rac_voice_agent_process_voice_turn');
625624

626625
final void Function(Pointer<RacVoiceAgentResultStruct>)?
627626
_voiceAgentResultFreeFn = (() {

0 commit comments

Comments
 (0)