I'm attempting to write an application which requires fairly basic PortAudio functionality: data/samples are read in from a stream and then processed elsewhere in the application.
My problem arises on the call to
Pa_OpenStream() in which the error code -9985 for Device Unavailable is returned. The
PaStreamParameters struct passed into this function (an instance of the struct is only passed for input, the argument for output is a
nullptr as it is not necessary here) is instantiated with values found from
I am using (on a Windows 10 machine) a Focusrite Scarlett 2i2 for input and as such the two related drivers I have installed on my machine are Focusrite USB 2.0 Audio Driver 2.5.1 and Focusrite USB 188.8.131.524. The device name in PortAudio is labelled as Line In (Scarlett 2i2 USB).
Previously, the aforementioned error code wasn't returned and the code would run as intended, however, due to issues with other pieces of software, the drivers had to be reinstalled; I am unable to say with certainty as to whether the current drivers are the same version as that which are currently running.
After researching the problem, (see Portaudio won't play sound if another program is currently playing), I found that if I change the default playback device on windows from Line Out (Scarlett 2i2 USB) to some other playback device (e.g. built in laptop speakers), the stream can be opened without any issues.
I would like to be able to have Line Out (Scarlett 2i2 USB) set as the default playback device on my machine as my application requires audio output from non-PortAudio sources (e.g. the system uses the Windows MIDI API with the default MIDI device), and having it arrive through this device is more desirable to me. Is anyone able to help diagnose the issue here, and if so suggest a fix?
Many thanks in advance.