module

Emerald::Docs::ARCHITECTURE::FfiBindings

LibVLC C-FFI Architecture

Executive Summary & Key Topics

Topic Method / Anchor Description
Direct C ABI Integration .topic_01_direct_c_abi Zero-overhead Crystal FFI bindings to LibVLC functions.
Automatic Runtime Discovery .topic_02_runtime_discovery Locating native LibVLC binaries and plugin paths automatically.

Class methods

topic_01_direct_c_abi

Direct C ABI Integration: Zero-overhead Crystal FFI bindings to LibVLC functions.

Emerald interfaces directly with libvlc.dll (Windows), libvlc.so (Linux), and libvlc.dylib (macOS) using Crystal's native C FFI (lib LibVLC ... end).

By utilizing direct method bindings rather than intermediary script bridges:

  • Memory overhead is negligible.
  • Function calls execute at pure machine code speeds.
  • Zero runtime translation layers exist between Crystal and VLC.
Source
topic_02_runtime_discovery

Automatic Runtime Discovery: Locating native LibVLC binaries and plugin paths automatically.

Emerald's Environment module automatically discovers the native VLC installation directory:

  • Sets the Windows DLL search directory via SetDllDirectoryA.
  • Injects the VLC_PLUGIN_PATH environment variable so decoder plugins (FFmpeg, A52, FLAC, Vorbis) are located on startup.
Source