tree: baa712ba9a76a8f922d2c94a94f6a26fe6abf7db [path history] [tgz]
  1. bin/
  2. hook/
  3. lib/
  4. test/
  5. third_party/
  6. tool/
  7. pubspec.yaml
  8. README.md
pkgs/code_assets/example/mini_audio/README.md

mini_audio

This project is a minimal, cross-platform demonstration of how to use Dart's build hooks, with code assets and dart:ffi to call a simple function from a popular C library. This project uses the miniaudio library to play audio files.

How it works

The native code is built by the hook/build.dart, which is run by the Dart SDK CLI tools. This build hook compiles the C code from third_party/miniaudio.c into a dynamic library.

The Dart FFI bindings to the C code are generated by tool/ffigen.dart. FFIgen generates Dart FFI bindings from third_party/miniaudio.h into lib/src/third_party/miniaudio.g.dart.

The Dart code in lib/src/mini_audio.dart uses the generated FFI bindings to provide a Dart API (not exposing any C types).