summaryrefslogtreecommitdiff
path: root/Source/Android/src/org
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2013-10-10 00:11:33 -0400
committerLioncash <mathew1800@gmail.com>2013-10-10 00:11:33 -0400
commit8b6ff7a358f0e6dcd1ee597c5a5ae9b98389a564 (patch)
tree8e1356499962095be741f7c2ef8d508c5e78882a /Source/Android/src/org
parent78a4dbced862aa45ec817b6e6be1b9c745ba57fa (diff)
Revert "{Android] Eliminate need for even using a byte array when copying assets over."
Turns out Android devs decided to opt for one of the most retarded ways of handling assets. Assets with some specific extensions are not compressed (png, jpeg, etc), and anything else is compressed. The AssetManager is so revolutionary, that you actually can't retrieve valid FileChannel descriptors from these compressed files! To add to this revolutionary system, they actually didn't give you a straightforward way of disabling this compression. Now using FileChannels are not possible, and thus we must use the much slower way of copying everything over. Thank you Android devs. Godforbid someone would like to use a non-array based way of copying things that's actually efficient, considering DMA access is possible with FileChannels. This reverts commit 0dd32986b8308e72c64f337217f933f8a74913fe.
Diffstat (limited to 'Source/Android/src/org')
-rw-r--r--Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java35
1 files changed, 19 insertions, 16 deletions
diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java
index 9d4eb6c42f..b06669f8f7 100644
--- a/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java
+++ b/Source/Android/src/org/dolphinemu/dolphinemu/DolphinEmulator.java
@@ -11,12 +11,10 @@ import android.content.Intent;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
-
import org.dolphinemu.dolphinemu.gamelist.GameListActivity;
import org.dolphinemu.dolphinemu.settings.UserPreferences;
import java.io.*;
-import java.nio.channels.FileChannel;
/**
* The main activity of this emulator front-end.
@@ -25,22 +23,16 @@ public final class DolphinEmulator extends Activity
{
private void CopyAsset(String asset, String output)
{
+ InputStream in = null;
+ OutputStream out = null;
+
try
{
- // Get input file channel.
- FileInputStream inStream = getAssets().openFd(asset).createInputStream();
- FileChannel in = inStream.getChannel();
-
- // Get output file channel.
- FileOutputStream outStream = new FileOutputStream(output);
- FileChannel out = outStream.getChannel();
-
- // Copy over
- in.transferTo(0, in.size(), out);
-
- // Clean-up
- inStream.close();
- outStream.close();
+ in = getAssets().open(asset);
+ out = new FileOutputStream(output);
+ copyFile(in, out);
+ in.close();
+ out.close();
}
catch (IOException e)
{
@@ -48,6 +40,17 @@ public final class DolphinEmulator extends Activity
}
}
+ private void copyFile(InputStream in, OutputStream out) throws IOException
+ {
+ byte[] buffer = new byte[1024];
+ int read;
+
+ while ((read = in.read(buffer)) != -1)
+ {
+ out.write(buffer, 0, read);
+ }
+ }
+
@Override
public void onCreate(Bundle savedInstanceState)
{