anarchuser / mic_stream

Flutter plugin to get an infinite audio stream from the microphone
https://pub.dev/packages/mic_stream
GNU General Public License v3.0
100 stars 68 forks source link

Not compatible with workmanager if the microphone is open #87

Open fobeid1 opened 10 months ago

fobeid1 commented 10 months ago

ERROR :: AndroidRuntime(16220): java.lang.NullPointerException: Attempt to invoke virtual method 'int android.media.AudioRecord.read(byte[], int, int)' on a null object reference ERROR :: AndroidRuntime(16220): at com.code.aaron.micstream.MicStreamPlugin$1.run(MicStreamPlugin.java:132) ERROR :: AndroidRuntime(16220): at java.lang.Thread.run(Thread.java:1012)

When executeTask by Workmanager while the recorder is running, the Workmanager activate the 'onDetachedFromEngine' function that call 'onCancel' when executeTask

@Override

public void onDetachedFromEngine(FlutterPluginBinding binding) { // TODO not call :: onCancel(null); // replace it with a new 'dispose' function that called by onMethodCall }