-
Notifications
You must be signed in to change notification settings - Fork 290
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
WASAPI gets the channel count wrong for some devices #286
Comments
Comment by @dechamps The code is getting the default device format using this code:
This is then fed into MSDN seems to be somewhat conflicted about the use of "This format might not be the best default format for an exclusive-mode application to use." But on the other hand: "An application can query an audio endpoint device's PKEY_AudioEngine_DeviceFormat property to obtain the shared-mode format that the user has selected for the device. For information about querying the properties of a device, see Device Properties. Some applications might find the format specified by a device's PKEY_AudioEngine_DeviceFormat property to be a suitable format for opening an exclusive-mode stream on the device." Here this is clearly not true, since the user surely never selected 8 channels for a built-in microphone input. This looks like a Windows bug. In any case, it seems like it would make more sense to use the IAudioClient::GetMixFormat() method anyway: "When creating a shared-mode stream for an audio endpoint device, the Initialize method always accepts the stream format obtained from a GetMixFormat call on the same device." I believe this makes most sense for the channel count returned by PortAudio, because shared mode is the default in PortAudio. If we want PortAudio users to be able to simply enumerate devices and be able to open them without having to care about host API specifics (which seems like what PortAudio is designed to do), then we should optimize for shared mode. That said, regarding exclusive mode, the same page goes on to say: "This format is not necessarily a format that the audio endpoint device supports. Thus, the caller might not succeed in creating an exclusive-mode stream with a format obtained by calling GetMixFormat." Therefore, it seems like the best way to fix this is to do the following:
It's actually highly likely that this format will work for exclusive mode too, because it looks like the difference would be only on the sample type, and PortAudio can already automatically handle such differences through implicit sample type conversion (which already works). Therefore I am not convinced that we actually need to use PKEY_AudioEngine_DeviceFormat at all. Worst case scenario we could expose a separate WASAPI-specific function for it. |
Comment by @dechamps Here's what I'm getting from
This is what I'd expect. Now I'll get my user with the offending hardware to try this and see what happens. |
Issue closed by @dechamps |
Issue created by @dechamps
This was originally a FlexASIO bug, which I am now reporting upstream.
For some audio devices, the WASAPI PortAudio code reports a channel count (both in
PaDeviceInfo
and fromPaWasapi_GetDeviceDefaultFormat()
) that is completely wrong.Specifically, I have a user for whom PortAudio returns the following:
This is for the built-in microphone input of a MSI GS63VR 7RG Stealth Pro running Windows 10.0.17134.
It goes without saying that the microphone input of a laptop is definitely not an 8-channel 7.1 audio input device. Trying to open it with 8 channels (in shared and exclusive mode), unsurprisingly, fails.
All other host APIs (MME, DirectSound, and WDM-KS) correctly report 2 channels for this device.
Relevant portion of the PortAudio debug log:
Both
pa_stable_v190600_20161030
and latest PortAudio master (0cdb346
) exhibit this problem.Sadly, I am unable to reproduce this using any of my own hardware. I only know of a single end user who is experiencing this bug.
The text was updated successfully, but these errors were encountered: