No Xiph libs

Configure builds without OGG, Opus, Vorbis, and FLAC libraries to reduce binary size

Overview

The OGG, Opus, Vorbis, and FLAC libraries are enabled by default in flutter_soloud (built from source via native hooks). However, if you don't need streaming capabilities, you can exclude these libraries to reduce your app's binary size by 600~3000 KB (depending on platform).

For a complete guide on building from source, using system packages, or downloading prebuilt binaries, see the Xiph Libraries & Codecs Guide.

Configuration Methods

Application Configuration (pubspec.yaml)

Native code for mobile and desktop (Android, iOS, macOS, Windows, Linux) is compiled using Dart build hooks.

To build your application without the bundled Opus, Ogg, Vorbis, and FLAC libraries, add the hooks.user_defines block to your root app's pubspec.yaml:

yaml
hooks:
  user_defines:
    flutter_soloud:
      no_xiph_libs: true

That's it! Dart's build hook will automatically:

  • Define NO_XIPH_LIBS during C/C++ native compilation.
  • Skip linking and bundling the prebuilt Xiph libraries.
  • Track this configuration in .dart_tool/hooks_runner/ so rebuilding and switching configurations invalidates and recompiles automatically across all native platforms.

Web Platform

For the Web platform (which uses Emscripten / WebAssembly rather than Dart native build hooks):

  1. Open web/compile_wasm.sh in the flutter_soloud package.
  2. Change NO_XIPH_LIBS="0" to NO_XIPH_LIBS="1".
  3. Rebuild the WASM binaries by executing web/compile_wasm.sh.

Requirements:

  • Emscripten installed
  • Linux or macOS for compilation (Windows users can use WSL)

Impact on Functionality

When built without Opus/Vorbis/FLAC:

  • setBufferStream() and readSamplesFrom*() using Opus/Vorbis/FLAC formats will throw exceptions
  • Other audio formats (MP3, WAV) and synthesis features remain fully functional
  • Binary size is reduced by 600~3000 KB depending on target architecture
  • All other features work normally