Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash with mic device sample rate mismatch #69

Merged
merged 4 commits into from
Mar 12, 2024

Conversation

ZachNagengast
Copy link
Contributor

@ZachNagengast ZachNagengast commented Mar 11, 2024

Previously the inputNode was using the sample rate based on the hardware that the app was running on. When selecting a microphone that is connected to the device but has a different hardware sample rate, there was a crash occuring:

required condition is false: format.sampleRate == hwFormat.sampleRate

This updates that code to always use the correct sample rate for the selected microphone.

Note: This PR also includes some minor fixes for the example app and tests

@ZachNagengast ZachNagengast merged commit 9c4d8e0 into main Mar 12, 2024
2 checks passed
Comment on lines -538 to +540
inputNode.installTap(onBus: 0, bufferSize: bufferSize, format: inputFormat) { [weak self] (buffer: AVAudioPCMBuffer, _: AVAudioTime) in
inputNode.installTap(onBus: 0, bufferSize: bufferSize, format: nodeFormat) { [weak self] (buffer: AVAudioPCMBuffer, _: AVAudioTime) in

Choose a reason for hiding this comment

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

Would passing format: nil here work?

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