Skip to content

Comments

Improve multi-channel playback compatibility in WASAPI exclusive mode#1234

Open
kashiken wants to merge 4 commits intonaudio:masterfrom
kashiken:feature_wasapi_flex_multich
Open

Improve multi-channel playback compatibility in WASAPI exclusive mode#1234
kashiken wants to merge 4 commits intonaudio:masterfrom
kashiken:feature_wasapi_flex_multich

Conversation

@kashiken
Copy link

This PR improves playback compatibility for multi-channel audio devices in WASAPI exclusive mode.

Purpose of Change

In the current code, dwChannelMask in the WaveFormatExtensible constructor is set by simply shifting and OR-ing bits based on the number of channels.
However, actual multi-channel audio devices return values that differ from this, because Windows expects the standard speaker placements defined in ksmedia.h and devices follow that specification.

Changes

  • Add an optional channelMask argument to the WaveFormatExtensible constructor.
    • If channelMask is not zero, dwChannelMask will be set to channelMask.
    • Otherwise, dwChannelMask is set as before.
  • Extend GetFallbackFormat() to try additional channel masks as well as sampling rates, channel counts, and bit depths.

Tests

Tested with a 4-channel USB audio device (channel mask 0x33 = KSAUDIO_SPEAKER_QUAD).
It cannot play back in WASAPI exclusive mode with the current code, but playback works after this change.

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.

1 participant