app/src/main/java/org/sil/hearthis/WavAudioRecorder.java
/**
	 * 
	 * 
	 *  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.
	 * 
	 */
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.
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 .
public void stop() {
		if (state == State.RECORDING) {
			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) {
				Log.e(WavAudioRecorder.class.getName(), "I/O exception occured while closing output file");
				state = State.ERROR;
			}
			state = State.STOPPED;
		} else {
			Log.e(WavAudioRecorder.class.getName(), "stop() called on illegal state");
			state = State.ERROR;
		}
	}
public void stop ( ) { if ( state == State . RECORDING ) { 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 ) { Log . e ( WavAudioRecorder . class . getName ( ) , "I/O exception occured while closing output file" ) ; state = State . ERROR ; } state = State . STOPPED ; } else { Log . e ( WavAudioRecorder . class . getName ( ) , "stop() called on illegal state" ) ; state = State . ERROR ; } }
// Write size to RIFF header // Write size to Subchunk2Size field