C++和pulseaudio“未在此范围内声明”

发布于 2024-08-02 07:57:19 字数 1663 浏览 3 评论 0原文

我正在尝试使用pulseaudio 来参加vorbis-stream 比赛,但遇到了问题。基本上我被告知:

‘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;
}

这可能是一些简单的错误,但如果有人能指出我正确的方向,那就太好了!

I'm trying to use pulseaudio to play the contest of a vorbis-stream but are hitting problems. Basicly I'm told that:

‘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

Some code are shown below:

#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;
}

It's probably some simple error, but if anyone could point me into the right direction, that would be great!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

咋地 2024-08-09 07:57:19

这些东西都在 simple.h 中定义,因此请在文件顶部添加一个新的 #include

#include <pulse/simple.h>

Those things are all defined in simple.h, so add a new #include to the top of your file:

#include <pulse/simple.h>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文