/** * Prepares the recorder to begin capturing and encoding data. This method must be called after * setting up the desired audio and video sources, encoders, file format, etc., but before * start(). * * @throws IllegalStateException if it is called after start() or before setOutputFormat(). * @throws IOException if prepare fails otherwise. */ public void prepare() throws IllegalStateException, IOException { if (mPath != null) { FileOutputStream fos = new FileOutputStream(mPath); try { _setOutputFile(fos.getFD(), 0, 0); } finally { fos.close(); } } else if (mFd != null) { _setOutputFile(mFd, 0, 0); } else { throw new IOException("No valid output file"); } _prepare(); }
/** * Prepares the recorder to begin capturing and encoding data. This method must be called after * setting up the desired audio and video sources, encoders, file format, etc., but before * start(). * * @throws IllegalStateException if it is called after start() or before setOutputFormat(). * @throws IOException if prepare fails otherwise. */ public void prepare() throws IllegalStateException, IOException { if (mPath != null) { RandomAccessFile file = new RandomAccessFile(mPath, "rws"); try { _setOutputFile(file.getFD(), 0, 0); } finally { file.close(); } } else if (mFd != null) { _setOutputFile(mFd, 0, 0); } else { throw new IOException("No valid output file"); } _prepare(); }