天天看點

linux錄音裝置權限,【轉】用AudioRecord實作錄音碰到的問題

>

Hi Guys,

> I am a newbie to android and was trying to get a

simple recording

> application up and running.  However I am

facing errors and wondering

> if some of you can point me in the

right direction.

> Stack Trace:

> 03-02

17:27:53.415: ERROR/AudioRecord(224): Could not get audio input

> for record source 1

> 03-02 17:27:53.425:

ERROR/AudioRecord-JNI(224): Error creating

> AudioRecord

instance: initialization check failed.

> 03-02 17:27:53.435:

ERROR/AudioRecord-Java(224):

> [ android.media.AudioRecord ]

Error code -20 when initializing native

> AudioRecord object.

> 03-02 17:27:53.487: ERROR/AudioRecord(224): Recording Failed

> 03-02 17:27:53.487: ERROR/AudioRecord(224):

>

java.lang.IllegalStateException: startRecording() called on an

>

uninitialized AudioRecord.

> 03-02 17:27:53.487:

ERROR/AudioRecord(224):     at

>

android.media.AudioRecord.startRecording(AudioRecord.java:495)

>

Sample Code:

> // Create a new AudioRecord object to record the

audio.

> int bufferSize =

>

AudioRecord.getMinBufferSize(AUDIO_SAMPLE_FREQUENCY_8000HZ,

>

AudioFormat.CHANNEL_CONFIGURATION_MONO,

>

AudioFormat.ENCODING_PCM_16BIT);

> AudioRecord audioRecord = new

> AudioRecord(MediaRecorder.AudioSource.MIC,

>

AUDIO_SAMPLE_FREQUENCY_8000HZ,

>

AudioFormat.CHANNEL_CONFIGURATION_MONO,

>

AudioFormat.ENCODING_PCM_16BIT,

> bufferSize);

>

audioRecord.startRecording();

> AndroidManifest.xml:

> ...

> >

permission>

> ...

> System Info:

>

Eclipse Galileo + SDK 2.1

> IBM T60 running Windows XP

>

Thanks in advance,

> Dmitriy