I have a port audio callback which takes an input sound buffer and performs an fft on the buffer for use in other portions of the application. The output buffer is not modified. I would like to catch the sound written to the default output audio device by other applications. However, when initializing a stream with the output device as input, port audio throws an error 'invalid number of channels'. Is it possible to catch all audio written to an output device using port audio? The stream initialization code is below:
PaStreamParameters inputParams;
inputParams.device = Pa_GetDefaultOutputDevice();
inputParams.channelCount = 2;
inputParams.sampleFormat = paFloat32;
const PaDeviceInfo * inputInfo = Pa_GetDeviceInfo(inputParams.device);
inputParams.suggestedLatency = inputInfo->defaultLowOutputLatency;
inputParams.hostApiSpecificStreamInfo = NULL;
error = Pa_OpenStream( &_pInputStream,
&inputParams,
NULL,
inputInfo->defaultSampleRate,
paFramesPerBufferUnspecified,
0,
coreAudioCallback,
this);
if( error != paNoError ){
printf("Port audio error = %s", Pa_GetErrorText(error));
}