[Portaudio] Issue with Pa_OpenStream on WDM/KS hostAPI

sarang sapre sarangsapre at yahoo.com
Thu Dec 3 05:51:58 EST 2015

Thanks Robert. I am able to use WASAPI. 

However, I have one question . 

If the Sampling rate supported by Device is 48KHz, and we try to open it with 44.1KHz using paOpenStream(), it fails as expected. Error Code is paInvalidDevice (-9996).. I was thinking it would be paInvalidSamplingRate (-9997). 


----- Original Message -----
From: sarang sapre <sarangsapre at yahoo.com>
To: "portaudio at lists.columbia.edu" <portaudio at lists.columbia.edu>
Sent: Thursday, November 26, 2015 2:34 PM
Subject: Re: [Portaudio] Issue with Pa_OpenStream on WDM/KS hostAPI


   Thanks for the response... 

    Our Device supports only 48000 KHz , however On Windows Playback device settings I can set it wrongly to 44100 (Only under special sequence of usage). This becomes unusable playback device...  When such situation comes, query to Pa_DeviceCount and Pa_DeviceInfo gives me list of devices.. Our device is listed under 3 APIs  and each of them has different defaultSamplingRate 
1. Api = paMME, defaultFs = 44100
2. Api = paWASAPI, defaultFs = 44100
3. Api = paWDMKS, defaultFs = 48000 
We tried using Api =paWDM/Ks because defaultSamplingRate matches what our device supports... 

If I understand you now, Api=paWASAPI returns defaultFs = 44100, which should match whatever is there in Windows Playback device settings... If so, we will try to use paWASAPI going forwards... 

Please note that if we called paOpenStream only once, it will give us valid stream handle - but we could not play audio on it... 

We were calling paOpenStream twice w/o closeSteam inbetween... This just happened to be out of experiment as such sequence was giving us expected result.. Also causing closeStream in between was causing eventual crash for this particular scenario... 

Thanks and Best Regards,
Sarang Sapre 


From: Robert Bielik <robert.bielik at dirac.se>
To: portaudio at lists.columbia.edu 
Sent: Thursday, November 26, 2015 1:13 PM
Subject: Re: [Portaudio] Issue with Pa_OpenStream on WDM/KS hostAPI

Hi Sarang,

Den 2015-11-26 kl. 08:33, skrev sarang sapre:

While doing Pa_OpenStream we are using WDM/KS HostAPI device and passing sampleRate = 48000.  To my surprise it returns PaNoError and some valid stream handle. 
You should not be surprised. WDM/KS opens your device directly and does not care about what setting there is in Windows. If your device supports the settings, open stream will succeed.

Use WASAPI backend if you want to use the setting in Windows control

If I call Pa_OpenStream again with same settings I get NULL handle with error code -9996 . Basically from second call onwards I am getting error, but first call to Pa_OpenStream() is strangely successful
Do you call Pa_CloseStream in between ? 

>Simply calling Pa_OpenStream twice doesn’t help because it will start behaving strangely soon after.. 
Once the device is opened through Pa_OpenStream, you have to call Pa_CloseStream before calling Pa_OpenStream again.


Portaudio mailing list
Portaudio at lists.columbia.edu

More information about the Portaudio mailing list