private int cheConfigure(int chePos,int type,int id,int[] channels){
  if (channels[0] >= MAX_CHANNELS) {
    return AAC_ERROR;
  }
  if (chePos != 0) {
    if (ac.che[type][id] == null) {
      ac.che[type][id]=new ChannelElement();
      AacSbr.ctxInit(ac.che[type][id].sbr);
    }
    if (type != TYPE_CCE) {
      if (channels[0] >= MAX_CHANNELS - ((type == TYPE_CPE || (type == TYPE_SCE && ac.oc[1].m4ac.ps == 1)) ? 1 : 0)) {
        log.error(String.format("Too many channels"));
        return AAC_ERROR;
      }
      ac.outputElement[channels[0]++]=ac.che[type][id].ch[0];
      if (type == TYPE_CPE || (type == TYPE_SCE && ac.oc[1].m4ac.ps == 1)) {
        ac.outputElement[channels[0]++]=ac.che[type][id].ch[1];
      }
    }
  }
 else {
    if (ac.che[type][id] != null) {
      AacSbr.ctxClose(ac.che[type][id].sbr);
      ac.che[type][id]=null;
    }
  }
  return 0;
}

private int cheConfigure ( int chePos , int type , int id , int [ ] channels ) { if ( channels [ 0 ] >= MAX_CHANNELS ) { return AAC_ERROR ; } if ( chePos != 0 ) { if ( ac . che [ type ] [ id ] == null ) { ac . che [ type ] [ id ] = new ChannelElement ( ) ; AacSbr . ctxInit ( ac . che [ type ] [ id ] . sbr ) ; } if ( type != TYPE_CCE ) { if ( channels [ 0 ] >= MAX_CHANNELS - ( ( type == TYPE_CPE || ( type == TYPE_SCE && ac . oc [ 1 ] . m4ac . ps == 1 ) ) ? 1 : 0 ) ) { log . error ( String . format ( "Too many channels" ) ) ; return AAC_ERROR ; } ac . outputElement [ channels [ 0 ] ++ ] = ac . che [ type ] [ id ] . ch [ 0 ] ; if ( type == TYPE_CPE || ( type == TYPE_SCE && ac . oc [ 1 ] . m4ac . ps == 1 ) ) { ac . outputElement [ channels [ 0 ] ++ ] = ac . che [ type ] [ id ] . ch [ 1 ] ; } } } else { if ( ac . che [ type ] [ id ] != null ) { AacSbr . ctxClose ( ac . che [ type ] [ id ] . sbr ) ; ac . che [ type ] [ id ] = null ; } } return 0 ; }
check for the channel element in the current channel position configuration . if it exists , make sure the appropriate element is allocated and map the channel order to match the internal ffmpeg channel layout .
