我想使用 PortAudio 库来播放音频数据。此音频数据来自 UDP paquets。
我看到有 Pa_OpenDefaultStream() (和 Pa_OpenStream() 非常相似)函数来打开一个流:
PaStream *stream;
PaError err;
/* Open an audio I/O stream. */
err = Pa_OpenDefaultStream( &stream,
0, /* no input channels */
2, /* stereo output */
paFloat32, /* 32 bit floating point output */
SAMPLE_RATE,
256, /* frames per buffer, i.e. the number
of sample frames that PortAudio will
request from the callback. Many apps
may want to use
paFramesPerBufferUnspecified, which
tells PortAudio to pick the best,
possibly changing, buffer size.*/
patestCallback, /* this is your callback function */
&data ); /*This is a pointer that will be passed to
your callback*/
我想我必须用它来玩我的 paquets 但我不知道如何使用它:
- 第一个参数是什么?
- 为什么我必须定义一个回调函数?
这是 PortAudio 文档的链接:http ://www.portaudio.com/trac/
任何帮助将不胜感激 :)
谢谢。