【发布时间】:2016-02-17 13:35:42
【问题描述】:
我有一个端口音频回调,它接受输入声音缓冲区并在缓冲区上执行 fft 以用于应用程序的其他部分。输出缓冲区未修改。我想捕捉其他应用程序写入默认输出音频设备的声音。但是,当以输出设备作为输入来初始化流时,端口音频会引发错误“通道数无效”。是否可以使用端口音频捕获写入输出设备的所有音频?流初始化代码如下:
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));
}
【问题讨论】: