FakeCaptureSession class
A CaptureSession that never touches a microphone.
This fake drives the same state as a real session: the recording flag, the frame stream, the rolling scope and the drop counters. As a result, a widget test can exercise the visualizer of a host. Frames arrive when a test calls emit or emitTone, and not when an audio thread produces them. This makes the timing exact instead of merely likely.
dispose leaves the same values readable as the real session. produced, dropped, pcmDropped and truncated answer after dispose and do not throw. As a result, a UI that reads a counter during teardown behaves the same here as it does against a microphone. The real session freezes its counters at dispose to manage this, because the C struct that supplied them is gone by then.
- Implemented types
Constructors
- FakeCaptureSession({CaptureConfig config = const CaptureConfig()})
Properties
- config → CaptureConfig
-
final
- dropped → int
-
Hops that the consumer was too slow to collect.
no setteroverride
-
emitted
→ List<
CaptureFrame> -
Every frame emitted since construction.
final
-
frames
→ Stream<
CaptureFrame> -
Reduced frames, in order.
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- isPaused → bool
-
Whether the device is stopped but the take is intact.
no setteroverride
- isRecording → bool
-
no setteroverride
- nextStartError ↔ Object?
-
If a test sets this field, start throws it.
getter/setter pair
- pcmDropped → int
-
Samples that the audio ring dropped because the file writer was too slow.
no setteroverride
- produced → int
-
Hops that the audio thread produced.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- scope → CaptureScope
-
A rolling window of recent frames, for a painter to draw.
final
- startCount ↔ int
-
getter/setter pair
- stopCount ↔ int
-
getter/setter pair
- stopResult ↔ WaveformPeaks?
-
What stop returns. The default is peaks from the frames that this fake
emitted.
getter/setter pair
- truncated → bool
-
Whether the history is more than CaptureConfig.maxDuration.
no setteroverride
Methods
-
dispose(
) → Future< void> -
override
-
dropFrames(
int count) → void - Simulates a consumer that falls behind.
-
emit(
CaptureFrame frame) → void - Publishes one frame, exactly as a drain does.
-
emitTone(
int count, {double amplitude = 0.5}) → void -
Publishes
countframes at a steadyamplitudefrom 0 to 1. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
pause(
) → Future< void> -
Stops the device and keeps the take.
override
-
resume(
) → Future< void> -
override
-
start(
) → Future< void> -
override
-
stop(
) → Future< WaveformPeaks> -
Stops the device and returns peaks for all the audio that it captured.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited