Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Noise and Audio probe cannot run at the same time #24

Closed
bardram opened this issue Apr 28, 2019 · 6 comments
Closed

Noise and Audio probe cannot run at the same time #24

bardram opened this issue Apr 28, 2019 · 6 comments
Assignees
Labels
enhancement New feature or request

Comments

@bardram
Copy link
Contributor

bardram commented Apr 28, 2019

It seems like the access to the microphone is "taken" by the Noise probe. For example in the example below, first the noise probe collect data (for 2 secs) and work fine and returns a noise recording. Then, when the audio probe wants to record, it get and error in starting the recording -- in the line

E/MediaRecorder( 5788): start failed: -38

Full print from the carp mobile sensing app is:

I/flutter ( 5788): Starting Instance of 'NoiseProbe'
I/MediaRecorderJNI( 5788): setup
I/flutter ( 5788): Sensing started ...
I/MediaRecorderJNI( 5788): setAudioSource(1)
I/MediaRecorderJNI( 5788): setAudioEncoder(0)
I/MediaRecorderJNI( 5788): setOutputFile
I/MediaRecorderJNI( 5788): prepare
I/MediaRecorderJNI( 5788): start
D/NoiseMeterPlugin( 5788): listen()
I/flutter ( 5788): >> {"id":"fece0e90-5970-11e9-f9a7-a331c1237735","timestamp":"2019-04-28T11:30:16.184358Z","mean_decibel":34.23076923076923,"std_decibel":5.984859266008269,"min_decibel":0,"max_decibel":52}
I/flutter ( 5788): Noise - mean: 34.23076923076923, std: 5.984859266008269, min: 0, max: 52
D/FlutterSoundPlugin( 5788): startRecorder
I/MediaRecorderJNI( 5788): setup
I/MediaRecorderJNI( 5788): setAudioSource(1)
I/MediaRecorderJNI( 5788): setAudioEncoder(3)
I/MediaRecorderJNI( 5788): setParameter()
I/MediaRecorderJNI( 5788): setOutputFile
I/MediaRecorderJNI( 5788): prepare
I/MediaRecorderJNI( 5788): start
E/MediaRecorder( 5788): start failed: -38
E/FlutterSoundPlugin( 5788): Exception: 
E/FlutterSoundPlugin( 5788): java.lang.IllegalStateException
E/FlutterSoundPlugin( 5788): 	at android.media.MediaRecorder._start(Native Method)
E/FlutterSoundPlugin( 5788): 	at android.media.MediaRecorder.start(MediaRecorder.java:1310)
E/FlutterSoundPlugin( 5788): 	at com.dooboolab.fluttersound.FlutterSoundPlugin.startRecorder(FlutterSoundPlugin.java:162)
E/FlutterSoundPlugin( 5788): 	at com.dooboolab.fluttersound.FlutterSoundPlugin.lambda$onMethodCall$0$FlutterSoundPlugin(FlutterSoundPlugin.java:65)
E/FlutterSoundPlugin( 5788): 	at com.dooboolab.fluttersound.FlutterSoundPlugin$$Lambda$0.run(Unknown Source:8)
E/FlutterSoundPlugin( 5788): 	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457)
E/FlutterSoundPlugin( 5788): 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
E/FlutterSoundPlugin( 5788): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162)
E/FlutterSoundPlugin( 5788): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636)
E/FlutterSoundPlugin( 5788): 	at java.lang.Thread.run(Thread.java:764)
@bardram
Copy link
Contributor Author

bardram commented Apr 28, 2019

@thomasnilsson - maybe the noise plugin does not release the microphone?

@bardram bardram assigned bardram and thomasnilsson and unassigned bardram Apr 28, 2019
@thomasnilsson
Copy link
Contributor

Will have a look at the underlying implementation

@thomasnilsson
Copy link
Contributor

It does not seem possible to run two plugins which use the same microphone, at the same time.

However there is no problem running them in an interleaving fashion, where only one plugin is using the microphone at one time.

@bardram
Copy link
Contributor Author

bardram commented Jun 4, 2019

We have some more fundamental problems w. the audio plugin -- have raised an issue:

@bardram
Copy link
Contributor Author

bardram commented Nov 6, 2019

A new release of flutter_sound fixing #93 above have been released and I've updated the CARP package. However, still have not tested if the noise and audio probe can be used in the same study, if taking care of not running at the same time (interleaving).

@bardram
Copy link
Contributor Author

bardram commented Aug 3, 2021

With the upgrade to carp_audio_package v. 0.30.0 using flutter_sound: ^8.1.4 for audio recording, this seems to be working now.

@bardram bardram self-assigned this Aug 3, 2021
@bardram bardram closed this as completed Aug 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants