-
Notifications
You must be signed in to change notification settings - Fork 251
Open
Labels
Description
Package version
Environment
- OS: macos 14.3.1
- Browser: Chrome
- record version: 5.0.4
Describe the bug
record stream failed:
*** Terminating app due to uncaught exception 'com.apple.coreaudio.avfaudio', reason: 'required condition is false: IsFormatSampleRateAndChannelCountValid(hwFormat)'
*** First throw call stack:
(
0 CoreFoundation 0x0000000188124540 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x0000000187c15eb4 objc_exception_throw + 60
2 CoreFoundation 0x000000018814a434 -[NSException description] + 0
3 AVFAudio 0x00000001f43be724 _Z19AVAE_RaiseExceptionP8NSStringz + 52
4 AVFAudio 0x00000001f4482038 _ZN17AVAudioIONodeImpl15SetOutputFormatEmP13AVAudioFormat + 860
5 AVFAudio 0x00000001f43e04f4 _ZN17AUGraphNodeBaseV318CreateRecordingTapEmjP13AVAudioFormatU13block_pointerFvP16AVAudioPCMBufferP11AVAudioTimeE + 796
6 AVFAudio 0x00000001f4475580 -[AVAudioNode installTapOnBus:bufferSize:format:block:] + 1400
7 record_darwin 0x00000001046d2618 $s13record_darwin22RecorderStreamDelegateC5start6config0A12EventHandleryAA12RecordConfigC_AA0jdI0CtKF + 776
8 record_darwin 0x00000001046c7fe8 $s13record_darwin8RecorderC11startStream6configyAA12RecordConfigC_tKF + 732
9 record_darwin 0x00000001046d6b44 $s13record_darwin17SwiftRecordPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctF + 2392
10 record_darwin 0x00000001046d8dc4 $s13record_darwin17SwiftRecordPluginC6handle_6resultySo17FlutterMethodCallC_yypSgctFTo + 124
11 FlutterMacOS 0x00000001084be91c __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 180
12 FlutterMacOS 0x0000000107869db8 -[FlutterEngine engineCallbackOnPlatformMessage:] + 416
13 FlutterMacOS 0x00000001080ce0c4 _ZNSt3_fl10__function6__funcIZ23FlutterEngineInitializeE4$_34NS_9allocatorIS2_EEFvNS_10unique_ptrIN7flutter15PlatformMessageENS_14default_deleteIS7_EEEEEEclEOSA_ + 128
14 FlutterMacOS 0x00000001080df054 _ZN7flutter20PlatformViewEmbedder21HandlePlatformMessageENSt3_fl10unique_ptrINS_15PlatformMessageENS1_14default_deleteIS3_EEEE + 76
15 FlutterMacOS 0x00000001080dfb6c _ZNSt3_fl10__function6__funcIN3fml8internal14CopyableLambdaIZN7flutter20PlatformViewEmbedder30EmbedderPlatformMessageHandler21HandlePlatformMessageENS_10unique_ptrINS5_15PlatformMessageENS_14defa 16 FlutterMacOS 0x00000001080dc670 _ZN7flutter18EmbedderTaskRunner8PostTaskEy + 652
17 FlutterMacOS 0x00000001080c634c FlutterEngineRunTask + 36
18 FlutterMacOS 0x000000010786cc18 -[FlutterEngine runTaskOnEmbedder:] + 56
19 FlutterMacOS 0x000000010786cdcc __60-[FlutterEngine postMainThreadTask:targetTimeInNanoseconds:]_block_invoke + 64
20 libdispatch.dylib 0x0000000187e1ecb8 _dispatch_call_block_and_release + 32
21 libdispatch.dylib 0x0000000187e20910 _dispatch_client_callout + 20
22 libdispatch.dylib 0x0000000187e2efa8 _dispatch_main_queue_drain + 984
23 libdispatch.dylib 0x0000000187e2ebc0 _dispatch_main_queue_callback_4CF + 44
24 CoreFoundation 0x00000001880f0ea4 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 16
25 CoreFoundation 0x00000001880ae760 __CFRunLoopRun + 1996
26 CoreFoundation 0x00000001880ad93c CFRunLoopRunSpecific + 608
27 HIToolbox 0x0000000192676448 RunCurrentEventLoopInMode + 292
28 HIToolbox 0x0000000192676284 ReceiveNextEventCommon + 648
29 HIToolbox 0x0000000192675fdc _BlockUntilNextEventMatchingListInModeWithFilter + 76
30 AppKit 0x000000018b88ced0 _DPSNextEvent + 660
31 AppKit 0x000000018c077eec -[NSApplication(NSEventRouting) _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 716
32 AppKit 0x000000018b88037c -[NSApplication run] + 476
33 AppKit 0x000000018b857640 NSApplicationMain + 880
34 meeting_copilot_flutter 0x00000001042047bc main + 12
35 dyld 0x0000000187c510e0 start + 2360
)
libc++abi: terminating due to uncaught exception of type NSException
Lost connection to device.
the Dart compiler exited unexpectedly.
My Code:
import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:record/record.dart';
import 'audio_record.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
late final AudioRecorder _audioRecorder;
Future<void> _start() async {
try {
if (await _audioRecorder.hasPermission()) {
const encoder = AudioEncoder.pcm16bits;
const config = RecordConfig(encoder: encoder, numChannels: 1);
await recordStream(_audioRecorder, config);
}
} catch (e) {
print(e);
}
}
Future<void> recordStream(AudioRecorder recorder, RecordConfig config) async {
final stream = await recorder.startStream(config);
stream.listen(
(data) {
// ignore: avoid_print
print(
recorder.convertBytesToInt16(Uint8List.fromList(data)),
);
},
// ignore: avoid_print
onDone: () {
// ignore: avoid_print
print('End of stream.');
},
);
}
@override
void initState() {
_audioRecorder = AudioRecorder();
_start();
super.initState();
}
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'You have pushed the button this many times:',
),
Text(
'$_counter',
style: Theme.of(context).textTheme.headlineMedium,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: const Icon(Icons.add),
),
);
}
}