MediaRecorder class sound source issues - setAudioSource () - unsupported parameter

I am new to Android development and I have the following question / issue.

I play with the MediaRecorder class to record only microphone sound. I follow the steps indicated on the official website: http://developer.android.com/reference/android/media/MediaRecorder.html

So, I have a method that initializes and sets up a MediaRecorder object 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 run this code in the simulator, thanks to logcat, I see that the setAudioSource method (MediaRecorder.AudioSource.MIC) gives the following error (with the audio_ipunt tag) 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 prepare () method is called, I get another error again:

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

If I start recording by calling the start () method ... I get a lot of messages saying:

 AudioFlinger(34):RecordThread: buffer overflow 

Then ... after stopping and releasing ... I see that the file was created, but it does not seem to be well written. Anway, if I try this on a real device, I can record without problems, but I CANโ€™t play what I just recorded.

I believe the key is in these errors, which I mentioned earlier. How can I fix them? Any suggestion or help?

+4
source share
3 answers

The simulator has a lot of problems with sound recording. Assume that this does not work. Itโ€™s best to try your code on a real device!

+1
source

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

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

+1
source

well, I'm pretty new to this Android programming, but I'll give you guys what I learned so far about this. A few answers here suggest that they are having problems with real devices, mainly with the Galaxy S, and the emulator / virtual device also does not work. Well, I read from Google that the virtual device does not support audio recording right now. This may or may not be accurate. However, a much more experienced Android programmer told me that there is no reason to believe that there is a similarity between devices between devices, since Android is currently available on many devices. In addition, each Android OS is very slightly modified to suit each device specifically, therefore, despite the fact that Droid and Droid X can run Android Froyo, the versions of Froyo are slightly different. All that has been said, perhaps the Galaxy S has a slightly different calling method for a microphone or something like that. My test device is MotoDroid, so I canโ€™t be sure of that, sorry. But I hope this helps a bit!

EDIT: my bad emulator supports audio recording.

0
source

Source: https://habr.com/ru/post/1312273/


All Articles