Problems with MediaRecorder class setting audio source - setAudioSource() - unsupported parameter

StackOverflow https://stackoverflow.com/questions/3002537

  •  25-09-2019
  •  | 
  •  

Question

I'm new in Android development and I have the next question/problem.

I'm playing around with the MediaRecorder class to record just audio from the microphone. I'm following the steps indicated in the official site: http://developer.android.com/reference/android/media/MediaRecorder.html

So I have a method that initializes and configure the MediaRecorder object in order to start recording. Here you have the code:


        this.mr = new MediaRecorder();
        this.mr.setAudioSource(MediaRecorder.AudioSource.MIC);
        this.mr.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
        this.mr.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
        this.mr.setOutputFile(this.path + this.fileName);
        try {
            this.mr.prepare();
        } catch (IllegalStateException e) {
            Log.d("Syso", e.toString());
            e.printStackTrace();
        } catch (IOException e) {
            Log.d("Syso", e.toString());
            e.printStackTrace();
        }

When I execute this code in the simulator, thanks to logcat, I can see that the method setAudioSource(MediaRecorder.AudioSource.MIC) gives the next error (with the tag audio_ipunt) when it is called:


ERROR/audio_input(34): unsupported parameter: x-pvmf/media-input-node/cap-config-interface;valtype=key_specific_value
ERROR/audio_input(34): VerifyAndSetParameter failed

And then when the method prepare() is called, I get the another error again:


ERROR/PVOMXEncNode(34): PVMFOMXEncNode-Audio_AMRNB::DoPrepare(): Got Component OMX.PV.amrencnb handle 

If I start to record bycalling the method start()... I get lots of messages saying:


AudioFlinger(34):RecordThread: buffer overflow

Then...after stop and release,.... I can see that a file has been created, but it doesn't seem that it been well recorderd. Anway, if i try this in a real device I can record with no problems, but I CAN'T play what I just recorded.

I gues that the key is in these errors that I've mentioned before. How can I fix them? Any suggestion or help??

Was it helpful?

Solution

The simulator has lots of issues with the audio recording. Lets say that it doesn't work. Your best bet is try your code in a real device!!!

OTHER TIPS

Note: The Android Emulator does not have the ability to capture audio, but actual devices are likely to provide these capabilities.

Ref: http://developer.android.com/guide/topics/media/audio-capture.html

well, i'm fairly new at this android programming, but I'll give you guys what I've learned so far about that. A few of the answers on here state that they are having issues on real devices, mostly the galaxy S, and the emulator/virtual device isn't working either. Well, I read from Google that the virtual device doesn't support audio recording right now. That may or may not be still accurate. However, a significantly more experienced android programmer told me that there is no reason to believe that there are similarities between devices as far as hardware goes, since android is available on so many devices nowadays. Also, each android OS is modified very slightly to cater specifically to each device, so even though the Droid and the Droid X may both be running Android Froyo, the versions of Froyo are slightly different. All that being said, maybe the Galaxy S has a slightly different call method for the microphone or something. My test device happens to be a MotoDroid, so I can't be sure about that, sorry. But I hope this helps a little bit!

EDIT: my bad, the emulator does support audio recording.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top