SoLoudIsolate class
Isolate-safe access to the SoLoud engine for tasks that do not require the main isolate's state.
The SoLoud engine is a singleton in C++ land and can be initialized only
from the main isolate via SoLoud. Call SoLoud.instance.init in the
main isolate before using this class from another isolate. Once initialized,
operations can be safely performed from another isolate because they do not
touch the main isolate's SoLoudLoader, AudioSource registry, filters, or
playback-event streams.
SoLoudIsolate exposes only those operations. It does not expose
init()/deinit(), loading, playback, filters, or the
voiceEnded/fileLoaded/stateChanged event streams. Those must remain on
the isolate that initialized the engine.
The primary use case is running the mixer output capture stream in a worker isolate so the main isolate stays free for UI and other tasks.
Example:
final isolateCapture = SoLoudIsolate.instance.startMixerOutputStream(
format: MixerOutputFormat.pcmS16le,
chunkPCMFrames: 2048,
);
isolateCapture.listen((chunk) { /* process audio bytes */ });
See also the example/lib/mixer_capture/isolate_capture_test.dart for
a complete example of running mixer output capture in a separate isolate.
- Annotations
-
- @experimental
Properties
- bindings → FlutterSoLoud
-
The low-level platform bindings. Advanced users can use this to call
methods that are safe to invoke from a non-main isolate.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isInitialized → bool
-
Whether the native engine is initialized.
no setter
- isMixerOutputStreamRunning → bool
-
Whether mixer output capture is currently active.
no setter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
getMixerOutputWavHeader(
) → Uint8List - Returns the current 44-byte WAV header for the active mixer output capture.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
readSamplesFromFile(
String completeFileName, int numSamplesNeeded, {double startTime = 0, double endTime = -1, bool average = false}) → Future< Float32List> - //////////////////////////////////////////////// Read samples from file and memory. //////////////////////////////////////////////// This method has the same behavior as SoLoud.readSamplesFromFile (refer to it for a complete documentation) and can be safely called from a non-main isolate. Is not mandatory that the engine is initialized in the main isolate to use this method.
-
readSamplesFromMem(
Uint8List buffer, int numSamplesNeeded, {double startTime = 0, double endTime = -1, bool average = false}) → Future< Float32List> - This method has the same behavior as SoLoud.readSamplesFromMem (refer to it for a complete documentation) and can be safely called from a non-main isolate. Is not mandatory that the engine is initialized in the main isolate to use this method.
-
startMixerOutputStream(
{MixerOutputFormat format = MixerOutputFormat.pcmF32le, int sampleRate = -1, int channels = -1, int bufferSizeBytes = 1024 * 1024, int notificationThresholdBytes = 4096, int chunkPCMFrames = -1}) → Stream< Uint8List> - Captures the master mixer output as a Stream of Uint8List chunks.
-
stopMixerOutputStream(
) → void - Stops the mixer output capture stream and releases associated resources.
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
- instance → SoLoudIsolate
-
The singleton instance of SoLoudIsolate.
final