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
241 stars 204 forks source link

Unexpected error on the version 5.1.0 #322

Closed liemfs closed 5 months ago

liemfs commented 5 months ago

5.1.0

Environment

Bug

There is an error that appears when recording is stopped, this error is not present in record 5.1.0 and record_android 1.1.0 versions, I didn't change any code, just upgraded the library

RecordConfig that I use:

RecordConfig(encoder: AudioEncoder.pcm16bits, bitRate: 14000, sampleRate: 12000, numChannels: 1, echoCancel: true, noiseSuppress: true)

Error that I get:

E/AudioRecorder( 4042): null
E/AudioRecorder( 4042): java.lang.InterruptedException
E/AudioRecorder( 4042):     at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireSharedInterruptibly(AbstractQueuedSynchronizer.java:1048)
E/AudioRecorder( 4042):     at java.util.concurrent.CountDownLatch.await(CountDownLatch.java:230)
E/AudioRecorder( 4042):     at com.llfbandit.record.record.recorder.RecordThread.startRecording$lambda$0(RecordThread.kt:124)
E/AudioRecorder( 4042):     at com.llfbandit.record.record.recorder.RecordThread.$r8$lambda$ldmev7sgpiaTAinIeDKedqNmCzU(Unknown Source:0)
E/AudioRecorder( 4042):     at com.llfbandit.record.record.recorder.RecordThread$$ExternalSyntheticLambda0.run(Unknown Source:2)
E/AudioRecorder( 4042):     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
E/AudioRecorder( 4042):     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
E/AudioRecorder( 4042):     at java.lang.Thread.run(Thread.java:1012)

To Reproduce

My code just like this, and it thrown an exception

final stream = await record.startStream(const RecordConfig(encoder: AudioEncoder.pcm16bits, bitRate: 14000, sampleRate: 12000, numChannels: 1, echoCancel: true, noiseSuppress: true));
onRecordStreamChange = stream.listen((chunk) async { 
   // do some stuff
});

---------------------------------------------------------------------------------------

await record.stop();
await onRecordStreamChange?.cancel();

Expected behavior

No error just like previous version (record 5.0.5 with record_android 1.1.0)

Additional context

Depedencies that I use:

dependencies:
  android_intent_plus: ^5.0.2
  animated_marker: ^0.0.5
  appcheck: ^1.1.0
  audio_video_progress_bar: ^2.0.3
  audioplayers: ^6.0.0
  awesome_notifications: ^0.9.3+1
  awesome_notifications_core: ^0.9.3
  basic_utils: ^5.7.0
  bubble: ^1.2.1
  cached_network_image: ^3.3.1
  catcher_2: ^1.2.6
  collection: ^1.18.0
  custom_pop_up_menu_fork: ^2.0.0
  device_info_plus: ^10.1.0
  dio: ^5.4.3+1
  dropdown_search: ^5.0.6
  easy_image_viewer: ^1.5.0
  encrypt: ^5.0.3
  fast_contacts: ^3.1.3
  file_picker: ^8.0.3
  firebase_core: ^2.31.1
  firebase_messaging: ^14.9.3
  flex_seed_scheme: ^2.0.0
  flick_video_player: ^0.8.0
  flutter:
    sdk: flutter
  flutter_archive: ^6.0.3
  flutter_cache_manager: ^3.3.2
  flutter_foreground_task: ^6.2.0
  flutter_keyboard_visibility: ^6.0.0
  flutter_native_splash: ^2.4.0
  flutter_secure_storage: ^9.2.2
  font_awesome_flutter: ^10.7.0
  freezed_annotation: ^2.4.1
  gap: ^3.0.1
  geolocator: ^12.0.0
  get: 4.6.6
  google_fonts: ^6.2.1
  google_maps_flutter: ^2.6.1
  image_picker: ^1.1.1
  intl: ^0.19.0
  isar:
    version: 3.1.7
    hosted: https://pub.isar-community.dev/
  isar_flutter_libs:
    version: 3.1.7
    hosted: https://pub.isar-community.dev/
  json_annotation: ^4.9.0
  just_audio: ^0.9.38
  loading_animation_widget: ^1.2.1
  logging: ^1.2.0
  lottie: ^3.1.2
  open_file_plus: ^3.4.1+1
  package_info_plus: ^8.0.0
  path: ^1.9.0
  path_provider: ^2.1.3
  permission_handler: ^11.3.1
  photo_view: ^0.15.0
  pin_code_fields: ^8.0.1
  pointycastle: ^3.9.1
  pretty_qr_code: ^3.3.0
  record: ^5.1.0
  ripple_wave: ^0.1.4
  share_plus: ^9.0.0
  shared_preferences: ^2.2.3
  sliver_tools: ^0.2.12
  socket_io_client: ^2.0.3+1
  tw_queue: ^0.0.3
  url_launcher: ^6.2.6
  uuid: ^4.4.0
  version: ^3.0.2
  very_good_infinite_list: ^0.7.1
  video_player: ^2.8.6
  wakelock_plus: ^1.2.5
  wave: ^0.2.2
llfbandit commented 5 months ago

Thanks for the report! record_android 1.2.1 has been released fixing this.

liemfs commented 5 months ago

Thanks for the fix I really appreciate it