nsRefPtr<ShutdownPromise>
MediaDecoderReader::Shutdown()
{
  MOZ_ASSERT(OnDecodeThread());
  mShutdown = true;

  mBaseAudioPromise.RejectIfExists(END_OF_STREAM, __func__);
  mBaseVideoPromise.RejectIfExists(END_OF_STREAM, __func__);

  ReleaseMediaResources();
  nsRefPtr<ShutdownPromise> p;

  // Spin down the task queue if necessary. We wait until BreakCycles to null
  // out mTaskQueue, since otherwise any remaining tasks could crash when they
  // invoke GetTaskQueue()->IsCurrentThreadIn().
  if (mTaskQueue && !mTaskQueueIsBorrowed) {
    // If we own our task queue, shutdown ends when the task queue is done.
    p = mTaskQueue->BeginShutdown();
  } else {
    // If we don't own our task queue, we resolve immediately (though
    // asynchronously).
    p = ShutdownPromise::CreateAndResolve(true, __func__);
  }

  mDecoder = nullptr;

  return p;
}
Exemplo n.º 2
0
void
MediaDecoderReader::Shutdown()
{
  MOZ_ASSERT(OnDecodeThread());
  mShutdown = true;
  ReleaseMediaResources();
  if (mTaskQueue && !mTaskQueueIsBorrowed) {
    // We may be running in the task queue ourselves, so we don't block this
    // thread on task queue draining, since that would deadlock.
    mTaskQueue->BeginShutdown();
  }
  mTaskQueue = nullptr;
}
Exemplo n.º 3
0
nsresult
DASHRepDecoder::PopulateByteRanges()
{
  NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");

  // Should not be called during shutdown.
  NS_ENSURE_FALSE(mShuttingDown, NS_ERROR_UNEXPECTED);

  ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
  if (!mByteRanges.IsEmpty()) {
    return NS_OK;
  }
  NS_ENSURE_TRUE(mReader, NS_ERROR_NULL_POINTER);
  LOG1("Populating byte range array.");
  return mReader->GetSubsegmentByteRanges(mByteRanges);
}
Exemplo n.º 4
0
void
DASHRepDecoder::OnReadMetadataCompleted()
{
  NS_ASSERTION(OnDecodeThread(), "Should be on decode thread.");

  // If shutting down, just return silently.
  if (mShuttingDown) {
    LOG1("Shutting down! Ignoring OnReadMetadataCompleted().");
    return;
  }

  LOG1("Metadata has been read.");

  // Metadata loaded and read for this stream; ok to populate byte ranges.
  nsresult rv = PopulateByteRanges();
  if (NS_FAILED(rv) || mByteRanges.IsEmpty()) {
    LOG("Error populating byte ranges [%x]", rv);
    DecodeError();
    return;
  }

  mMainDecoder->OnReadMetadataCompleted(this);
}