-
Notifications
You must be signed in to change notification settings - Fork 274
Closed
Description
Package version
6.1.1
Environment
- OS: Android 15.0
- Flutter: 3.35.2 (Dart 3.9.0)
Describe the bug
When stopping the recording while using the FLAC file format (RecordConfig(encoder: AudioEncoder.flac)) on the Android app, the app crashes with the following stack trace:
E/AndroidRuntime( 9184): FATAL EXCEPTION: MediaCodecEncoder Thread
E/AndroidRuntime( 9184): Process: com.example.record_flac_bug, PID: 9184
E/AndroidRuntime( 9184): java.lang.IllegalStateException: Container not started
E/AndroidRuntime( 9184): at com.llfbandit.record.record.container.FlacContainer.stop(FlacContainer.kt:30)
E/AndroidRuntime( 9184): at com.llfbandit.record.record.encoder.MediaCodecEncoder.stopAndRelease(MediaCodecEncoder.kt:195)
E/AndroidRuntime( 9184): at com.llfbandit.record.record.encoder.MediaCodecEncoder.onError(MediaCodecEncoder.kt:186)
E/AndroidRuntime( 9184): at com.llfbandit.record.record.encoder.MediaCodecEncoder.processOutputBuffer(MediaCodecEncoder.kt:180)
E/AndroidRuntime( 9184): at com.llfbandit.record.record.encoder.MediaCodecEncoder.access$processOutputBuffer(MediaCodecEncoder.kt:17)
E/AndroidRuntime( 9184): at com.llfbandit.record.record.encoder.MediaCodecEncoder$AudioRecorderCodecCallback.onOutputBufferAvailable(MediaCodecEncoder.kt:224)
E/AndroidRuntime( 9184): at android.media.MediaCodec$EventHandler.handleCallback(MediaCodec.java:1953)
E/AndroidRuntime( 9184): at android.media.MediaCodec$EventHandler.handleMessage(MediaCodec.java:1851)
E/AndroidRuntime( 9184): at android.os.Handler.dispatchMessage(Handler.java:107)
E/AndroidRuntime( 9184): at android.os.Looper.loopOnce(Looper.java:257)
E/AndroidRuntime( 9184): at android.os.Looper.loop(Looper.java:342)
E/AndroidRuntime( 9184): at android.os.HandlerThread.run(HandlerThread.java:85)
Other audio encoders seem to work correctly (checked wav, opus, pcm16bits, aacEld)
To Reproduce
Run the following function:
Future<void> _recordFlac() async {
final appDocumentsDir = await getApplicationDocumentsDirectory(); // imported from path_provider
final recorder = AudioRecorder();
await recorder.start(
const RecordConfig(encoder: AudioEncoder.flac),
path: '${appDocumentsDir.path}/recording.flac',
);
await Future.delayed(Duration(seconds: 1)); // record for one second
await recorder.stop(); // <= crash occurs here
await recorder.dispose();
}
Expected behavior
The recorder should save the recording file or, in the worst-case scenario, throw an exception instead of crashing the app.
Metadata
Metadata
Assignees
Labels
No labels