Skip to content

record_linux: every AudioRecorder shares one parecord process, so starting or disposing any recorder kills another's capture #631

Closed

Description

@siegblink

Package version

record 6.2.1, record_linux 1.3.1. record_linux 2.1.2 has the same structure (one CapturePipeline per plugin instance).

Environment

  • OS: Linux (Ubuntu 24.04, PipeWire)

Describe the bug

RecordLinux keeps one _parecordProcess for the whole plugin (2.x: one _pipeline) and ignores recorderId. start and startStream begin with stop(recorderId), dispose(recorderId) calls stop as well, and stop kills that one process, whichever recorder started it. So with two AudioRecorders, one recorder starting, or merely being disposed, kills the other's capture. dispose also closes _stateStreamCtrl, which every recorder's state stream shares.

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

To Reproduce

Steps to reproduce the behavior:

  1. Start a stream on one recorder and count its chunks:
    final a = AudioRecorder();
    final stream = await a.startStream(
      const RecordConfig(encoder: AudioEncoder.pcm16bits, numChannels: 1),
    );
    var chunks = 0;
    stream.listen((_) => chunks++, onDone: () => print('done'));
    await Future<void>.delayed(const Duration(seconds: 1));
  2. Create a second recorder, list the input devices with it, and dispose it:
    final other = AudioRecorder();
    await other.listInputDevices();
    await other.dispose();
  3. Wait, then read chunks:
    await Future<void>.delayed(const Duration(milliseconds: 1500));
  4. See: 8 chunks in the first second, none after other.dispose(). onDone doesn't run either: that part is AudioRecorder: the stream from startStream never ends when the platform's capture ends #632.

Expected behavior

One capture per recorder id, as on the other platforms: a recorder's start, stop and dispose touch only its own capture and state, and a keeps receiving audio.

Additional context

Measured with flutter test on the machine above, with RecordPlatform.instance = RecordLinux(). Starting a second stream has the same effect as disposing one: its startStream calls stop first. We hit it with a speech-to-text pre-warm holding one recorder while a settings screen listed devices and ran a mic level meter with others.

Activity

  1. llfbandit commented on Oct 9, 2026

    @llfbandit
    Owner

    Thanks for the report.

    record_linux 2.1.3 has been released with the fix.

  2. siegblink commented on Oct 13, 2026

    @siegblink
    Author

    Confirmed fixed with record_linux 2.1.3 (record 7.1.2) on Ubuntu 24.04, PipeWire 1.0.5. I ran the repro above with flutter test against the real RecordLinux: a gets 8 chunks in its first second, then 15 in the 1.5 s after other.dispose() (none before the fix), and 15 more in the 1.5 s after a second recorder starts its own stream, which gets 14. In our app, the mic level meter and speech-to-text now capture at the same time.

    Thanks for the quick fix!

  3. added a commit that references this issue on Nov 12, 2026
    580e722
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

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions