openclaw/apps/macos/Sources/ObjCExceptionCatcher/include/ObjCExceptionCatcher.h
liji 46aa3205e4 feat(voice-wake): integrate ObjCExceptionCatcher for safe audio tap installation
- Added ObjCExceptionCatcher to handle Objective-C exceptions during AVAudioNode tap installation, preventing crashes when the audio subsystem is not fully initialized.
- Introduced a 0.5s delay before starting the voice wake runtime to ensure the audio subsystem is ready, reducing the risk of AVAudioEngine errors.
- Updated VoiceWakeRuntime to utilize the new exception catcher and implemented retry logic for starting the runtime with exponential backoff.

This enhances the stability of the voice wake feature during app launch.
2026-01-27 16:40:59 +08:00

18 lines
887 B
Objective-C

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
NS_ASSUME_NONNULL_BEGIN
/// Safely tries to install a tap on an AVAudioNode, catching any Objective-C exceptions.
/// @param node The audio node to install the tap on.
/// @param bus The bus number to tap.
/// @param bufferSize The size of the audio buffer.
/// @param format The audio format (pass nil to use the node's native format).
/// @param block The block to call with audio buffers.
/// @param outError If non-nil and an exception occurs, contains error info about the exception.
/// @return YES if the tap was installed successfully, NO if an exception was thrown.
BOOL CBTryInstallTap(AVAudioNode *node, AVAudioNodeBus bus, AVAudioFrameCount bufferSize,
AVAudioFormat * _Nullable format, AVAudioNodeTapBlock block, NSError * _Nullable * _Nullable outError);
NS_ASSUME_NONNULL_END