Expand description
A C++ binding for prolink, generated by cxx.
Built for Mixxx, whose Pro DJ Link support is being replaced by calls into this library, and shaped by that: the C++ side is meant to be a thin shell that renders, so everything here hands over state that is ready to display rather than parts a caller has to reassemble. There is no packet, no socket and no parsing in this API.
§Why cxx and not a C ABI
A hand-written C header has to be kept in step with the Rust by hand, and
the failure mode when it is not is a caller’s stack corrupted at run time,
on a machine the author does not have. cxx generates both sides from this
one file, so the same mistake is a compile error in both languages — and
String and Vec cross as rust::String and rust::Vec rather than as
fixed-size buffers with a length convention.
Nothing on the C++ side of this boundary is unsafe, and nothing it
receives needs freeing.
§Two rules the surface follows
Events are drained, never pushed. A callback would be invoked from a
tokio worker thread, which for a Qt host means every handler has to be
thread-safe and re-entrant, and a slow one stalls the network. Instead
drain_events returns everything queued since the last call, on the
caller’s own thread, from a timer or an idle handler. Back-pressure is
bounded rather than unbounded: Event::dropped says how much was missed.
Absent numbers are negative, never zero. A host drawing a tempo has to
tell “not playing” from “0.00 BPM”, and zero cannot. cxx has no Option
in a shared struct, so the convention is explicit and applied everywhere:
-1.0 means “no value”, not a value of minus one.
§Example
#include "prolink-cxx/src/lib.rs.h"
auto session = prolink::open(prolink::default_config());
// From a UI timer, on your own thread:
for (const prolink::Event& event : session->drain_events()) {
if (event.kind == prolink::EventKind::Beat) { /* ... */ }
}
for (const prolink::Player& player : session->players()) {
if (player.is_master) {
meter->setPhase(player.bar_phase);
}
}Re-exports§
pub use ffi::Config;pub use ffi::Device;pub use ffi::DeviceKind;pub use ffi::Event;pub use ffi::EventKind;pub use ffi::MediaInfo;pub use ffi::Metadata;pub use ffi::NetworkInterface;pub use ffi::PdbContents;pub use ffi::PdbNamed;pub use ffi::PdbPlaylist;pub use ffi::PdbTrack;pub use ffi::PlainEntry;pub use ffi::PlayState;pub use ffi::Player;pub use ffi::Row;pub use ffi::ServeConfig;pub use ffi::ServeConsumer;pub use ffi::ServeStatus;pub use ffi::ServedSlot;pub use ffi::Slot;
Modules§
- ffi
- The shared vocabulary, and the entry points.
Structs§
- Server
- A running server: our media, offered to real players.
- Session
- A running session: sockets, timers, and the state they maintain.
Functions§
- default_
config - A config that chooses an interface, announces, and claims any free number.
- init_
logging - Send this library’s log to standard error.
- interfaces
- The interfaces that could carry Pro DJ Link traffic.
- open
- Start a session.
- read_
anlz - Read one analysis file off disk.
- read_
anlz_ preview - Read only the preview waveforms, seeking past everything else.
- read_
pdb - Read a rekordbox
export.pdboff disk. - read_
pdb_ bytes - Read a rekordbox
export.pdba host already has in memory. - serve
- Start serving.