public void stop(){
  if (state == State.RECORDING) {
    if (rUncompressed) {
      audioRecorder.stop();
      try {
        randomAccessWriter.seek(4);
        randomAccessWriter.writeInt(Integer.reverseBytes(36 + payloadSize));
        randomAccessWriter.seek(40);
        randomAccessWriter.writeInt(Integer.reverseBytes(payloadSize));
        randomAccessWriter.close();
      }
 catch (      IOException e) {
        state=State.ERROR;
      }
    }
 else {
      mediaRecorder.stop();
    }
    state=State.STOPPED;
  }
 else {
    state=State.ERROR;
  }
}

public void stop ( ) { if ( state == State . RECORDING ) { if ( rUncompressed ) { audioRecorder . stop ( ) ; try { randomAccessWriter . seek ( 4 ) ; randomAccessWriter . writeInt ( Integer . reverseBytes ( 36 + payloadSize ) ) ; randomAccessWriter . seek ( 40 ) ; randomAccessWriter . writeInt ( Integer . reverseBytes ( payloadSize ) ) ; randomAccessWriter . close ( ) ; } catch ( IOException e ) { state = State . ERROR ; } } else { mediaRecorder . stop ( ) ; } state = State . STOPPED ; } else { state = State . ERROR ; } }
stops the recording , and sets the state to stopped . in case of further usage , a reset is needed . also finalizes the wave file in case of uncompressed recording .
