AudioRecord not working for Motorola Milestone

I only have this problem on Motorola Milestone. The code:

// init recorder
recordInstance = new AudioRecord(MediaRecorder.AudioSource.MIC,
    8000, AudioFormat.CHANNEL_CONFIGURATION_MONO,
    AudioFormat.ENCODING_PCM_16BIT, 8000);

recordInstance.startRecording();

//more code here

recordInstance.stop();

      

Information about the error that I have (cannot find more at that time as I do not have the milestone itself to debug):

Uncaught handler: thread main exiting due to uncaught exception
java.lang.IllegalStateException: stop() called on an uninitialized AudioRecord.
at android.media.AudioRecord.stop(AudioRecord.java:51 6)

      

Obviously I'm not the only one with this problem. Some very similar threads I found (no solution):

http://groups.google.com/group/android-developers/browse_thread/thread/6dd24aeb484b2e40 http://androidcommunity.com/forums/f2/problem-using-audiorecord-in-motorola-milestone-30935/ http: / /community.developer.motorola.com/t5/Android-App-Development-for/Problem-using-AudioRecord-on-Milestone-device/mp/3889 http://www.fring.com/forums/showthread.php? t = 16194 http://groups.google.com/group/android-developers/browse_thread/thread/63be273ba59c635e/1c4a010fd470d328

+2


a source to share


3 answers


This should work:

recordInstance = new AudioRecord(MediaRecorder.AudioSource.MIC,
16000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, 16000);

      



Just stick to the standard sample rates http://en.wikipedia.org/wiki/Sampling_rate#Audio . I wonder why Milestone doesn't support 8-bit encoding recording. It also gives me an error - "Invalid audio format".

+1


a source


First, as they say, try putting a try catch block on top of a stop, as the debug post says, the entry ends up in IllegalState.



Perhaps if you can catch the exception, you can find out what the problem is.

0


a source


The problem is not the parameters, the problem is Motorola cheating with Android, AudioRecord will not build itself properly if the mode is IN_CALL, if its MODE_NORMAL it should be fine.

This is because something in the Motorolas code triggers the input in IN_CALL mode.

0


a source







All Articles