From: Ross Bencina Date: Sat, 10 Sep 2016 13:43:30 +0000 (+1000) Subject: Cleanup: Check return code from waveOutMessage when polling for preferred devices... X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=1a95d6790b39d3e8bbe0ff2a4cf57e3ff8296855;p=portaudio Cleanup: Check return code from waveOutMessage when polling for preferred devices, don't assume that an OUT parameter is unchanged on error. Move #define DRVM_MAPPER_PREFERRED_GET to top of file with other #defines. --- diff --git a/src/hostapi/wmme/pa_win_wmme.c b/src/hostapi/wmme/pa_win_wmme.c index 5afaf8e..5c56815 100644 --- a/src/hostapi/wmme/pa_win_wmme.c +++ b/src/hostapi/wmme/pa_win_wmme.c @@ -123,6 +123,11 @@ #endif #endif /* PAWIN_USE_WDMKS_DEVICE_INFO */ +#if !defined(DRVM_MAPPER_PREFERRED_GET) +/* DRVM_MAPPER_PREFERRED_GET is defined in mmddk.h but we avoid a dependency on the DDK by defining it here */ +#define DRVM_MAPPER_PREFERRED_GET (0x2000+21) +#endif + /* use CreateThread for CYGWIN, _beginthreadex for all others */ #if !defined(__CYGWIN__) && !defined(_WIN32_WCE) #define CREATE_THREAD (HANDLE)_beginthreadex( 0, 0, ProcessingThreadProc, stream, 0, &stream->processingThreadId ) @@ -1013,19 +1018,15 @@ PaError PaWinMme_Initialize( PaUtilHostApiRepresentation **hostApi, PaHostApiInd winMmeHostApi->inputDeviceCount = 0; winMmeHostApi->outputDeviceCount = 0; -#if !defined(DRVM_MAPPER_PREFERRED_GET) -/* DRVM_MAPPER_PREFERRED_GET is defined in mmddk.h but we avoid a dependency on the DDK by defining it here */ -#define DRVM_MAPPER_PREFERRED_GET (0x2000+21) -#endif - - /* the following calls assume that if wave*Message fails the preferred device parameter won't be modified */ preferredDeviceStatusFlags = 0; waveInPreferredDevice = -1; - waveInMessage( (HWAVEIN)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveInPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags ); + if( waveInMessage( (HWAVEIN)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveInPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags ) != MMSYSERR_NOERROR ) + waveInPreferredDevice = -1; preferredDeviceStatusFlags = 0; waveOutPreferredDevice = -1; - waveOutMessage( (HWAVEOUT)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveOutPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags ); + if( waveOutMessage( (HWAVEOUT)WAVE_MAPPER, DRVM_MAPPER_PREFERRED_GET, (DWORD_PTR)&waveOutPreferredDevice, (DWORD_PTR)&preferredDeviceStatusFlags ) != MMSYSERR_NOERROR ) + waveOutPreferredDevice = -1; maximumPossibleDeviceCount = 0;