Fix: Add delays in audio engine cleanup to prevent HALC_ProxyIOContext overload errors

This commit is contained in:
Beingpax 2025-02-25 21:17:48 +05:45
parent a798087759
commit c681c61463

View File

@ -742,6 +742,9 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
// Only cleanup temporary files, not the permanent recordings
audioEngine.stopAudioEngine()
// Add a small delay to allow audio system to complete its operations
try? await Task.sleep(nanoseconds: 100_000_000) // 100ms delay
// Release whisper resources if not needed
if !isRecording && !isProcessing {
await whisperContext?.releaseResources()
@ -785,6 +788,8 @@ class WhisperState: NSObject, ObservableObject, AVAudioRecorderDelegate {
// 5. Finally clean up resources
logger.info("Cleaning up resources")
// Add a small delay before cleanup to prevent audio overload
try? await Task.sleep(nanoseconds: 150_000_000) // 150ms delay
await cleanupResources()
logger.info("Mini recorder dismissal completed")
}