• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Could not get audio input for record source 1

cjm32

Lurker
Feb 10, 2011
1
0
Hi

I keep getting this error when trying to initialize and AudioRecord object, in an attempt to record sounds using the emulator using Eclipse.

I have tried with various bit sampling rates, 8000 is the only one that is valid, but the error continues to appear. I have tried on various versions of the sdk, 1.5, 1.6, 2, 2.2 and 2.3.1. (and combinations of with the AVD).

Here is the code:

Code:
    Log.v(TAG, "About to initialize recording");
    //int[] samplingRates = {44100, 22050, 16000, 11025, 8000};
    int[] samplingRates = {8000};
  for (int i = 0; i < samplingRates.length; ++i)
  {
   try
   {
    Log.d(TAG,"Trying sampling rate: " + samplingRates[i]);
    int min = AudioRecord.getMinBufferSize(samplingRates[i], 
      AudioFormat.CHANNEL_CONFIGURATION_MONO,
      //AudioFormat.CHANNEL_IN_MONO,
      AudioFormat.ENCODING_PCM_16BIT);
    Log.d(TAG,"MinBufferSize: " + min);
    AudioRecord record = new AudioRecord(MediaRecorder.AudioSource.MIC, samplingRates[i],
      AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, min);
    if (record.getState() == AudioRecord.STATE_INITIALIZED)
    {
     Log.d("Recorder", "Audio recorder initialised at " + record.getSampleRate());
     return record;
    }
    record.release();
    record = null;
   }
   catch (IllegalArgumentException e)
   {
    // Try the next one.
    Log.d(TAG,"Initialization failed");
   }
  }
  // None worked.
  return null;

Has anyone seen this same problem, it seems to be a straight forward request so i
 

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones