Skip to content

AudioRecorder: the stream from startStream never ends when the platform's capture ends #632

Closed

Description

@siegblink

Package version

record 6.2.1. The same code is in 7.1.1.

Environment

  • OS: Linux (Ubuntu 24.04). The code involved is platform-independent.

Describe the bug

_startRecordStream (lib/src/part/record_stream.dart) re-emits the platform stream through its own broadcast controller. It forwards data (7.x also errors) but not the done event: stream.listen(...) has no onDone, and the controller closes only when the app itself calls stop, cancel, dispose or startStream again. So when a capture ends on the platform's side (the capture process dies, the device goes away, or on Linux another recorder stops it: #631), the stream startStream returned goes silent but never completes, and its owner can't tell its capture has ended.

const RecordConfig(encoder: AudioEncoder.pcm16bits, numChannels: 1)

To Reproduce

Steps to reproduce the behavior:

  1. On Linux, start a stream and listen with an onDone:
    final a = AudioRecorder();
    final stream = await a.startStream(
      const RecordConfig(encoder: AudioEncoder.pcm16bits, numChannels: 1),
    );
    stream.listen((_) {}, onDone: () => print('done'));
  2. End the capture on the platform's side, here with a second recorder (record_linux: every AudioRecorder shares one parecord process, so starting or disposing any recorder kills another's capture #631):
    final other = AudioRecorder();
    await other.listInputDevices();
    await other.dispose();
  3. See: the data stops, and done is never printed.

Expected behavior

When the platform stream is done, the stream from startStream closes too, so the caller's onDone runs; for instance onDone: () => _recordStreamCtrl?.close() in _startRecordStream.

Additional context

Measured with flutter test on the machine above, with RecordPlatform.instance = RecordLinux() (record_linux 1.3.1): no data after the second recorder's dispose, and onDone never ran in the following 1.5 s.

Activity

  1. llfbandit commented on Oct 9, 2026

    @llfbandit
    Owner

    Thanks for the report.

    record 7.1.2 has been released with the fix.

  2. siegblink commented on Oct 13, 2026

    @siegblink
    Author

    Confirmed with record 7.1.2 on Linux (record_linux 2.1.3). Since #631 is fixed, a second recorder no longer ends the capture, so I ended it by killing the recorder's parecord from outside: the stream from startStream now completes, and onDone ran 1 ms after the kill.

    Thanks!

  3. added 2 commits that reference this issue on Nov 12, 2026
    075cd07
    334256c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions