如何编译自定义 PulseAudio 模块?
How to compile custom PulseAudio module?
我正在尝试编写 PulseAudio 模块。首先,我为 this 文档中提到的模块编写了以下最小代码。
#include <pulsecore/module.h>
int pa__init(pa_module *m)
{
return 0;
}
我尝试用这个命令编译它:
gcc -g -shared -o module-test.so module-test.c
但是报错:
pulsecore/module.h: No such file or directory
#include <pulsecore/module.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
在网上搜索后,我发现我必须安装libpulse-dev
,但我已经安装了pulseaudio
和libpulse-dev
,如下所示。
jyotesh@jyotesh-VM:~$ sudo apt install pulseaudio libpulse-dev
[sudo] password for jyotesh:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libpulse-dev is already the newest version (1:11.1-1ubuntu7.2).
pulseaudio is already the newest version (1:11.1-1ubuntu7.2).
0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
我已经尝试使用 locate
、find
、apt-file
等搜索头文件。我找不到这个头文件在哪里。
有人知道如何编译 PulseAudio 模块吗?
我能够按照 here and here 中的步骤编译代码并构建 module-test.so
文件。我将在这里重复这些步骤:
首先,我从源代码构建并安装了 PulseAudio v12.2。
# Clone PulseAudio git repository
git clone https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
# I wanted 12.2 version of PulseAudio, so I checked out that version
cd pulseaudio
git checkout tags/v12.2
# Install the dependencies
sudo apt-get -y build-dep pulseaudio
# Build PulseAudio source code
./bootstrap.sh
make
# Install and configure dynamic linker run-time bindings (so that
# ld can find the libraries that you specify while building your module)
sudo make install
sudo ldconfig
在此之后,我为模块编写了最少的代码。
#include <config.h> // this is required, otherwise you will get compilation errors
#include <pulsecore/module.h>
int pa__init(pa_module *m)
{
return 0;
}
为了编译它,我使用了命令
gcc -g -shared -fPIC -I/home/jyotesh/pulseaudio -I/home/jyotesh/pulseaudio/src -L/home/jyotesh/pulseaudio/.libs -L/usr/local/lib/pulseaudio -o module-test.so module-test.c -lpulsecore-12.2 -lpulsecommon-12.2 -lpulse
我正在尝试编写 PulseAudio 模块。首先,我为 this 文档中提到的模块编写了以下最小代码。
#include <pulsecore/module.h>
int pa__init(pa_module *m)
{
return 0;
}
我尝试用这个命令编译它:
gcc -g -shared -o module-test.so module-test.c
但是报错:
pulsecore/module.h: No such file or directory
#include <pulsecore/module.h>
^~~~~~~~~~~~~~~~~~~~
compilation terminated.
在网上搜索后,我发现我必须安装libpulse-dev
,但我已经安装了pulseaudio
和libpulse-dev
,如下所示。
jyotesh@jyotesh-VM:~$ sudo apt install pulseaudio libpulse-dev
[sudo] password for jyotesh:
Reading package lists... Done
Building dependency tree
Reading state information... Done
libpulse-dev is already the newest version (1:11.1-1ubuntu7.2).
pulseaudio is already the newest version (1:11.1-1ubuntu7.2).
0 upgraded, 0 newly installed, 0 to remove and 10 not upgraded.
我已经尝试使用 locate
、find
、apt-file
等搜索头文件。我找不到这个头文件在哪里。
有人知道如何编译 PulseAudio 模块吗?
我能够按照 here and here 中的步骤编译代码并构建 module-test.so
文件。我将在这里重复这些步骤:
首先,我从源代码构建并安装了 PulseAudio v12.2。
# Clone PulseAudio git repository
git clone https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
# I wanted 12.2 version of PulseAudio, so I checked out that version
cd pulseaudio
git checkout tags/v12.2
# Install the dependencies
sudo apt-get -y build-dep pulseaudio
# Build PulseAudio source code
./bootstrap.sh
make
# Install and configure dynamic linker run-time bindings (so that
# ld can find the libraries that you specify while building your module)
sudo make install
sudo ldconfig
在此之后,我为模块编写了最少的代码。
#include <config.h> // this is required, otherwise you will get compilation errors
#include <pulsecore/module.h>
int pa__init(pa_module *m)
{
return 0;
}
为了编译它,我使用了命令
gcc -g -shared -fPIC -I/home/jyotesh/pulseaudio -I/home/jyotesh/pulseaudio/src -L/home/jyotesh/pulseaudio/.libs -L/usr/local/lib/pulseaudio -o module-test.so module-test.c -lpulsecore-12.2 -lpulsecommon-12.2 -lpulse