Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
c82d3dc
Removes outdated comment
MasonRemaley Nov 4, 2025
b39754b
Temporarily links everything dynamically
MasonRemaley Nov 5, 2025
0b225c9
Stubs out dlopen/dlclose/dlsym/dlerror
MasonRemaley Nov 5, 2025
aa444ef
Progress on dlfcn stub, need to try wirign up to actual symbols now
MasonRemaley Nov 5, 2025
751a5e6
Adds actual symbols to table
MasonRemaley Nov 5, 2025
004267e
Temporarily disables SDL in example so we can test without dynamic li…
MasonRemaley Nov 5, 2025
93d6718
Adds all modules and plugins for screen play example, namespaces symb…
MasonRemaley Nov 8, 2025
b1a88b6
Adds stubs for when RTLD_NEXT is passed in
MasonRemaley Nov 8, 2025
1a2976b
Caches translated headers to work around translate c issue
MasonRemaley Nov 14, 2025
35059f9
Fixes bitcasts of sizeofs
MasonRemaley Nov 14, 2025
47ddef3
Gets example working in Zig, but still using SDL + needs a lot of cle…
MasonRemaley Nov 15, 2025
91800db
Allows linking to pipewire via static library or Zig module
MasonRemaley Nov 20, 2025
e8c590e
Documents some of the tricky stuff going on to make easier to maintain
MasonRemaley Nov 20, 2025
831d915
WIP - embedding configuration
MasonRemaley Nov 20, 2025
17f385f
Progress wrapping standard calls
MasonRemaley Nov 20, 2025
b81a3fc
Progress towards faking config file loading
MasonRemaley Nov 20, 2025
5f02774
Finishes removing requirement to have config file present
MasonRemaley Nov 20, 2025
09c2d6b
Fixes build with use zig module set to false
MasonRemaley Nov 20, 2025
deda59f
Updates README
MasonRemaley Nov 20, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@

Pipewire client library, ported to the Zig build system.


## Motivation

I want a static executable that can play audio and turn screen contents into a video feed.
I want a static executable that can play audio and turn screen contents into a video feed. The pipewire library makes heavy use of `dlopen` internally, so this is nontrivial.

## Status

I got the screen-play example that displays the current webcam feed compiling and running (see `zig build screen-play`.)

The pipewire library makes heavy use of `dlopen` internally, so further work will be needed to link statically to it.
You can run the `video-play` example with `zig build video-play` to see the current webcam feed. This currently works without pipewire accessing the dynamic linker, but the example executable uses SDL so it still has access to it. I plan to port the example away from SDL so that this can be changed.
601 changes: 336 additions & 265 deletions build.zig

Large diffs are not rendered by default.

4 changes: 4 additions & 0 deletions build.zig.zon
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
.url = "git+https://github.com/allyourcodebase/SDL3#af9c32ce4824e0ad4337447434c40f2b672faf94",
.hash = "sdl-0.0.0-i4QD0btgqAABajEXrQnyZr1xVsk7LM48w2nBmuQ5gdfr",
},
.zin = .{
.url = "git+https://github.com/marler8997/zin#d3e230690f09debdb99dffe4586ad19f9dfb4716",
.hash = "zin-0.0.0-W7QDx6kKAwCVg-wWMO4FdpvZMH66NJpc9wFDdxp5c8E2",
},
},
.paths = .{
"LICENSE",
Expand Down
19 changes: 15 additions & 4 deletions src/generate_conf.zig → src/build/generate_client_conf.zig
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Generates the pipewire client config. We can almost use `addConfigHeader` for this with the
//! `autoconf_at` style, but not quite as it adds a c style comment to the first line (explaining
//! that the file is generated) which isn't allowed by this syntax.

const std = @import("std");
const options = @import("options");

const assert = std.debug.assert;

/// Generate the pipewire config. We can almost use `addConfigHeader` for this with the
/// `autoconf_at` style, but not quite as it adds a c style comment to the first line (explaining
/// that the file is generated) which isn't allowed by this syntax.
pub fn main() !void {
var gpa = std.heap.GeneralPurposeAllocator(.{ .thread_safe = false }){};
defer if (gpa.deinit() != .ok) @panic("leak detected");
Expand All @@ -32,6 +32,17 @@ pub fn main() !void {
var output_buf: [4096]u8 = undefined;
var writer = output.writerStreaming(&output_buf);

// Ideally we'd just use embed file rather than emit this warning but I'm having trouble
// getting `addEmbedPath` to work, so this will do for now. Not sure if this is a bug or user
// error.
try writer.interface.writeAll("# ");
try writer.interface.splatByteAll('#', 80 - 2);
try writer.interface.writeAll("\n");
try writer.interface.writeAll("# Generated by Zig's build system. Do not edit.\n");
try writer.interface.writeAll("# ");
try writer.interface.splatByteAll('#', 80 - 2);
try writer.interface.writeAll("\n\n");

while (true) {
_ = reader.interface.streamDelimiter(&writer.interface, '@') catch |err| switch (err) {
error.EndOfStream => break,
Expand Down
Loading