Ejemplo n.º 1
0
void
AudioDestinationNode::InputMuted(bool aMuted)
{
  MOZ_ASSERT(Context() && !Context()->IsOffline());

  if (!mAudioChannelAgent) {
    if (aMuted) {
      return;
    }
    CreateAudioChannelAgent();
  }

  if (aMuted) {
    mAudioChannelAgent->NotifyStoppedPlaying();
    return;
  }

  AudioPlaybackConfig config;
  nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&config,
                                                         AudioChannelService::AudibleState::eAudible);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return;
  }

  WindowVolumeChanged(config.mVolume, config.mMuted);
  WindowSuspendChanged(config.mSuspend);
}
Ejemplo n.º 2
0
void
AudioDestinationNode::InputMuted(bool aMuted)
{
  MOZ_ASSERT(Context() && !Context()->IsOffline());

  if (!mAudioChannelAgent) {
    if (aMuted) {
      return;
    }
    CreateAudioChannelAgent();
  }

  if (aMuted) {
    mAudioChannelAgent->NotifyStoppedPlaying();
    return;
  }

  float volume = 0.0;
  bool muted = true;
  nsresult rv = mAudioChannelAgent->NotifyStartedPlaying(&volume, &muted);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return;
  }

  WindowVolumeChanged(volume, muted);
}
Ejemplo n.º 3
0
nsresult
nsSpeechTask::DispatchStartInner()
{
  CreateAudioChannelAgent();

  nsSynthVoiceRegistry::GetInstance()->SetIsSpeaking(true);
  return DispatchStartImpl();
}
Ejemplo n.º 4
0
nsresult
nsSpeechTask::DispatchStartImpl(const nsAString& aUri)
{
    LOG(LogLevel::Debug, ("nsSpeechTask::DispatchStart"));

    MOZ_ASSERT(mUtterance);
    if(NS_WARN_IF(!(mUtterance->mState == SpeechSynthesisUtterance::STATE_PENDING))) {
        return NS_ERROR_NOT_AVAILABLE;
    }

    CreateAudioChannelAgent();

    mUtterance->mState = SpeechSynthesisUtterance::STATE_SPEAKING;
    mUtterance->mChosenVoiceURI = aUri;
    mUtterance->DispatchSpeechSynthesisEvent(NS_LITERAL_STRING("start"), 0, 0,
            EmptyString());

    return NS_OK;
}
void
AudioDestinationNode::SetMozAudioChannelType(AudioChannel aValue, ErrorResult& aRv)
{
    if (Context()->IsOffline()) {
        aRv.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
        return;
    }

    if (aValue != mAudioChannel &&
            CheckAudioChannelPermissions(aValue)) {
        mAudioChannel = aValue;

        if (mStream) {
            mStream->SetAudioChannelType(mAudioChannel);
        }

        if (mAudioChannelAgent) {
            CreateAudioChannelAgent();
        }
    }
}
Ejemplo n.º 6
0
void
AudioDestinationNode::Resume()
{
  CreateAudioChannelAgent();
  SendInt32ParameterToStream(DestinationNodeEngine::SUSPENDED, 0);
}