Пример #1
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());
      }
    }
  }
Пример #2
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());
      }
    }
  }
Пример #3
0
  protected void startRec() {
    if (_mic != null && _mic.getState() == AudioRecord.STATE_INITIALIZED) {
      Log.debug(this.getClass().getSimpleName() + ".startRec(): starting mic");
      _mic.startRecording();
      resetTimestampRecStart();
      _countFrames = 0;

      Log.debug(
          this.getClass().getSimpleName()
              + ".startRec(): state="
              + _mic.getState()
              + ", recordingState="
              + _mic.getRecordingState());

      if (_me == null) {
        _me = new Thread(this, "mic");
        // _me.setPriority(Thread.NORM_PRIORITY);
        _me.start();
        Log.debug(this.getClass().getSimpleName() + ".startRec(): micThread started ");
      }
    } else {
      Log.error(this.getClass().getSimpleName() + ".startRec(): Failed to initialise microphone.");
    }
  }