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

Use correct number of channels for the selected CoreAudio stream #422

Merged

Conversation

mikedickey
Copy link
Contributor

The kAudioStreamPropertyPhysicalFormat query returns the number of channels for the device's first audio stream. If any single, subsequent stream is selected to fulfill the user request, it may use a different number of channels. This mismatch can cause a lot of problems.

The kAudioStreamPropertyPhysicalFormat query returns the number
of channels for the device's first audio stream. If any single,
subsequent stream is selected to fulfill the user request, it may
use a different number of channels. This mismatch can cause a lot
of problems.
@mikedickey
Copy link
Contributor Author

I know very little about this API, but I wasn't sure if this is the correct approach versus modifying the AudioObjectGetPropertyData commands so that the stream id is passed into them? Perhaps that is what the inQualifierData fields are for?

@mikedickey
Copy link
Contributor Author

@garyscavone I believe this is a pretty bad bug, which causes very bad audio distortion (and possibly crashes) when using certain interfaces on OSX.

@garyscavone
Copy link
Contributor

The relevant code is quite old. I don't disagree that this may be a bug but I'm surprised it hasn't been flagged earlier. Part of the problem is that the whole multiple-stream per device scenario is quite confusing and almost impossible to test adequately. Just to confirm, you did experience poor audio and this proposed change fixed it? Do you know what audio device it happened with?

@mikedickey
Copy link
Contributor Author

The relevant code is quite old. I don't disagree that this may be a bug but I'm surprised it hasn't been flagged earlier. Part of the problem is that the whole multiple-stream per device scenario is quite confusing and almost impossible to test adequately. Just to confirm, you did experience poor audio and this proposed change fixed it? Do you know what audio device it happened with?

@garyscavone Yes, specifically I encountered this when using an RME Babyface Pro FS device. It reports several streams, which total up to the 12 channels supported. If you use channels from the first stream (0-3) it works fine. If you try to use channels 4+ the callback is triggered with a different number of channels (2 versus 4 if I remember correctly), and this causes really bad audio garble.

This fix ensures that the number of channels expected by the callback is correct regardless of which stream is chosen, and the number of channels on it. After applying it all channels including 4-11 work great with the RME.

@garyscavone garyscavone merged commit cb03db3 into thestk:master Feb 22, 2024
12 checks passed
@garyscavone
Copy link
Contributor

Many thanks!

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