C ++和pulseaudio的“不在此范围内声明”
-
19-09-2019 - |
题
我想使用的PulseAudio发挥Vorbis格式流的比赛,但均创下的问题。 Basicly有人告诉我:
‘pa_simple’ was not declared in this scope
‘pa_simple_new’ was not declared in this scope
‘pa_simple_write’ was not declared in this scope
某些代码如下所示:
#include <pulse/pulseaudio.h>
pa_simple *s;
pa_sample_spec ss;
ss.format = PA_SAMPLE_S16NE;
ss.channels = 2;
ss.rate = 44100;
s = pa_simple_new(
NULL, // Use the default server.
"Fooapp", // Our application's name.
PA_STREAM_PLAYBACK, // Playback
NULL, // Use the default device.
"Music", // Description of our stream.
&ss, // Our sample format.
NULL, // Use default channel map
NULL, // Use default buffering attributes.
NULL, // Ignore error code.
);
while((samples=vorbis_synthesis_pcmout(&vd,&pcm))>0){
int j;
int bout=(samples<convsize?samples:convsize);
cout << "D" << endl;
for(i=0;i<vi.channels;i++){
ogg_int16_t *ptr=convbuffer+i;
float *mono=pcm[i];
for(j=0;j<bout;j++){
int val=floor(mono[j]*32767.f+.5f);
*ptr=val;
ptr+=vi.channels;
}
}
cout << "E" << endl;
#ifdef PulseAudio
pa_simple_write(s,convbuffer,2*vi.channels,NULL);
#else
fwrite(convbuffer,2*vi.channels,bout,output);
#endif
vorbis_synthesis_read(&vd,bout);
cout << "F" << endl;
}
这也可能是一些简单的错误,但如果有人可以点我到正确的方向,这将是伟大的!
解决方案
这些东西都定义在 simple.h ,所以添加一个新的#include
到文件的顶部:
#include <pulse/simple.h>
不隶属于 StackOverflow