1
0
mirror of https://github.com/mitb-archive/filebot synced 2024-08-13 17:03:45 -04:00

* added info about required native lib arch to error msg if mediainfo native code can't be loaded

This commit is contained in:
Reinhard Pointner 2011-11-15 02:50:48 +00:00
parent 715c6f8ee5
commit 98fdd221ff
5 changed files with 35 additions and 9 deletions

View File

@ -36,7 +36,11 @@ public class MediaInfo implements Closeable {
public MediaInfo() {
handle = MediaInfoLibrary.INSTANCE.New();
try {
handle = MediaInfoLibrary.INSTANCE.New();
} catch (LinkageError e) {
throw new MediaInfoException(e);
}
}
@ -236,7 +240,11 @@ public class MediaInfo implements Closeable {
public static String staticOption(String option, String value) {
return MediaInfoLibrary.INSTANCE.Option(null, new WString(option), new WString(value)).toString();
try {
return MediaInfoLibrary.INSTANCE.Option(null, new WString(option), new WString(value)).toString();
} catch (LinkageError e) {
throw new MediaInfoException(e);
}
}
}

View File

@ -0,0 +1,19 @@
package net.sourceforge.filebot.mediainfo;
import com.sun.jna.Platform;
public class MediaInfoException extends RuntimeException {
public MediaInfoException(LinkageError e) {
this(String.format("Unable to load %d-bit native library 'mediainfo'", Platform.is64Bit() ? 64 : 32), e);
}
public MediaInfoException(String msg, Throwable e) {
super(msg, e);
}
}

View File

@ -58,6 +58,7 @@ import net.sourceforge.filebot.ResourceManager;
import net.sourceforge.filebot.format.ExpressionFormat;
import net.sourceforge.filebot.format.MediaBindingBean;
import net.sourceforge.filebot.mediainfo.MediaInfo;
import net.sourceforge.filebot.mediainfo.MediaInfoException;
import net.sourceforge.filebot.mediainfo.MediaInfo.StreamKind;
import net.sourceforge.tuned.DefaultThreadFactory;
import net.sourceforge.tuned.ui.LazyDocumentListener;
@ -297,8 +298,8 @@ class BindingDialog extends JDialog {
mediaInfo.close();
}
}
} catch (LinkageError e) {
UILogger.log(Level.SEVERE, "Unable to load native library 'mediainfo'", e);
} catch (MediaInfoException e) {
UILogger.log(Level.SEVERE, e.getMessage(), e);
}
// could not retrieve media info

View File

@ -150,9 +150,6 @@ public class SublightSubtitleClient implements SubtitleProvider, VideoHashSubtit
});
} catch (IOException e) {
Logger.getLogger(SublightSubtitleClient.class.getName()).log(Level.WARNING, "Error computing video hash: " + e.getMessage());
} catch (LinkageError e) {
// MediaInfo native lib not available
throw new UnsupportedOperationException(e.getMessage(), e);
}
requests.add(i, request);

View File

@ -15,6 +15,7 @@ import java.util.Formatter;
import java.util.concurrent.TimeUnit;
import net.sourceforge.filebot.mediainfo.MediaInfo;
import net.sourceforge.filebot.mediainfo.MediaInfoException;
import net.sourceforge.filebot.mediainfo.MediaInfo.StreamKind;
@ -32,7 +33,7 @@ import net.sourceforge.filebot.mediainfo.MediaInfo.StreamKind;
*/
public final class SublightVideoHasher {
public static String computeHash(File file) throws IOException, LinkageError {
public static String computeHash(File file) throws IOException, MediaInfoException {
byte[][] hash = new byte[4][];
// 1 byte = 0 (reserved)
@ -79,7 +80,7 @@ public final class SublightVideoHasher {
}
protected static long getDuration(File file, TimeUnit unit) throws IOException, LinkageError {
protected static long getDuration(File file, TimeUnit unit) throws IOException, MediaInfoException {
MediaInfo mediaInfo = new MediaInfo();
if (!mediaInfo.open(file))