// Path: external/com/ideaheap/io/VorbisFileOutputStream.java
// public class VorbisFileOutputStream implements Closeable {
// 	
// 	// The index into native memory where the ogg stream info is stored.
// 	private final int oggStreamIdx;
// 	
// 	/*
// 	static {
// 		System.loadLibrary("ogg");
// 		System.loadLibrary("vorbis");
// 		System.loadLibrary("vorbis-stream");
// 	}
// 	*/
// 
// 	public VorbisFileOutputStream (String fname, VorbisInfo s) throws IOException {
// 		oggStreamIdx = this.create(fname, s);
// 	}
// 	public VorbisFileOutputStream (String fname) throws IOException {
// 		oggStreamIdx = this.create(fname, new VorbisInfo());
// 	}
// 	
// 	public void close() throws IOException {
// 		this.closeStreamIdx(this.oggStreamIdx);
// 	}
// 	
// 	/**
// 	 * Please god never use this.  It works, but this is very inefficient.
// 	 * @param buf
// 	 * @return
// 	 * @throws IOException
// 	 */
// 	public int write(final short buf) throws IOException {
// 		short [] bufArray = new short[1];
// 		bufArray[0] = buf;
// 		return this.writeStreamIdx(this.oggStreamIdx, bufArray, 0, 1);
// 	}
// 	
// 	/**
// 	 * Write PCM data to ogg.  This assumes that you pass your streams in interleaved.
// 	 * @param buffer
// 	 * @param offset
// 	 * @param length
// 	 * @return
// 	 * @throws IOException
// 	 */
// 	public int write(final short [] buffer, int offset, int length) throws IOException {
// 		return this.writeStreamIdx(this.oggStreamIdx, buffer, 0, length);
// 	}
// 	
// 	/**
// 	 * Write PCM data to ogg. This assumes you pass streams in interleaved.
// 	 * @param buffer
// 	 * @return
// 	 * @throws IOException
// 	 */
// 	public int write(final short [] buffer) throws IOException {
// 		return this.writeStreamIdx(this.oggStreamIdx, buffer, 0, buffer.length);
// 	}
// 	
// 	private native int writeStreamIdx(int idx, short [] pcmdata, int offset, int size) throws IOException;
// 	private native void closeStreamIdx(int idx) throws IOException;
// 	private native int create(String path, VorbisInfo s) throws IOException;
// }
// 
// Path: external/com/ideaheap/io/VorbisInfo.java
// public class VorbisInfo {
// 	/**
// 	 * The number of channels to be encoded. For your sake, here are the
// 	 * official channel positions for the first five according to Xiph.org.
// 	 * one channel - the stream is monophonic
// 	 * two channels - the stream is stereo. channel order: left, right
//      * three channels - the stream is a 1d-surround encoding.
//      * 		channel order: left, center, right
//      * four channels - the stream is quadraphonic surround. 
//      * 		channel order: front left, front right, rear left, rear right
//      * five channels - the stream is five-channel surround.
//      * 		channel order: front left, center, front right, rear left, rear right
// 	 */
// 	public int 		channels = 1;
// 	
// 	/**
// 	 * The number of samples per second of pcm data.
// 	 */
// 	public int 		sampleRate = 44100;
// 	
// 	/**
// 	 * The recording quality of the encoding. This is not currently
// 	 * set for the decoder. The range goes from -.1 (worst) to 1 (best)
// 	 */
// 	public float 	quality = 0.4f; // Ignored for ABR
// 	
// 	/**
// 	 * the total number of samples from the recording. This field means
// 	 * nothing to the encoder.
// 	 */
// 	public long		length;
// 	
// 	public int 	bitRate = 32000; // Bit rate for the average bit rate, ignored for VBR
// 	public int	coder = 0; // 0 for ABR, 1 for VBR
// 
// }


import java.io.IOException;
import java.nio.ShortBuffer;
import android.util.Log;
import com.ideaheap.io.VorbisFileOutputStream;
import com.ideaheap.io.VorbisInfo;
/**
 * SpokenPic Java source code 
 * @author Ricardo Galli (gallir@gmail.com)
 * @copyright: Menéame & APSL, 2012
 * @license: GPL3
 */

package com.spokenpic.audio;




public class AudioEncoderVorbis extends AudioEncoderRecord {
	
	VorbisFileOutputStream fWriter;
	VorbisInfo mConfig;
	
	// TODO: add internal buffering
	ShortBuffer mBigBuffer;
	final int BUFFER_CAPACITY = 16536;

	public AudioEncoderVorbis(int chanConfig, int userConfig) {
		super(chanConfig, userConfig);
	}

