Example #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();
    }
  }
Example #2
0
 public void setDeafened(final boolean state) {
   if (mAudioHost != null && mProtocol != null && mProtocol.currentUser != null) {
     mAudioHost.setSelfDeafened(mProtocol.currentUser, state);
     settings.setMutedAndDeafened(state, state);
   }
 }
Example #3
0
  private void doConnectionDisconnect() {
    // First disable all hosts to prevent old callbacks from being
    // processed.
    if (mProtocolHost != null) {
      mProtocolHost.disable();
      mProtocolHost = null;
    }

    if (mConnectionHost != null) {
      mConnectionHost.disable();
      mConnectionHost = null;
    }

    if (mAudioHost != null) {
      mAudioHost.disable();
      mAudioHost = null;
    }

    // Stop threads.
    if (mProtocol != null) {
      mProtocol.stop();
      mProtocol = null;
    }

    if (mClient != null && mClientThread != null) {
      new Thread(
              new Runnable() {
                @Override
                public void run() {
                  mClient.disconnect();
                }
              })
          .start();

      try {
        mClientThread.join();
      } catch (final InterruptedException e) {
        mClientThread.interrupt();
      }

      // Leave mClient reference intact as its state might still be
      // queried.
      mClientThread = null;
    }

    // Broadcast state, this is synchronous with observers.
    state = MumbleConnectionHost.STATE_DISCONNECTED;
    updateConnectionState();

    // Now observers shouldn't need these anymore.
    chatMessages.clear();
    unreadChatMessages.clear();
    users.clear();
    messages.clear();
    channels.clear();

    // Stop wakelock
    if (wakeLock.isHeld()) {
      wakeLock.release();
    }

    if (tts != null) {
      tts.stop();
      tts.shutdown();
    }

    stopSelf();
  }