Skip to content

Commit 412d0ac

Browse files
committed
Fix missing pre-connect error handler
1 parent 11504b8 commit 412d0ac

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/src/core/room_preconnect.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ extension RoomPreConnect on Room {
2626
Duration timeout = const Duration(seconds: 10),
2727
PreConnectOnError? onError,
2828
}) async {
29+
preConnectAudioBuffer.setErrorHandler(onError);
2930
await preConnectAudioBuffer.startRecording(timeout: timeout);
3031
try {
3132
final result = await operation();

lib/src/preconnect/pre_connect_audio_buffer.dart

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ class PreConnectAudioBuffer {
5353
EventChannel? _eventChannel;
5454
StreamSubscription? _streamSubscription;
5555

56-
final PreConnectOnError? _onError;
56+
PreConnectOnError? _onError;
5757
final int _requestSampleRate;
5858
int? _renderedSampleRate;
5959

@@ -301,4 +301,9 @@ class PreConnectAudioBuffer {
301301
logger.info(
302302
'[Preconnect audio] sent ${(data.length / 1024).toStringAsFixed(1)}KB of audio (${secondsOfAudio.toStringAsFixed(2)} seconds) to ${agents} agent(s)');
303303
}
304+
305+
/// Updates the callback invoked when pre-connect audio fails.
306+
void setErrorHandler(PreConnectOnError? onError) {
307+
_onError = onError;
308+
}
304309
}

0 commit comments

Comments
 (0)