Skip to main content

Crate tympan_aspl

Crate tympan_aspl 

Source
Expand description

tympan-aspl — a Rust framework for writing macOS AudioServerPlugins.

AudioServerPlugins are the user-space audio drivers that run inside coreaudiod and appear to the system as audio devices. tympan-aspl provides safe Rust abstractions over the Core Audio HAL AudioServerPlugin C interface so a Rust crate can implement a virtual audio device — a loopback, a virtual microphone, a routing or processing driver — without writing C++ or Objective-C.

See docs/overview.md for the project’s scope and docs/architecture.md for the design that drives this crate.

§Layering

The crate is built bottom-up in conceptual layers, isolated by module boundary:

  • raw — the low-level FFI to the AudioServerPlugin C ABI. Its ABI type definitions (raw::abi) and marshalling (raw::marshal) are plain data, compiled and tested on every host; only the live extern "C" entry points and CoreFoundation calls (a later PR) are macOS-gated.
  • realtime — allocation-free, lock-free primitives for the IOProc realtime callback. Cross-platform, so the realtime invariants are unit-testable on any host.
  • The object model — error, fourcc, object, property, format, io — cross-platform plain-data mirrors of the Core Audio C types.
  • The property protocol — objects (the object tree) and dispatch (the cross-platform answer to the HAL’s property reads).
  • The public API — driver, device, stream — the traits and declarative types a consumer implements against.
  • bundle.driver bundle Info.plist generation.

§Realtime safety

Any code reachable from the IOProc realtime callback must be allocation-free, lock-free, and free of blocking syscalls. The realtime module exposes a RealtimeContext marker that acts as a compile-time witness for the realtime context; Driver::process_io takes one. Mechanical enforcement lives in tests/realtime_safety.rs via an assert_no_alloc global-allocator guard.

§Implementing a driver

A consumer implements Driver for a type carrying its per-plug-in state, describes the device it exposes with a DeviceSpec, and — on macOS — exposes the type as a CFPlugIn with the plugin_entry! macro.

Re-exports§

pub use bundle::BundleConfig;
pub use device::Device;
pub use device::DeviceId;
pub use device::DeviceSpec;
pub use dispatch::DeviceState;
pub use driver::AnyDriver;
pub use driver::Driver;
pub use driver::DriverInfo;
pub use error::OsStatus;
pub use format::FormatNegotiation;
pub use format::SampleFormat;
pub use format::StreamFormat;
pub use fourcc::FourCharCode;
pub use io::IoBuffer;
pub use io::IoOperation;
pub use io::Sample;
pub use io::Timestamp;
pub use object::AudioObjectId;
pub use object::ObjectKind;
pub use objects::Object;
pub use objects::ObjectMap;
pub use property::PropertyAddress;
pub use property::PropertyElement;
pub use property::PropertyScope;
pub use property::PropertySelector;
pub use property::PropertyValue;
pub use property::ValueRange;
pub use realtime::RealtimeContext;
pub use stream::StreamDirection;
pub use stream::StreamSpec;

Modules§

bundle
.driver bundle packaging helpers.
device
Device abstraction.
dispatch
Core Audio property dispatch.
driver
The top-level Driver trait and its framework-side wrapper.
error
OSStatus wrapper and Core Audio error constants.
format
Audio stream formats.
fourcc
Four-character codes.
io
The IO cycle: timestamps, operations, and the realtime buffer wrapper.
object
Audio object identifiers and the AudioServerPlugin object model.
objects
The AudioServerPlugin object tree.
property
The Core Audio property protocol.
raw
Low-level FFI to the Core Audio AudioServerPlugin C ABI.
realtime
Realtime-safe primitives.
stream
Stream abstraction.

Macros§

plugin_entry
Expose a T: Driver implementation as the AudioServerPlugin this .driver bundle provides.