Ejemplo n.º 1
0
  @Override
  public void onServiceConnected(ComponentName name, IBinder service) {
    mService = IPlayerService.Stub.asInterface(service);
    if (bound) {
      Log.d(TAG, "Service Connected");
    } else {
      Log.d(TAG, "Service Connected, but was unbound in the meantime");
      return;
    }

    try {
      mService.registerCallback(mCallback, 0);
    } catch (RemoteException e) {
      throw new RuntimeException(e);
    }

    for (Opt o : options) {
      setOption(o.opt, o.arg);
    }
    options.clear();

    if (modToPlay != null) {
      playMod(modToPlay);
      modToPlay = null;
    }
  }
Ejemplo n.º 2
0
  @Override
  public void setOption(String opt, Object val) {
    final int k, v;
    if (opt.equals("active")) {
      isActive = (Boolean) val;
      Log.d(TAG, ">>>>>>>>>> VICEPLUGIN IS " + (isActive ? "ACTIVE" : "NOT ACTIVE"));
      return;
    } else if (opt.equals("filter")) {
      k = OPT_FILTER;
      v = (Boolean) val ? 1 : 0;
    } else if (opt.equals("ntsc")) {
      k = OPT_NTSC;
      v = (Integer) val;
    } else if (opt.equals("resampling")) {
      k = OPT_RESAMPLING;
      v = (Integer) val;
    } else if (opt.equals("filter_bias")) {
      k = OPT_FILTER_BIAS;
      v = (Integer) val;
    } else if (opt.equals("sid_model")) {
      k = OPT_SID_MODEL;
      v = (Integer) val;
    } else {
      return;
    }

    if (!libraryLoaded) {
      optMap.put(k, v);
    } else {
      N_setOption(k, v);
    }
  }
Ejemplo n.º 3
0
 public void bindService(Context ctx, Handler h) {
   handler = h;
   Log.d(TAG, "binding");
   Intent i = new Intent(ctx, PlayerService.class);
   bound = true;
   ctx.startService(i);
   ctx.bindService(i, this, Context.BIND_AUTO_CREATE);
 }
Ejemplo n.º 4
0
 @Override
 public void onServiceDisconnected(ComponentName name) {
   Log.d(TAG, "Service Disconnected!");
   if (handler != null) {
     Message msg = handler.obtainMessage(999);
     handler.sendMessage(msg);
   }
 }
Ejemplo n.º 5
0
 public void unbindService(Context ctx) {
   Log.d(TAG, "Unbinding");
   handler = null;
   bound = false;
   if (mService != null) {
     try {
       mService.unRegisterCallback(mCallback);
     } catch (RemoteException e) {
       // throw new RuntimeException(e);
     }
   }
   ctx.unbindService(this);
 }
Ejemplo n.º 6
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;
  }