Skip to content

Commit 327cb50

Browse files
Reef-7sanchitmonga22
authored andcommitted
Fix compile error and restore rac_free error handling in voice agent bridge
1 parent 3c16253 commit 327cb50

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ class DartBridgeVoiceAgent {
6666
}
6767

6868
try {
69-
final lib = PlatformLoader.loadCommons();
70-
7169
// Use shared component handles (matches Swift approach)
7270
// This allows the voice agent to use already-loaded models from the
7371
// individual component bridges (STT, LLM, TTS, VAD)
@@ -110,7 +108,6 @@ class DartBridgeVoiceAgent {
110108
if (_handle == null) return false;
111109

112110
try {
113-
final lib = PlatformLoader.loadCommons();
114111
final readyPtr = calloc<Int32>();
115112
try {
116113
final result = NativeFunctions.voiceAgentIsReady(_handle!, readyPtr);
@@ -128,7 +125,6 @@ class DartBridgeVoiceAgent {
128125
if (_handle == null) return false;
129126

130127
try {
131-
final lib = PlatformLoader.loadCommons();
132128
final loadedPtr = calloc<Int32>();
133129
try {
134130
final result = NativeFunctions.voiceAgentIsSTTLoaded(_handle!, loadedPtr);
@@ -146,7 +142,6 @@ class DartBridgeVoiceAgent {
146142
if (_handle == null) return false;
147143

148144
try {
149-
final lib = PlatformLoader.loadCommons();
150145
final loadedPtr = calloc<Int32>();
151146
try {
152147
final result = NativeFunctions.voiceAgentIsLLMLoaded(_handle!, loadedPtr);
@@ -164,7 +159,6 @@ class DartBridgeVoiceAgent {
164159
if (_handle == null) return false;
165160

166161
try {
167-
final lib = PlatformLoader.loadCommons();
168162
final loadedPtr = calloc<Int32>();
169163
try {
170164
final result = NativeFunctions.voiceAgentIsTTSLoaded(_handle!, loadedPtr);
@@ -466,7 +460,11 @@ class DartBridgeVoiceAgent {
466460
calloc.free(textPtr);
467461
// Free the audio data allocated by C++
468462
if (audioPtr.value != nullptr) {
469-
NativeFunctions.racFree(audioPtr.value);
463+
try {
464+
NativeFunctions.racFree(audioPtr.value);
465+
} catch (_) {
466+
// `rac_free` may not exist in some native builds.
467+
}
470468
}
471469
calloc.free(audioPtr);
472470
calloc.free(audioSizePtr);

0 commit comments

Comments
 (0)