PulseAudio under the hood

Table of contents Preface About PulseAudio High-level components Key abstractions D-Bus API C API Protocols and networking Device drivers Sound processing Sample cache Stream management Time management Power saving Automatic setup and routing Desktop integrations Compatibility layers Server internals Module list GUI tools …

Using MiniSAPServer and MiniSAPListener for SAP/SDP

MiniSAPServer is a small program that periodically sends SAP/SDP messages, given a config file and destination address. I’ve prepared a complementary MiniSAPListener program which listens for SAP/SDP messages, and prints them to stdout or passes to a shell command. The source code is mostly extracted from PulseAudio RTP …

File locking in Linux

Table of contents Introduction Advisory locking Common features Differing features File descriptors and i-nodes BSD locks (flock) POSIX record locks (fcntl) lockf function Open file description locks (fcntl) Emulating Open file description locks Command line tools Mandatory locking Introduction File locking is a …

Reusing UNIX domain socket (SO_REUSEADDR for AF_INET)

Unix domain sockets are a networkless version of Internet sockets. They have several advantages: Unix domain sockets are files, so file-system permissions may be used for them when one end is closed (e.g. process exits), SIGPIPE is delivered to another end performance may be up to 2x better See details here. Lack of …

Decoding and playing audio files in Linux

Table of contents Overview FFmpeg SoX ALSA (libasound) PulseAudio Other libraries Notes Overview I was playing with various media libraries recently and have prepared several snippets demonstrating how one can decode and play an audio file in two separate steps. The source code is available on GitHub here and there. The …

SCons rebuilds generated source files every launch

Problem In a large project that uses SCons, VariantDir, and source code generation, happens one of the following: generated source files are rebuilt every time when scons is launched if .sconsign.dblite is removed manually, scons crashes with the following trace: OSError: [Errno 2] No such file or directory: …

Xlib usage examples

Table of contents What is Xlib? Printing pressed keys Embedding window What is Xlib? Xlib (also known as libX11) is an X11 client library. It contains functions for interacting with an X server. This page provides several code snippets implementing complete X11 programs. Printing pressed keys The source code is available on …

Detecting USB devices with libudev

Below you can find code snippets that match USB devices using libudev. A good tutorial is available here: libudev and Sysfs Tutorial. Listing and monitoring USB devices The snippet first prints all detected USB devices, and then enters monitoring mode and prints USB devices when they are inserted or removed. Source code on …

httpexpect.v1: end-to-end HTTP API testing for Go

httpexpect is a new Go package for end-to-end HTTP and REST API testing. It provides convenient chainable helpers for building HTTP request, sending it, and inspecting received HTTP response and its payload. Links: repo on GitHub announcement on Reddit The key point is that request construction and response assertions become …