llfbandit / record

Audio recorder from microphone to a given file path. No external dependencies, MediaRecorder is used for Android an AVAudioRecorder for iOS.
https://pub.dev/packages/record
239 stars 202 forks source link

[iOS] Alarm Pauses Recording, but Recorder Incorrectly Reporting Continuous Recording #372

Closed erdnx closed 6 days ago

erdnx commented 3 months ago

5.1.2

Environment

Describe the bug

When an interruption occurs (alarm, phone call, etc.), the internal recorder pauses, but this package's recorder assumes it is still recording. When you pause and resume recording, it actually continues to record. The problem is that the package's recorder reports the wrong state. It reports that it is recording while it is actually paused.

To Reproduce

Steps to reproduce the behavior:

  1. Start record
  2. Alarm rings
  3. Recorder showing as it is still recording
  4. Save record
  5. Listen it, there is nothing after the alarm

Expected behavior

When an interruption happen, it may be alarm, phone call or other media action, recorder should be aware what is the actual state of recorder.

mynlexi commented 3 months ago

This can be catched by doing a check for incoming data

void addAudioData(Uint8List audioData) {
    _buffer.add(audioData);
    _resetInactivityTimer();
  }

  void _resetInactivityTimer() {
    _inactivityTimer?.cancel();
    // pausing?
    _inactivityTimer = Timer(Duration(milliseconds: inactivityTimeout), () {
      getIt<RecorderBloc>()
          .add(SpawnRecorderError(RecorderError.bluetoothError));
    });
  }

-> on alarm u can just pause, and resume, by user input -> audio source change (eg. bluetooth) pauses, but resume doesnt work (probably would have to create new recorder)