Hi all,

i'm getting the above error message when i run below code. please let
me know if you have found any solution for this?

                int sampleRateInHz = 11025;// 44100, 22050 and 11025
                int channelConfig = AudioFormat.CHANNEL_CONFIGURATION_MONO;
                int audioFormat = AudioFormat.ENCODING_PCM_16BIT;
                File file = new
File(Environment.getExternalStorageDirectory(), "xyz.pcm");

                if (file.exists())
                        file.delete();

                try {
                        file.createNewFile();
                } catch (IOException e) {
                        Log.e("crate file:", e.toString());
                }

                try {

                        OutputStream os = new FileOutputStream(file);

                        BufferedOutputStream bos = new BufferedOutputStream(os);

                        DataOutputStream dos = new DataOutputStream(bos);

                        //int bufferSize =11025 +
AudioRecord.getMinBufferSize(sampleRateInHz,channelConfig,
audioFormat);

                        int bufferSize = 440000;

                        short[] buffer = new short[bufferSize];

                        AudioRecord audioRecord = new
AudioRecord(MediaRecorder.AudioSource.MIC, sampleRateInHz,
                                        channelConfig, audioFormat, bufferSize);

                        audioRecord.startRecording();
                        Log.e("recording", "before");

                        while (isRecording) {
                                int bufferReadResult = audioRecord.read(buffer, 
0, bufferSize);
                                for (int i = 0; i < bufferReadResult; i++) {
                                        dos.writeShort(buffer[i]);
                                        Log.e("recording", "recording....");

                                }
                        }

                        audioRecord.stop();
                        dos.close();
                        Log.e("recording", "stopeed");

                } catch (Throwable e) {
                        Log.e("record:", e.toString());
                }


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

To unsubscribe from this group, send email to 
android-developers+unsubscribegooglegroups.com or reply to this email with the 
words "REMOVE ME" as the subject.

Reply via email to