Canardoux / flutter_sound

Flutter plugin for sound. Audio recorder and player.
Mozilla Public License 2.0
850 stars 553 forks source link

[BUG]:-[FlutterSoundRecorder startRecorder:result:] com.apple.coreaudio.avfaudio - required condition is false: format.sampleRate == hwFormat.sampleRate #1034

Closed coder-dongjiayi closed 1 month ago

coder-dongjiayi commented 1 month ago

Flutter Sound Version :

flutter_sound: ^9.4.6


Severity

Fatal Exception: com.apple.coreaudio.avfaudio required condition is false: format.sampleRate == hwFormat.sampleRate


Platforms you faced the error

Describe the bug firsebase monitored a number of users who were recording while the program crashed.

20240515152519 my code

    await _record.openRecorder();
    await _initSession();
    await _record.startRecorder(codec: Codec.pcm16, toFile: _recordPcmPath);
Larpoux commented 1 month ago

Yes @coder-dongjiayi ,

There is something bad with RAW PCM (notably with Streams) on iOS. I want to rewrite all this bad code, but this is a major work for me, and I don't have much time. So don't expect to have this fixed soon.

In the mean time, perhaps you can record a WAV sound, and translate your file to RAW PCM, ( if you really need RAW PCM ). WAV is just RAW PCM with an envelop in front of the data so it is very easy to remove this envelop. You can use flutter_soud/util/flutter_sound_helper :

Future<void> waveToPCM({
    required String inputFile,
    required String outputFile,
  }) async {
coder-dongjiayi commented 1 month ago

okay, I will try using wav。