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
103 stars 70 forks source link

Microphone config won't change when opening micstream a second time #36

Closed philip260897 closed 2 years ago

philip260897 commented 2 years ago

Hey, first of all thanks for the work you've done. My application requires for me to start/stop recording frequently with different settings (sample rate, bit depth), but I've noticed the config won't change when calling MicStream.microphone after the first time!

I've noticed on line 90: mic_stream.dart you're working with the cached _microphone stream from previous initializations which won't reconfigure the microphone with the new settings. Is this intended behavior, if so, can you add an option to force re-initialization every time ?

anarchuser commented 2 years ago

Currently, this is intended behaviour. There hasn't been a need for changing configs before. Let me check how much work it is to remove the caching part. If the native language parts need to be adjusted, I can only fix it for android

anarchuser commented 2 years ago

The main reason why this caching exists is to prevent parallel access to the microphone. It shouldn't be a problem to cache the configs instead, though, and reinitialise the microphone.

anarchuser commented 2 years ago

Please update to mic_stream: 0.6.0 and check whether the changes make it work for you

philip260897 commented 2 years ago

Yes, works like a charm! thank you :)