Exemple #1
0
  public void run() {
    // android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
    // _mic.startRecording();
    long then = getTime();
    long ftime = _audio.getFrameInterval();
    while (_me != null) {

      readMic();
      long now = getTime();
      long nexpected = (ftime * _countFrames) + then;
      long nap = (nexpected - now);
      if (_countFrames % 50 == 0) Log.debug("would sleep " + nap);
      nap = 1;
      try {
        Thread.sleep(nap);
      } catch (InterruptedException ex) {
        Log.verb(
            this.getClass().getSimpleName() + ".run(): InterruptedException: " + ex.getMessage());
      }
    }
  }
Exemple #2
0
  protected void stopRec() {
    if ((_mic != null) && (_mic.getState() == AudioRecord.STATE_INITIALIZED)) {
      if (_mic.getRecordingState() != AudioRecord.RECORDSTATE_STOPPED) {
        _mic.stop();
      }
      Log.debug(this.getClass().getSimpleName() + ".stopRec(): mic stopped");
    }

    if (_me != null) {
      Thread tmic = _me;
      _me = null;
      try {
        tmic.join(1000);
        Log.debug(this.getClass().getSimpleName() + ".stopRec(): micThread stoppped");
      } catch (InterruptedException ex) {
        Log.debug(
            this.getClass().getSimpleName()
                + ".stopRec(): InterruptedException: "
                + ex.getMessage());
      }
    }
  }