Permalink
Browse files

Add FileNotFoundException to JVstHost2.newInstance

  • Loading branch information...
1 parent dca5893 commit 3e3a46faa94162d86145ef2a0417c5b0635c17a5 @mhroth committed Jan 23, 2009
View
Binary file not shown.
View
4 README
@@ -98,7 +98,9 @@ There is a basic idiom to loading a VST, which is written below.
JVstHost2 vst;
try {
- vst = JVstHost2.newInstance(vstFile, sampleRate, blockSize);
+ vst = JVstHost2.newInstance(vstFile, SAMPLE_RATE, BLOCK_SIZE);
+} catch (FileNotFoundException fnfe) {
+ fnfe.printStackTrace(System.err);
} catch (JVstLoadException jvle) {
jvle.printStackTrace(System.err);
}
@@ -66,11 +66,15 @@ protected JVstHost2(File pluginFile, long pluginPtr) {
* @param file The location of the native plugin library.
* @param sampleRate The sample rate at which the plugin should operate.
* @param blockSize The maximum size of an audio block
- * @return A new instance of a JVstHost2 subclass corresponding to the plugin's vst version.
+ * @return A new instance of a <code>JVstHost2</code> subclass corresponding to the plugin's vst version.
+ * @throws FileNotFoundException Thrown if the given VST File does not exist.
+ * @throws IllegalArgumentException Thrown if the supplied sample rate or block size exceed their allowed values.
+ * See <code>setSampleRate</code> and <code>setBlockSize</code>.
* @throws JVstLoadException Thrown if there are any errors while loading the native VST.
- * Use <code>JVstLoadException.getMessage</code> to retrieve the cause.
+ * @throws NullPointerException Thrown if the given VST File is null.
+ * @throws For more information on exceptions, see <a href="http://github.com/mhroth/jvsthost/wikis/micro-blog/#fn3">http://github.com/mhroth/jvsthost/wikis/micro-blog/</a>
*/
- public static JVstHost2 newInstance(File file, float sampleRate, int blockSize) throws JVstLoadException {
+ public static JVstHost2 newInstance(File file, float sampleRate, int blockSize) throws FileNotFoundException, JVstLoadException {
JVstHost2 vst = newInstance(file);
vst.setSampleRate(sampleRate);
vst.setBlockSize(blockSize);
@@ -83,13 +87,18 @@ public static JVstHost2 newInstance(File file, float sampleRate, int blockSize)
* only initialised, and not started, nor supplied with necessary information, such as sample rate
* or block size.
* @param file The location of the native plugin library.
- * @return A new instance of a JVstHost2 subclass corresponding to the plugin's vst version.
+ * @return A new instance of a <code>JVstHost2</code> subclass corresponding to the plugin's vst version.
+ * @throws FileNotFoundException Thrown if the given VST File does not exist.
* @throws JVstLoadException Thrown if there are any errors while loading the native VST.
- * Use JVstLoadException.getMessage() to retrieve the cause.
+ * @throws NullPointerException Thrown if the given VST File is null.
+ * @throws For more information on exceptions, see <a href="http://github.com/mhroth/jvsthost/wikis/micro-blog/#fn3">http://github.com/mhroth/jvsthost/wikis/micro-blog/</a>
*/
- public static JVstHost2 newInstance(File file) throws JVstLoadException {
+ public static JVstHost2 newInstance(File file) throws FileNotFoundException, JVstLoadException {
+ if (file == null) {
+ throw new NullPointerException("VST file cannot be null. Specify a non-null File object.");
+ }
if (!file.exists()) {
- throw new JVstLoadException(new FileNotFoundException(file.toString()));
+ throw new FileNotFoundException(file.toString());
}
long pluginPtr = loadPlugin(file.toString());
int vstVersionInt = getVstVersion(pluginPtr);
@@ -22,6 +22,7 @@
package com.synthbot.minihost;
import java.io.File;
+import java.io.FileNotFoundException;
import com.synthbot.audioio.vst.JVstAudioThread;
import com.synthbot.audioplugin.view.StringGui;
@@ -49,6 +50,9 @@ public GuiMiniHost(File vstFile) {
// load the vst
try {
vst = JVstHost2.newInstance(vstFile, SAMPLE_RATE, BLOCK_SIZE);
+ } catch (FileNotFoundException fnfe) {
+ fnfe.printStackTrace(System.err);
+ System.exit(1);
} catch (JVstLoadException jvle) {
jvle.printStackTrace(System.err);
System.exit(1);

0 comments on commit 3e3a46f

Please sign in to comment.