Skip to content

Fix audio format handling and threading issues in SummaryTalk#1

Open
SilentMalachite wants to merge 1 commit into
mainfrom
fix-audio-and-threading-issues-16173873815300854753
Open

Fix audio format handling and threading issues in SummaryTalk#1
SilentMalachite wants to merge 1 commit into
mainfrom
fix-audio-and-threading-issues-16173873815300854753

Conversation

@SilentMalachite
Copy link
Copy Markdown
Owner

Identified and fixed critical issues in SystemAudioManager where audio buffers were being incorrectly manually converted and processed on the main thread.
Refactored SystemAudioManager to use SFSpeechAudioBufferRecognitionRequest.appendAudioSampleBuffer(_:) for native handling of CMSampleBuffer.
Moved heavy audio and network processing to background queues to improve UI responsiveness.
Fixed error handling in TranscriptionManager to correctly update recording state on errors.


PR created automatically by Jules for task 16173873815300854753 started by @SilentMalachite

- 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>
@google-labs-jules
Copy link
Copy Markdown

👋 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 @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

Copilot AI review requested due to automatic review settings January 30, 2026 08:56
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 SystemAudioManager to use native CMSampleBuffer handling via SFSpeechAudioBufferRecognitionRequest.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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants