Fix audio format handling and threading issues in SummaryTalk#1
Fix audio format handling and threading issues in SummaryTalk#1SilentMalachite wants to merge 1 commit into
Conversation
- Refactor `SystemAudioManager` to process audio on a background queue and pass `CMSampleBuffer` directly to `TranscriptionManager`, avoiding incorrect manual conversion to `AVAudioPCMBuffer` and fixing potential audio corruption. - Update `TranscriptionManager` to use the new `SystemAudioManager` API and properly handle recording state/errors. - Move `IPtalkManager` networking operations to a dedicated background queue to prevent main thread blocking. - Add `CoreMedia` import where necessary. Co-authored-by: SilentMalachite <84108752+SilentMalachite@users.noreply.github.com>
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
There was a problem hiding this comment.
Pull request overview
This PR refactors audio handling and threading in SummaryTalk to improve performance and code quality. It addresses critical issues where audio buffers were being manually converted and processed on the main thread, replacing this with native framework APIs and background queue processing.
Changes:
- Refactored
SystemAudioManagerto use nativeCMSampleBufferhandling viaSFSpeechAudioBufferRecognitionRequest.appendAudioSampleBuffer(_:), eliminating complex manual audio format conversion - Moved heavy audio processing and network operations to dedicated background queues to improve UI responsiveness
- Enhanced error handling to properly update recording state when errors occur
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| SummaryTalk/Models/TranscriptionManager.swift | Refactored to use native CMSampleBuffer handling, improved error recovery by calling stopRecording() on errors, added defensive check for audioEngine.isRunning |
| SummaryTalk/Models/SystemAudioManager.swift | Removed manual audio conversion code (~47 lines), changed to pass CMSampleBuffer directly to handler, moved audio processing to background audioQueue |
| SummaryTalk/Models/IPtalkManager.swift | Moved network listener and connection operations to dedicated background queue while properly marshaling state updates to MainActor |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Identified and fixed critical issues in
SystemAudioManagerwhere audio buffers were being incorrectly manually converted and processed on the main thread.Refactored
SystemAudioManagerto useSFSpeechAudioBufferRecognitionRequest.appendAudioSampleBuffer(_:)for native handling ofCMSampleBuffer.Moved heavy audio and network processing to background queues to improve UI responsiveness.
Fixed error handling in
TranscriptionManagerto correctly update recording state on errors.PR created automatically by Jules for task 16173873815300854753 started by @SilentMalachite