Exemple #1
0
				FOREACH(Ptr<DelayItem>, item, executableDelayItems)
				{
					if(item->executeInMainThread)
					{
						item->proc();
						item->status=INativeDelay::Executed;
					}
					else
					{
						InvokeAsync([=]()
						{
							item->proc();
							item->status=INativeDelay::Executed;
						});
					}
				}
Exemple #2
0
RefPtr<ReaderProxy::AudioDataPromise>
ReaderProxy::RequestAudioData()
{
  MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
  MOZ_ASSERT(!mShutdown);

  mSeamlessLoopingBlocked = false;
  return InvokeAsync(mReader->OwnerThread(),
                     mReader.get(),
                     __func__,
                     &MediaFormatReader::RequestAudioData)
    ->Then(mOwnerThread,
           __func__,
           this,
           &ReaderProxy::OnAudioDataRequestCompleted,
           &ReaderProxy::OnAudioDataRequestFailed);
}
RefPtr<ShutdownPromise>
MediaDecoderReaderWrapper::Shutdown()
{
  MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
  MOZ_ASSERT(!mRequestAudioDataCB);
  MOZ_ASSERT(!mRequestVideoDataCB);
  MOZ_ASSERT(!mAudioDataRequest.Exists());
  MOZ_ASSERT(!mVideoDataRequest.Exists());

  mShutdown = true;
  if (mStartTimeRendezvous) {
    mStartTimeRendezvous->Destroy();
    mStartTimeRendezvous = nullptr;
  }
  return InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                     &MediaDecoderReader::Shutdown);
}
Exemple #4
0
int RilRequest::Request(uint32_t id, const void *data, int len)
{
	int ret = 0;

	ILOG_TRACE(MGUI_RILREQ);
	ret = rilutil_makeRequestBlob(&_b, id, data, len);
	if (ret) {
		ILOG_ERROR(MGUI_RILREQ, "rilutil_makeRequestBlob failed (ret=%d)\n", ret);
		return ret;
	}
	ret = InvokeAsync(RIL_UBUS_REQ, _b.head);
	if (ret) {
		ILOG_ERROR(MGUI_RILREQ, "Invoke() failed (ret=%d)\n", ret);
		return ret;
	}
	ILOG_DEBUG(MGUI_RILREQ, "%s exit\n", __FUNCTION__);

	return ret;
}
void
MediaDecoderReaderWrapper::RequestVideoData(bool aSkipToNextKeyframe,
                                            media::TimeUnit aTimeThreshold)
{
  MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
  MOZ_ASSERT(!mShutdown);
  MOZ_ASSERT(mRequestVideoDataCB, "Request video data without callback!");

  // Time the video decode and send this value back to callbacks who accept
  // a TimeStamp as its second parameter.
  TimeStamp videoDecodeStartTime = TimeStamp::Now();

  if (aTimeThreshold.ToMicroseconds() > 0 &&
      mStartTimeRendezvous->HaveStartTime()) {
    aTimeThreshold += StartTime();
  }

  auto p = InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                       &MediaDecoderReader::RequestVideoData,
                       aSkipToNextKeyframe, aTimeThreshold.ToMicroseconds());

  if (!mStartTimeRendezvous->HaveStartTime()) {
    p = p->Then(mOwnerThread, __func__, mStartTimeRendezvous.get(),
                &StartTimeRendezvous::ProcessFirstSample<MediaData::VIDEO_DATA>,
                &StartTimeRendezvous::FirstSampleRejected<MediaData::VIDEO_DATA>)
         ->CompletionPromise();
  }

  RefPtr<MediaDecoderReaderWrapper> self = this;
  mVideoDataRequest.Begin(p->Then(mOwnerThread, __func__,
    [self, videoDecodeStartTime] (MediaData* aVideoSample) {
      MOZ_ASSERT(self->mRequestVideoDataCB);
      self->mVideoDataRequest.Complete();
      self->OnSampleDecoded(self->mRequestVideoDataCB.get(), aVideoSample, videoDecodeStartTime);
    },
    [self] (MediaDecoderReader::NotDecodedReason aReason) {
      MOZ_ASSERT(self->mRequestVideoDataCB);
      self->mVideoDataRequest.Complete();
      self->OnNotDecoded(self->mRequestVideoDataCB.get(), aReason);
    }));
}
void
MediaDecoderReaderWrapper::WaitForData(MediaData::Type aType)
{
  MOZ_ASSERT(mOwnerThread->IsCurrentThreadIn());
  MOZ_ASSERT(WaitCallbackRef(aType));

  auto p = InvokeAsync(mReader->OwnerThread(), mReader.get(), __func__,
                       &MediaDecoderReader::WaitForData, aType);

  RefPtr<MediaDecoderReaderWrapper> self = this;
  WaitRequestRef(aType).Begin(p->Then(mOwnerThread, __func__,
    [self] (MediaData::Type aType) {
      MOZ_ASSERT(self->WaitCallbackRef(aType));
      self->WaitRequestRef(aType).Complete();
      self->WaitCallbackRef(aType)->OnResolved(aType);
    },
    [self, aType] (WaitForDataRejectValue aRejection) {
      MOZ_ASSERT(self->WaitCallbackRef(aType));
      self->WaitRequestRef(aType).Complete();
      self->WaitCallbackRef(aType)->OnRejected(aRejection);
    }));
}
void
ChannelMediaDecoder::DownloadProgressed()
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());

  GetOwner()->DownloadProgressed();

  using StatsPromise = MozPromise<MediaStatistics, bool, true>;
  InvokeAsync(GetStateMachine()->OwnerThread(),
              __func__,
              [
                playbackStats = mPlaybackStatistics,
                res = RefPtr<BaseMediaResource>(mResource),
                duration = mDuration,
                pos = mPlaybackPosition
              ]() {
                auto rate = ComputePlaybackRate(playbackStats, res, duration);
                UpdatePlaybackRate(rate, res);
                MediaStatistics stats = GetStatistics(rate, res, pos);
                return StatsPromise::CreateAndResolve(stats, __func__);
              })
    ->Then(
      mAbstractMainThread,
      __func__,
      [ =, self = RefPtr<ChannelMediaDecoder>(this) ](MediaStatistics aStats) {
        if (IsShutdown()) {
          return;
        }
        mCanPlayThrough = aStats.CanPlayThrough();
        GetStateMachine()->DispatchCanPlayThrough(mCanPlayThrough);
        mResource->ThrottleReadahead(ShouldThrottleDownload(aStats));
        // Update readyState since mCanPlayThrough might have changed.
        GetOwner()->UpdateReadyState();
      },
      []() { MOZ_ASSERT_UNREACHABLE("Promise not resolved"); });
}
Exemple #8
0
int StatsRequest::Request()
{
	return InvokeAsync(STATISTICS_UBUS_REQUEST, NULL);
}
Exemple #9
0
RefPtr<MediaDataDecoder::FlushPromise> VPXDecoder::Flush() {
  return InvokeAsync(mTaskQueue, __func__, []() {
    return FlushPromise::CreateAndResolve(true, __func__);
  });
}
Exemple #10
0
RefPtr<MediaDataDecoder::FlushPromise>
AppleATDecoder::Flush()
{
  LOG("Flushing AudioToolbox AAC decoder");
  return InvokeAsync(mTaskQueue, this, __func__, &AppleATDecoder::ProcessFlush);
}
Exemple #11
0
int ChargerRequest::Request()
{
	return InvokeAsync(CHARGER_UBUS_REQUEST, NULL);
}