Ejemplo n.º 1
0
  public void setPushToTalk(final boolean state) {
    if (mProtocol == null || mProtocol.currentUser == null) return;

    Assert.assertTrue(
        "Push to talk not on, but setPushToTalk called!", !settings.isVoiceActivity());

    if (state) {
      mAudioHost.setTalkState(getCurrentUser(), AudioOutputHost.STATE_TALKING);
      mAudioInput.startRecording();
    } else {
      mAudioHost.setTalkState(getCurrentUser(), AudioOutputHost.STATE_PASSIVE);
      mAudioInput.stopRecording();
    }
  }
Ejemplo n.º 2
0
  void updateConnectionState() {
    final int oldState = serviceState;

    switch (state) {
      case MumbleConnectionHost.STATE_CONNECTING:
        serviceState = CONNECTION_STATE_CONNECTING;
        break;
      case MumbleConnectionHost.STATE_CONNECTED:
        settings.addObserver(this);
        serviceState = synced ? CONNECTION_STATE_CONNECTED : CONNECTION_STATE_SYNCHRONIZING;
        if (settings.isDeafened()) {
          setDeafened(true);
        } else if (settings.isMuted()) {
          setMuted(true);
        }
        updateFavourites();
        if (synced) {
          // Initialize audio input
          mAudioInput = new AudioInput(this, mProtocol.codec);
          if (settings.isVoiceActivity())
            mAudioInput.startRecording(); // Immediately begin record if using voice activity

          showNotification();
        }
        break;
      case MumbleConnectionHost.STATE_DISCONNECTED:
        settings.deleteObserver(this);
        serviceState = CONNECTION_STATE_DISCONNECTED;
        if (mAudioInput != null) {
          try {
            mAudioInput.stopRecordingAndBlock();
          } catch (InterruptedException e) {
            e.printStackTrace();
          } finally {
            mAudioInput.terminate();
            mAudioInput = null;
          }
        }
        hideNotification();
        break;
      default:
        Assert.fail();
    }

    if (oldState != serviceState) {
      broadcastState();
    }
  }
Ejemplo n.º 3
0
  // Settings observer
  @Override
  public void update(Observable observable, Object data) {
    Settings settings = (Settings) observable;

    if (data.equals(Settings.OBSERVER_KEY_ALL)) {
      // Create PTT overlay
      dismissPTTOverlay();
      if (settings.isPushToTalk()
          && !settings.getHotCorner().equals(Settings.ARRAY_HOT_CORNER_NONE)) {
        createPTTOverlay();
      }

      // Handle voice activity
      try {
        mAudioInput
            .stopRecordingAndBlock(); // We block because we want to wait before restarting
                                      // recording to avoid a concurrent modificatione exception.
      } catch (InterruptedException e) {
        e.printStackTrace();
      } finally {
        if (settings.isVoiceActivity()) mAudioInput.startRecording();
      }
    }
  }