Skip to content

Instantly share code, notes, and snippets.

pub fn set_param(&self, id: spa::param::ParamType, flags: u32, param: &[u8]) {
unsafe {
spa_interface_call_method!(
self.proxy.as_ptr(),
pw_sys::pw_node_methods,
set_param,
id.as_raw(),
flags,
param.as_ptr() as *const spa::sys::spa_pod
);
@saivert
saivert / serialize.rs
Created June 5, 2023 20:01
Serialization and Deserialization of pipewire Props
struct SomeProps {
volume: Option<f32>,
mute: Option<bool>,
channel_volumes: Option<Vec<f32>>,
}
const PROPS_KEY_CHANNEL_VOLUMES: u32 = 65544;
const PROPS_KEY_VOLUME: u32 = 65539;
const PROPS_KEY_MUTE: u32 = 65540;
static void on_process(void *userdata) {
static int counter;
struct data *data = userdata;
struct pw_buffer *b = NULL;
struct spa_buffer *buf = NULL;
int16_t *dst = NULL;
if (!_setformat_requested) {
if ((b = pw_stream_dequeue_buffer(data->stream)) == NULL) {
int stride = plugin.fmt.channels * (plugin.fmt.bps / 8);
int buffer_size = 1024 * (plugin.fmt.bps/8) * plugin.fmt.channels;
int bytes_per_channel = (buffer_size > buf->datas[0].maxsize ? buf->datas[0].maxsize : buffer_size) / plugin.fmt.channels;
int nframes = bytes_per_channel / stride;
// nframes is now 512 when I expected 1024
static void on_process(void *userdata) {
struct data *data = userdata;
struct pw_buffer *b = NULL;
struct spa_buffer *buf = NULL;
int16_t *dst = NULL;
if (!_setformat_requested) {
int stride = (plugin.fmt.channels * plugin.fmt.bps) / 8;
if ((b = pw_stream_dequeue_buffer(data->stream)) == NULL) {
pw_log_warn("out of buffers: %m");
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <netlink/route/link.h>
int main(int argc, char *argv[])
{
struct rtnl_link *link;
struct nl_sock *sk;
int err;
var inputplf = DB_decoder_t(
plugin: plug,
open: {(hints: UInt32) -> UnsafeMutablePointer<DB_fileinfo_t>? in
let ptr: UnsafeMutablePointer<fileinfo> = UnsafeMutablePointer<fileinfo>.allocate(capacity: 1)
ptr.initialize(repeating: fileinfo(dbfileinfo: DB_fileinfo_t(), frequency: 440), count: 1)
return UnsafeMutablePointer<DB_fileinfo_t>(OpaquePointer(ptr))
},
init: {(info: UnsafeMutablePointer<DB_fileinfo_t>?, it: UnsafeMutablePointer<DB_playItem_t>?) -> Int32 in
0
// swift-tools-version: 5.7
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "ddbswift",
products: [
// Products define the executables and libraries a package produces, and make them visible to other packages.
.library(
@saivert
saivert / .gtkrc-2.0
Created November 22, 2021 23:04
Fixes for adwaita gtk2 theme
# Fixes for adwaita gtk2
# Fix too big buttons
style "button" {
GtkButton::inner-border = {3, 3, 2, 2}
}
# Fix prelight assuming dialog bg color
style "notebook_checkbutton" {
bg[PRELIGHT] = {1.0, 1.0, 1.0}
@saivert
saivert / cairotest.c
Created October 24, 2021 20:25
Compile with: gcc -o cairotest cairotest.c `pkgconf --libs --cflags gtk+-3.0 `
#include <cairo.h>
#include <cairo/cairo.h>
#include <gtk/gtk.h>
typedef struct {
float x, y;
} coord_t;
static void do_drawing(cairo_t *);