	@Override
	Boolean prepareEncoder() throws IOException {
// Path: external/com/ideaheap/io/VorbisFileOutputStream.java
// public class VorbisFileOutputStream implements Closeable {
// 	
// 	// The index into native memory where the ogg stream info is stored.
// 	private final int oggStreamIdx;
// 	
// 	/*
// 	static {
// 		System.loadLibrary("ogg");
// 		System.loadLibrary("vorbis");
// 		System.loadLibrary("vorbis-stream");
// 	}
// 	*/
// 
// 	public VorbisFileOutputStream (String fname, VorbisInfo s) throws IOException {
// 		oggStreamIdx = this.create(fname, s);
// 	}
// 	public VorbisFileOutputStream (String fname) throws IOException {
// 		oggStreamIdx = this.create(fname, new VorbisInfo());
// 	}
// 	
// 	public void close() throws IOException {
// 		this.closeStreamIdx(this.oggStreamIdx);
// 	}
// 	
// 	/**
// 	 * Please god never use this.  It works, but this is very inefficient.
// 	 * @param buf
// 	 * @return
// 	 * @throws IOException
// 	 */
// 	public int write(final short buf) throws IOException {
// 		short [] bufArray = new short[1];
// 		bufArray[0] = buf;
// 		return this.writeStreamIdx(this.oggStreamIdx, bufArray, 0, 1);
// 	}
// 	
// 	/**
// 	 * Write PCM data to ogg.  This assumes that you pass your streams in interleaved.
// 	 * @param buffer
// 	 * @param offset
// 	 * @param length
// 	 * @return
// 	 * @throws IOException
// 	 */
// 	public int write(final short [] buffer, int offset, int length) throws IOException {
// 		return this.writeStreamIdx(this.oggStreamIdx, buffer, 0, length);
// 	}
// 	
// 	/**
// 	 * Write PCM data to ogg. This assumes you pass streams in interleaved.
// 	 * @param buffer
// 	 * @return
// 	 * @throws IOException
// 	 */
// 	public int write(final short [] buffer) throws IOException {
// 		return this.writeStreamIdx(this.oggStreamIdx, buffer, 0, buffer.length);
// 	}
// 	
// 	private native int writeStreamIdx(int idx, short [] pcmdata, int offset, int size) throws IOException;
// 	private native void closeStreamIdx(int idx) throws IOException;
// 	private native int create(String path, VorbisInfo s) throws IOException;
// }
// 
// Path: external/com/ideaheap/io/VorbisInfo.java
// public class VorbisInfo {
// 	/**
// 	 * The number of channels to be encoded. For your sake, here are the
// 	 * official channel positions for the first five according to Xiph.org.
// 	 * one channel - the stream is monophonic
// 	 * two channels - the stream is stereo. channel order: left, right
//      * three channels - the stream is a 1d-surround encoding.
//      * 		channel order: left, center, right
//      * four channels - the stream is quadraphonic surround. 
//      * 		channel order: front left, front right, rear left, rear right
//      * five channels - the stream is five-channel surround.
//      * 		channel order: front left, center, front right, rear left, rear right
// 	 */
// 	public int 		channels = 1;
// 	
// 	/**
// 	 * The number of samples per second of pcm data.
// 	 */
// 	public int 		sampleRate = 44100;
// 	
// 	/**
// 	 * The recording quality of the encoding. This is not currently
// 	 * set for the decoder. The range goes from -.1 (worst) to 1 (best)
// 	 */
// 	public float 	quality = 0.4f; // Ignored for ABR
// 	
// 	/**
// 	 * the total number of samples from the recording. This field means
// 	 * nothing to the encoder.
// 	 */
// 	public long		length;
// 	
// 	public int 	bitRate = 32000; // Bit rate for the average bit rate, ignored for VBR
// 	public int	coder = 0; // 0 for ABR, 1 for VBR
// 
// }


// Path: src/com/spokenpic/audio/AudioEncoderVorbis.java
import java.io.IOException;
import java.nio.ShortBuffer;
import android.util.Log;
import com.ideaheap.io.VorbisFileOutputStream;
import com.ideaheap.io.VorbisInfo;

/**
 * SpokenPic Java source code 
 * @author Ricardo Galli (gallir@gmail.com)
 * @copyright: Menéame & APSL, 2012
 * @license: GPL3
 */

package com.spokenpic.audio;




public class AudioEncoderVorbis extends AudioEncoderRecord {
	
	VorbisFileOutputStream fWriter;
	VorbisInfo mConfig;
	
	// TODO: add internal buffering
	ShortBuffer mBigBuffer;
	final int BUFFER_CAPACITY = 16536;

	public AudioEncoderVorbis(int chanConfig, int userConfig) {
		super(chanConfig, userConfig);
	}

	@Override
	Boolean prepareEncoder() throws IOException {
		mConfig = new VorbisInfo();