PipeWire是一个新的低级多媒体框架。它旨在以最小的延迟为音频和视频提供捕获和播放,并支持基于 PulseAudio、JACK、ALSA 和 GStreamer 的应用程序。
基于该框架的守护进程可以配置为音频服务器(具有 PulseAudio 和 JACK 功能)和视频捕获服务器。
PipeWire 还支持 Flatpak 等容器,并且不依赖音频和视频用户组。取而代之的是,它使用类似 Polkit 的安全模型,要求 Flatpak 或 Wayland 允许录制屏幕或音频。
在 Ubuntu 上默认迁移到 PipeWire 是从当前版本Ubuntu 22.04 LTS (Jammy Jellyfish)开始的,该版本同时附带了 PipeWire 和 PulseAudio,但 PipeWire 仅用于 Wayland 上的截屏和屏幕共享,而 PulseAudio 仍用于音频处理。在即将发布的Ubuntu 22.10 (Kinetic Kudu)版本中,PulseAudio 将被删除,取而代之的是 PipeWire,这一举措也得到了ubuntu-meta软件包最近更改的证实。
PipeWire 目前是 GNU/Linux 发行版采用最多的开源技术。PipeWire 由 Red Hat 的 Wim Taymans 创建,是一种用于在基于 Linux 的系统上处理音频、视频流和硬件的服务器,它已经被 Fedora Linux、Slackware、OpenMandriva Lx、EndeavourOS 等流行发行版采用。
看来PulseAudio已经走到了生命的尽头,技术更新换代太快。并不是说PulseAuido不好,在一段时间里它支撑着Linux音频平台所有应用,只是随着安全性等需求在Linux桌面平台的逐步增强,PipeWire作为后起之秀替代PulseAudio成为必然。
Ubuntu2004上编译PipeWire
PipeWire的编译并不复杂,学习阶段建议你直接通过源码编译安装,并通过调试的方式熟悉代码。
1. 获取代码
git clone https://gitlab.freedesktop.org/pipewire/pipewire.git
获取后切换到某个tag分支,这里我们采用的是最新的分支:1.0.4
2. 编译
在编译PierWire之前,我们先介绍一个概念:会话管理器(session manager)。与 JACK 一样,PipeWire 在内部不实现任何连接逻辑。监视新流并将它们连接到适当的输出设备或应用程序的负担留给称为会话管理器的外部组件。
目前唯一推荐的会话管理器是WirePlumber:它基于模块化设计,具有实现实际管理功能的 Lua 插件。(搞不懂老外为啥要在一个工程里引入Lua这种解析性语言)。
还有一个会话管理器是PipeWire Media Session,不过已经被弃用,取而代之的是 WirePlumber,不过可以作为学习目的而使用。Pipewire Media Session是一个非常简单的会话管理器,可以满足一些基本的桌面用例。它主要用于测试,并作为构建新会话管理器的示例。
可以通过修改meson_options.txt文件来选择使用哪个回话管理器:value的可选值为wireplumber或者media-session。
option('session-managers',
description : 'Session managers to build (can be [] for none or an absolute path)',
type : 'array',
value : ['wireplumber'])
2.1 glib版本问题
在编译wireplumber的时候,编译系统会检测glib的版本。不建议系统升级glib版本,容易引起系统异常。可以根据系统目前提供的版本,直接修改meson.build文件即可:
glib_req_version = '>= 2.64'
add_project_arguments([
'-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_64',
'-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_64',
], language: 'c'
)
譬如我的2004系统默认安装的glib版本是2.64,所以我这里直接修改为2.64即可编译。
2.2 debug版本调试
同时为了使用GDB进行调试,可以关闭优化等级
- 1 修改buildtype为debug
project('pipewire', ['c' ],
version : '1.0.4',
license : [ 'MIT', 'LGPL-2.1-or-later', 'GPL-2.0-only' ],
meson_version : '>= 0.61.1',
default_options : [ 'warning_level=3',
'c_std=gnu11',
'cpp_std=c++17',
'b_pie=true',
#'b_sanitize=address,undefined',
'buildtype=debug' ])
1.2 查找系统中的O3选项,并统一替换为O0。使用vscode的统一替换即可完成
+ c_args : [avx2_args, '-O0', '-DHAVE_AVX2'], dependencies : [ spa_dep ], install : false ) @@ -97,7 +97,7 @@ if have_neon audioconvert_neon = static_library('audioconvert_neon', ['resample-native-neon.c', 'fmt-ops-neon.c' ], - c_args : [neon_args, '-O3', '-DHAVE_NEON'], + c_args : [neon_args, '-O0', '-DHAVE_NEON'], dependencies : [ spa_dep ], install : false ) @@ -113,7 +113,7 @@ audioconvert_lib = static_library('audioconvert', 'resample-peaks.c', 'wavfile.c', 'volume-ops.c' ], - c_args : [ simd_cargs, '-O3'], + c_args : [ simd_cargs, '-O0'], link_with : simd_dependencies, include_directories : [configinc], dependencies : [ spa_dep ], @@ -131,7 +131,7 @@ spa_audioconvert_dep = declare_dependency(link_with: spa_audioconvert_lib) test_lib = static_library('test_lib', ['test-source.c' ], - c_args : ['-O3'], + c_args : ['-O0'], dependencies : [ spa_dep ], install : false ) diff --git a/spa/plugins/audiomixer/meson.build b/spa/plugins/audiomixer/meson.build index 65aafee20..839dce474 100644 --- a/spa/plugins/audiomixer/meson.build +++ b/spa/plugins/audiomixer/meson.build @@ -9,7 +9,7 @@ simd_dependencies = [] audiomixer_c = static_library('audiomixer_c', ['mix-ops-c.c' ], - c_args : ['-O3'], + c_args : ['-O0'], dependencies : [ spa_dep ],
2.3 依赖包
pw-cat、pw-play等bin文件依赖sndfile,执行如下命令:
sudo apt install -y libsndfile1-dev
Backend选项依赖ALSA,执行如下命令:
sudo apt install -y libasound2-dev
2.4 prefix安装路径
建议制定prefix安装路径,而不是安装到默认的系统路径,防止对系统的修改。因人而异,也可以直接安装到系统,只是习惯问题。
执行编译命令并生成相关makefie:
./autogen.sh --prefix=/home/yji/oss/install
编译完成后最终输入如下log信息:
wireplumber 0.5.1 Lua version : 5.4.4 (built-in) systemd conf data : YES libsystemd : YES libelogind : NO For documentation Python 3 Sphinx related modules: NO Doxygen : YES sphinx-build : NO For introspection Python 3 lxml module : NO Doxygen : YES g-ir-scanner : NO pipewire 1.0.4 systemd conf data : YES libsystemd : YES libselinux : YES intl support : YES pipewire-alsa : YES OpenSSL (for raop-sink) : NO lilv (for lv2 plugins) : NO ffado : NO RLIMITs : with limits.d file affecting matching PAM users PAM defaults : without limits.d file affecting all PAM users (not needed with modern systemd or kernel) Documentation : NO Man pages : NO Misc dependencies dbus (Bluetooth, rt, portal, pw-reserve): YES SDL2 (video examples) : NO opus (Bluetooth, RTP) : NO readline (for pw-cli) : YES X11 (x11-bell) : NO libcanberra (x11-bell) : NO GLib-2.0 (Flatpak support) : YES GIO (GSettings) : YES WebRTC Echo Canceling < 1.0 : NO Vulkan : NO pw-cat/pw-play/pw-dump/filter-chain sndfile : YES filter-chain libmysofa : NO Streaming between daemons libpulse : NO Avahi DNS-SD (Zeroconf) : NO Opus with custom modes for NetJack2 : NO ROC : NO Backend libusb (Bluetooth quirks) : NO gstreamer-device-provider : NO ALSA : YES Bluetooth audio : NO JACK2 : NO libcamera : NO Compress-Offload : YES Udev : YES V4L2 kernel header : YES V4L2 enabled : YES GStreamer modules glib-2.0 : YES gobject-2.0 : YES gmodule-2.0 : YES gio-2.0 : YES gio-unix-2.0 : YES gstreamer-1.0 : NO Bluetooth audio codecs SBC : NO Optional programs find (for header testing) : YES valgrind (test setup) : NO Session managers Build media-session : NO Build wireplumber : YES Default session-manager : wireplumber pw-cat/pw-play/pw-dump tool Build pw-cat tool : YES Build pw-cat with FFmpeg integration : NO Optional Modules jack-tunnel : NO ffado-driver : NO rt : with RTKit portal : YES pulse-tunnel : NO zeroconf-discover : NO raop-discover (needs Avahi) : NO raop-sink (requires OpenSSL) : NO roc-sink : NO roc-source : NO x11-bell : NO avb : YES Functional test programs openal-info : NO pactl : YES Subprojects lua : YES (from wireplumber) wireplumber : YES 1 warnings User defined options prefix : /home/yji/oss/install
2.5 编译并安装
make -j32 sudo make install
所有产物均被安装到根目录的oss/install路劲
~/oss/install$ ls bin etc include lib share
~/oss/install/bin$ ls pipewire pipewire-pulse pw-config pw-dump pw-link pw-mididump pw-mon pw-record pw-v4l2 spa-json-dump wireplumber pipewire-aes67 pw-cat pw-dot pw-encplay pw-loopback pw-midiplay pw-play pw-reserve spa-acp-tool spa-monitor wpctl pipewire-avb pw-cli pw-dsdplay pw-jack pw-metadata pw-midirecord pw-profiler pw-top spa-inspect spa-resample wpexec
看到了我们心爱的piepwire和wireplumber可执行文件。
参考文献:
https://wiki.archlinux.org/title/PipeWire
浙公网安备 33010602011771号