Skip to content
Snippets Groups Projects
Commit 108d27ba authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Code factorization

parent 7c47d44d
No related branches found
No related tags found
No related merge requests found
......@@ -32,6 +32,7 @@ import org.videolan.libvlc.LibVLC;
import org.videolan.libvlc.Media;
import java.io.BufferedReader;
import java.io.Closeable;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
......@@ -170,14 +171,8 @@ public class VLCUtil {
}
} catch (IOException ignored) {
} finally {
if (br != null)
try {
br.close();
} catch (IOException e) {}
if (fileReader != null)
try {
fileReader.close();
} catch (IOException e) {}
close(br);
close(fileReader);
}
if (processors == 0)
processors = 1; // possibly borked cpuinfo?
......@@ -243,14 +238,8 @@ public class VLCUtil {
Log.w(TAG, "Could not parse maximum CPU frequency!");
Log.w(TAG, "Failed to parse: " + line);
} finally {
if (br != null)
try {
br.close();
} catch (IOException ignored) {}
if (fileReader != null)
try {
fileReader.close();
} catch (IOException ignored) {}
close(br);
close(fileReader);
}
// Store into MachineSpecs
......@@ -372,16 +361,10 @@ public class VLCUtil {
return null;
}
return elf;
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (in != null)
in.close();
} catch (IOException e) {
}
close(in);
}
return null;
}
......@@ -566,7 +549,6 @@ public class VLCUtil {
else
sb.append(c);
}
return sb.toString();
}
......@@ -592,5 +574,12 @@ public class VLCUtil {
return nativeGetThumbnail(media, i_width, i_height);
}
private static void close(Closeable closeable) {
if (closeable != null)
try {
closeable.close();
} catch (IOException ignored) {}
}
private static native byte[] nativeGetThumbnail(Media media, int i_width, int i_height);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment