@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private int queueInputBuffer(MediaCodec codec,ByteBuffer[] inputBuffers,int index,SpeechRecord speechRecord){
  if (speechRecord == null || speechRecord.getRecordingState() != SpeechRecord.RECORDSTATE_RECORDING) {
    return -1;
  }
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
    ByteBuffer inputBuffer=inputBuffers[index];
    inputBuffer.clear();
    int size=inputBuffer.limit();
    byte[] buffer=new byte[size];
    int status=read(speechRecord,buffer);
    if (status < 0) {
      handleError("status = " + status);
      return -1;
    }
    inputBuffer.put(buffer);
    codec.queueInputBuffer(index,0,size,0,0);
    return size;
  }
  return -1;
}

@ TargetApi ( Build . VERSION_CODES . JELLY_BEAN ) private int queueInputBuffer ( MediaCodec codec , ByteBuffer [ ] inputBuffers , int index , SpeechRecord speechRecord ) { if ( speechRecord == null || speechRecord . getRecordingState ( ) != SpeechRecord . RECORDSTATE_RECORDING ) { return - 1 ; } if ( Build . VERSION . SDK_INT >= Build . VERSION_CODES . JELLY_BEAN ) { ByteBuffer inputBuffer = inputBuffers [ index ] ; inputBuffer . clear ( ) ; int size = inputBuffer . limit ( ) ; byte [ ] buffer = new byte [ size ] ; int status = read ( speechRecord , buffer ) ; if ( status < 0 ) { handleError ( "status = " + status ) ; return - 1 ; } inputBuffer . put ( buffer ) ; codec . queueInputBuffer ( index , 0 , size , 0 , 0 ) ; return size ; } return - 1 ; }
copy audio from the recorder into the encoder .
