Example #1
0
void
AudioStream::Start()
{
  MonitorAutoLock mon(mMonitor);
  MOZ_ASSERT(mState == INITIALIZED);
  auto r = InvokeCubeb(cubeb_stream_start);
  mState = r == CUBEB_OK ? STARTED : ERRORED;
  LOG("started, state %s", mState == STARTED ? "STARTED" : "ERRORED");
}
Example #2
0
void
AudioStream::Start()
{
  MonitorAutoLock mon(mMonitor);
  MOZ_ASSERT(mState == INITIALIZED);
  mState = STARTED;
  auto r = InvokeCubeb(cubeb_stream_start);
  if (r != CUBEB_OK) {
    mState = ERRORED;
  }
  LOG("started, state %s", mState == STARTED ? "STARTED" : mState == DRAINED ? "DRAINED" : "ERRORED");
}
Example #3
0
void
AudioStream::ResetDefaultDevice()
{
  MonitorAutoLock mon(mMonitor);
  if (mState != STARTED && mState != STOPPED) {
    return;
  }

  MOZ_ASSERT(mCubebStream);
  auto r = InvokeCubeb(cubeb_stream_reset_default_device);
  if (!(r == CUBEB_OK || r == CUBEB_ERROR_NOT_SUPPORTED)) {
    mState = ERRORED;
  }
}
Example #4
0
int64_t
AudioStream::GetPositionInFramesUnlocked()
{
  mMonitor.AssertCurrentThreadOwns();

  if (mState == ERRORED) {
    return -1;
  }

  uint64_t position = 0;
  if (InvokeCubeb(cubeb_stream_get_position, &position) != CUBEB_OK) {
    return -1;
  }
  return std::min<uint64_t>(position, INT64_MAX);
}
Example #5
0
nsresult
AudioStream::Start()
{
  MonitorAutoLock mon(mMonitor);
  MOZ_ASSERT(mState == INITIALIZED);
  mState = STARTED;
  auto r = InvokeCubeb(cubeb_stream_start);
  if (r != CUBEB_OK) {
    mState = ERRORED;
  }
  LOG("started, state %s", mState == STARTED ? "STARTED" : mState == DRAINED ? "DRAINED" : "ERRORED");
  if (mState == STARTED || mState == DRAINED) {
    return NS_OK;
  }
  return NS_ERROR_FAILURE;
}
Example #6
0
void
AudioStream::Resume()
{
  MonitorAutoLock mon(mMonitor);
  MOZ_ASSERT(mState != INITIALIZED, "Must be Start()ed.");
  MOZ_ASSERT(mState != STARTED, "Already Start()ed.");
  MOZ_ASSERT(mState != SHUTDOWN, "Already Shutdown()ed.");

  // Do nothing if we are already drained or errored.
  if (mState == DRAINED || mState == ERRORED) {
    return;
  }

  if (InvokeCubeb(cubeb_stream_start) != CUBEB_OK) {
    mState = ERRORED;
  } else if (mState != DRAINED && mState != ERRORED) {
    // Don't transition to other states if we are already
    // drained or errored.
    mState = STARTED;
  }
}