From: rossb Date: Wed, 9 Dec 2009 01:55:50 +0000 (+0000) Subject: derive ds output channel count from speaker configuration when pnpInterface is unavai... X-Git-Tag: pa_stable_v19_20110326_r1647~195 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=0263158765c408964bfd2d21147370d0356a5689;p=portaudio derive ds output channel count from speaker configuration when pnpInterface is unavailable (eg wavemapper). Thanks to Dmitry Kostjuchenko for the patch. --- diff --git a/src/hostapi/dsound/pa_win_ds.c b/src/hostapi/dsound/pa_win_ds.c index 99a27f7..672c262 100644 --- a/src/hostapi/dsound/pa_win_ds.c +++ b/src/hostapi/dsound/pa_win_ds.c @@ -725,6 +725,40 @@ static PaError AddOutputDeviceInfoFromDirectSound( winDsDeviceInfo->deviceOutputChannelCountIsKnown = 1; } + /* Guess channels count from speaker configuration. We do it only when + pnpInterface is NULL or when PAWIN_USE_WDMKS_DEVICE_INFO is undefined. + */ +#ifdef PAWIN_USE_WDMKS_DEVICE_INFO + if( !pnpInterface ) +#endif + { + DWORD spkrcfg; + if( SUCCEEDED(IDirectSound_GetSpeakerConfig( lpDirectSound, &spkrcfg )) ) + { + int count = 0; + switch (DSSPEAKER_CONFIG(spkrcfg)) + { + case DSSPEAKER_HEADPHONE: count = 2; break; + case DSSPEAKER_MONO: count = 1; break; + case DSSPEAKER_QUAD: count = 4; break; + case DSSPEAKER_STEREO: count = 2; break; + case DSSPEAKER_SURROUND: count = 4; break; + case DSSPEAKER_5POINT1: count = 6; break; + case DSSPEAKER_7POINT1: count = 8; break; + case DSSPEAKER_7POINT1_SURROUND: count = 8; break; +#ifndef DSSPEAKER_5POINT1_SURROUND +#define DSSPEAKER_5POINT1_SURROUND 0x00000009 +#endif + case DSSPEAKER_5POINT1_SURROUND: count = 6; break; + } + if( count ) + { + deviceInfo->maxOutputChannels = count; + winDsDeviceInfo->deviceOutputChannelCountIsKnown = 1; + } + } + } + #ifdef PAWIN_USE_WDMKS_DEVICE_INFO if( pnpInterface ) {