public void addSamples ( int [ ] samples , int count ) { assert ( count * streamConfig . getChannelCount ( ) <= samples . length ) ; if ( samples . length < count * streamConfig . getChannelCount ( ) ) throw new IllegalArgumentException ( "count given exceeds samples array bounds" ) ; sampleLock . lock ( ) ; try { //get number of channels int channels = streamConfig . getChannelCount ( ) ; int maxBlock = streamConfig . getMaxBlockSize ( ) ; if ( unfilledRequest == null ) unfilledRequest = prepareRequest ( maxBlock , channels ) ; int remaining = count ; int offset = 0 ; while ( remaining > 0 ) { int newRemaining = unfilledRequest . addInterleavedSamples ( samples , offset , remaining , maxBlock ) ; offset += ( remaining - newRemaining ) * channels ; remaining = newRemaining ; if ( unfilledRequest . isFull ( maxBlock ) ) { this . preparedRequests . add ( unfilledRequest ) ; unfilledRequest = null ; } if ( remaining > 0 ) { unfilledRequest = prepareRequest ( maxBlock , channels ) ; } } } finally { sampleLock . unlock ( ) ; } }
Add samples to the encoder so they may then be encoded . This method uses breaks the samples into blocks which will then be made available to encode .