예제 #1
0
  public VICEPlugin() {
    if (!initialized) {
      /* Store basic, kernal & chargen for C++ code to find. */
      dataDir = new File(Environment.getExternalStorageDirectory(), "droidsound");
      if (!dataDir.exists()) {
        dataDir.mkdir();
      }

      File viceDir = new File(dataDir, "VICE");
      synchronized (lock) {
        if (!viceDir.exists()) {
          unzipper = Unzipper.getInstance();
          unzipper.unzipAssetAsync(getContext(), "vice.zip", dataDir);
        }
      }
      initialized = true;
    }
  }
예제 #2
0
  @Override
  public boolean load(FileSource fs) {

    // currentTune = 0;

    if (!libraryLoaded) {
      System.loadLibrary("vice");

      if (unzipper != null) {
        while (!unzipper.checkJob("vice.zip")) {
          try {
            Thread.sleep(500);
          } catch (InterruptedException e) {
            e.printStackTrace();
            return false;
          }
        }
        unzipper = null;
      }

      N_setDataDir(new File(dataDir, "VICE").getAbsolutePath());

      for (Entry<Integer, Integer> e : optMap.entrySet()) {
        N_setOption(e.getKey(), e.getValue());
      }
      optMap.clear();
      libraryLoaded = true;
    }

    final String error;
    // try {
    // File file = File.createTempFile("tmp-XXXXX", "sid");
    // FileOutputStream fo = new FileOutputStream(file);
    // fo.write(fs.getContents());
    // fo.close();
    error = N_loadFile(fs.getFile().getAbsolutePath());
    // file.delete();
    // }
    // catch (IOException ie) {
    //	throw new RuntimeException(ie);
    // }

    if (error != null) {
      Log.i(TAG, "Native code error: " + error);
      return false;
    }

    fs.close();

    return true;
  }