-
-
Notifications
You must be signed in to change notification settings - Fork 55
Embedding of opus and ogg libs on all platforms with a choice of doing this #195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
@filiph please, could you try this on your Mac? It should compile with or without the environment variable (with or without the libs). |
|
Thanks @alnitak for the quick turnaround on this! I can see there's a lot of work behind this. Here's what I did:
Hope this helps. |
|
Hey Filip, thanks for the detailed description! I tried and found out that the To test it’s enough to run Then:
You could also test using the
Meanwhile, on Android, I modified the So, to recap, on the other platforms, except MacOS and iOS that are using the above workflow, it’s enough to set the variable in the IDE as explained in the 1st post. I still need to update the |
|
Thanks for the info. After doing what you suggested: $ NO_OPUS_OGG_LIBS= && flutter run -t lib/buffer_stream/websocket.dartI no longer see the exception. On the other hand, when hitting "set stream" and "play" (there's a typo, btw, it says "paly"), I don't hear a sound. The UI changes but there's nothing. Is that expected? Same problem when I build the app with $ export NO_OPUS_OGG_LIBS= && flutter build macos --target "lib/buffer_stream/websocket.dart" |
|
Hey Filip, thanks for your time.
yes, the app doesn't find a websocket server. But since the plugins compiles without errors and throws an exception when using But it would awesome if you want to try! At the beginning of TL;DR
To know better how the buffer stream behaves, you can change the From Screen.Recording.2025-03-06.at.14.06.31.mp4update: you can even run the flutter_soloud example on your mobile phone connected to your local wi-fi and it should work. |
|
Hi Marco, I'm sorry, I don't think I'll have time in the next few days to do this. |
|
No worries, Filip! I totally understand. Since the plugin build is now fixed, you can postpone testing the BufferStream for later when you have more time. |

Description
Opus and Ogg libraries are currently only used by the BufferStream to receive and fill audio data with Opus format.
To fix #191, and most likely #192, we need to embed the ogg and opus libraries in the Flutter project that uses the plugin.
Previously, MacOS and Linux were using the system opus and ogg libraries if they were available in the OS.
Now the libs are prebuilt for all platforms and stored in the plugin folder. This means that even if they are not needed, the plugin still requires them to work, and the size of the app will grow slightly. To address this, a new environment variable has been introduced that can be used to prevent the prebuilt libs from being linked to the final app.
If trying to use, for example the
SoLoud.setBufferStream()function, an exception will be thrown if the environment variable has been set.How to set the environment variable:
(a new NO_OPUS_OGG_LIBS.md file with this section has been created and linked from README.md)
Linux - Android - Windows
If using VS Code, add
NO_OPUS_OGG_LIBSset to an empty string in theenvkey to the .vscode/launch.json configuration, for example:If using Android Studio, add
NO_OPUS_OGG_LIBS="1"in the Run/Debug Configurations configuration under Environment Variables text field.Alternatively, you can export the variable in the terminal and build the app, for example:
exportNO_OPUS_OGG_LIBS="1" && flutter build appbundleNote that when adding or removing the variable, you need to run
flutter clean.Warning
Side note for Android: It appears that after aflutter cleanin your app folder, the plugin build files are not recompiled because they haven't changed. The only solution I've found is to runflutter pub cache cleanor, for developers, remove theandroid/.cxxplugin folder (this might be a Flutter 3.29.0 bug, maybe I should file an issue).MacOS - iOS
To set the environment variable on MacOS and iOS, you can add the following line to the
app/ios/Podfileorapp/macos/Podfileat the top of the file:Alternatively, you can export the variable in the terminal and build the app, for example:
exportNO_OPUS_OGG_LIBS="1" && flutter build macosupdate: after running this command, if you want to run it again without the env variable, it must be unset:
NO_OPUS_OGG_LIBS= && flutter build macosNote that when adding or removing the variable, you need to:
flutter cleanflutter pub getcd macosorcd iospod installNote
The environment variable set in VS Code or in Android Studio will be ignored.
Web
To set the environment variable on Web, open
web/compile_wasm.shand change the lineNO_OPUS_OGG_LIBS="0"toNO_OPUS_OGG_LIBS="1".You should then run the script to build the WASM and JS files.
emscriptenmust be installedThe script works on Linux and probably on MacOS. Windows users should run the script in WSL or wait until a .bat script is available.
Note
The environment variable set in VS Code or in Android Studio will be ignored.
Type of Change