コード例 #1
0
nsresult
ChannelMediaDecoder::Load(nsIChannel* aChannel,
                          bool aIsPrivateBrowsing,
                          nsIStreamListener** aStreamListener)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(!mResource);
  MOZ_ASSERT(aStreamListener);
  AbstractThread::AutoEnter context(AbstractMainThread());

  mResource =
    BaseMediaResource::Create(mResourceCallback, aChannel, aIsPrivateBrowsing);
  if (!mResource) {
    return NS_ERROR_FAILURE;
  }
  DDLINKCHILD("resource", mResource.get());

  nsresult rv = MediaShutdownManager::Instance().Register(this);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return rv;
  }

  rv = mResource->Open(aStreamListener);
  NS_ENSURE_SUCCESS(rv, rv);

  SetStateMachine(CreateStateMachine());
  NS_ENSURE_TRUE(GetStateMachine(), NS_ERROR_FAILURE);

  GetStateMachine()->DispatchIsLiveStream(mResource->IsLiveStream());

  return InitializeStateMachine();
}
コード例 #2
0
bool
MediaOmxCommonDecoder::CheckDecoderCanOffloadAudio()
{
  return (mCanOffloadAudio && !mFallbackToStateMachine &&
          !(GetStateMachine() && GetStateMachine()->GetDecodedStream()) &&
          mPlaybackRate == 1.0);
}
コード例 #3
0
void
MediaOmxCommonDecoder::ResumeStateMachine()
{
  MOZ_ASSERT(NS_IsMainThread());
  DECODER_LOG(LogLevel::Debug, ("%s current time %f", __PRETTY_FUNCTION__, mLogicalPosition));

  if (mShuttingDown) {
    return;
  }

  if (!GetStateMachine()) {
    return;
  }

  GetStateMachine()->DispatchAudioOffloading(false);

  mFallbackToStateMachine = true;
  mAudioOffloadPlayer = nullptr;
  SeekTarget target = SeekTarget(mLogicalPosition,
                                 SeekTarget::Accurate,
                                 MediaDecoderEventVisibility::Suppressed);
  // Call Seek of MediaDecoderStateMachine to suppress seek events.
  GetStateMachine()->InvokeSeek(target);

  mNextState = mPlayState;
  ChangeState(PLAY_STATE_LOADING);
  // exit dormant state
  GetStateMachine()->DispatchSetDormant(false);
  UpdateLogicalPosition();
}
コード例 #4
0
nsresult
ChannelMediaDecoder::Load(BaseMediaResource* aOriginal)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(!mResource);
  AbstractThread::AutoEnter context(AbstractMainThread());

  mResource = aOriginal->CloneData(mResourceCallback);
  if (!mResource) {
    return NS_ERROR_FAILURE;
  }
  DDLINKCHILD("resource", mResource.get());

  nsresult rv = MediaShutdownManager::Instance().Register(this);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return rv;
  }

  SetStateMachine(CreateStateMachine());
  NS_ENSURE_TRUE(GetStateMachine(), NS_ERROR_FAILURE);

  GetStateMachine()->DispatchIsLiveStream(mResource->IsLiveStream());

  return InitializeStateMachine();
}
コード例 #5
0
void
MediaOmxCommonDecoder::PauseStateMachine()
{
  MOZ_ASSERT(NS_IsMainThread());
  DECODER_LOG(LogLevel::Debug, ("%s", __PRETTY_FUNCTION__));

  MOZ_ASSERT(GetStateMachine());
  // enter dormant state
  GetStateMachine()->DispatchSetDormant(true);
}
コード例 #6
0
ファイル: Player.cpp プロジェクト: WiZFramework/DxBase2016
	void Player::OnCollision(const shared_ptr<GameObject>& other){
		//ヒットした相手が振り分け用のインターフェイスを保持してるか確認
		auto IAssign = dynamic_pointer_cast<AssignInterface>(other);
		if (IAssign){
			//インターフェイスを保持してた
			//処理を振り分ける
			IAssign->AssignAction(GetThis<Player>());
		}
		if (GetStateMachine()->GetCurrentState() == JumpState::Instance()){
			GetStateMachine()->ChangeState(DefaultState::Instance());
		}
	}
コード例 #7
0
ファイル: Player.cpp プロジェクト: WiZFramework/BaseCross
	//Aボタン
	void  Player::OnPushA() {
		if (GetStateMachine()->GetTopState() == PlayerDefaultState::Instance() ||
			GetStateMachine()->GetTopState() == PlayerOnMoveboxState::Instance()) {
			switch (m_PlayerAction) {
			case PlayerAction::Jump:
				GetStateMachine()->Push(PlayerJumpState::Instance());
				break;
			case PlayerAction::Attack:
				GetStateMachine()->Push(PlayerAttackState::Instance());
				break;
			}
		}
	}
コード例 #8
0
ファイル: Player.cpp プロジェクト: WiZFramework/BaseCross
	void Player::OnCollision(vector<shared_ptr<GameObject>>& OtherVec) {

		auto PtrBehavior = GetBehavior<PlayerBehavior>();
		shared_ptr<GameObject> v;
		if (PtrBehavior->OnHitObjMoveBox(OtherVec, v)) {
			GetStateMachine()->Reset(PlayerOnMoveboxState::Instance());
			GetComponent<Transform>()->SetParent(v);
			return;
		}

		if (GetStateMachine()->GetTopState() == PlayerJumpState::Instance()) {
			//現在がジャンプステートか移動ボックスステートならPlayerDefaultにリセット
			GetStateMachine()->Reset(PlayerDefaultState::Instance());
		}
	}
コード例 #9
0
ファイル: Player.cpp プロジェクト: WiZFramework/DxBase2015
	void Player::Update2(){
		auto ColPtr = GetComponent<CollisionSphere>();
		if (ColPtr->GetHitObject() && GetStateMachine()->GetCurrentState() == JumpState::Instance()){
			GetStateMachine()->ChangeState(DefaultState::Instance());
		}

		auto fps = App::GetApp()->GetStepTimer().GetFramesPerSecond();
		wstring FPS(L"FPS: ");
		FPS += Util::UintToWStr(fps);

		wstring str = FPS;
		//文字列をつける
		auto PtrString = GetComponent<StringSprite>();
		PtrString->SetText(str);
	}
コード例 #10
0
bool
ChannelMediaDecoder::CanPlayThroughImpl()
{
  MOZ_ASSERT(NS_IsMainThread());
  NS_ENSURE_TRUE(GetStateMachine(), false);
  return GetStatistics().CanPlayThrough();
}
コード例 #11
0
nsresult
ChannelMediaDecoder::Load(nsIChannel* aChannel,
                          bool aIsPrivateBrowsing,
                          nsIStreamListener** aStreamListener)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_ASSERT(!mResource);

  mResource =
    BaseMediaResource::Create(mResourceCallback, aChannel, aIsPrivateBrowsing);
  if (!mResource) {
    return NS_ERROR_FAILURE;
  }

  nsresult rv = MediaShutdownManager::Instance().Register(this);
  if (NS_WARN_IF(NS_FAILED(rv))) {
    return rv;
  }

  rv = OpenResource(aStreamListener);
  NS_ENSURE_SUCCESS(rv, rv);

  SetStateMachine(CreateStateMachine());
  NS_ENSURE_TRUE(GetStateMachine(), NS_ERROR_FAILURE);

  return InitializeStateMachine();
}
コード例 #12
0
ファイル: QHState.cpp プロジェクト: klhurley/ElementalEngine2
///	\brief	register state in parent object and state machine
void CQHState::RegisterState()
{
	if( m_Name.IsEmpty() )
	{
		return;
	}

	IHashString *parentName = GetParentName();
	CQHStateMachineManager *amanager = GetManager();

	// Parent is either a state or state machine
	CQHState *parentState = amanager->GetState( parentName );
	if( parentState != NULL )
	{
		parentState->AddChildState( this );
		GetStateMachine()->AddGlobalState( this );
	}
	else
	{
		CQHStateMachine *parentStateMachine = amanager->GetStateMachine( parentName );
		if( parentStateMachine != NULL )
		{
			parentStateMachine->AddBaseState( this );
			parentStateMachine->AddGlobalState( this );
		}
		else
		{
			m_ToolBox->Log( LOGERROR, _T("Could not find parent object %s for state %s."), parentName->GetString(), GetName()->GetString() );
		}
	}
}
コード例 #13
0
bool
ChannelMediaDecoder::ShouldThrottleDownload(const MediaStatistics& aStats)
{
  // We throttle the download if either the throttle override pref is set
  // (so that we can always throttle in Firefox on mobile) or if the download
  // is fast enough that there's no concern about playback being interrupted.
  MOZ_ASSERT(NS_IsMainThread());
  NS_ENSURE_TRUE(GetStateMachine(), false);

  int64_t length = aStats.mTotalBytes;
  if (length > 0 &&
      length <= int64_t(StaticPrefs::MediaMemoryCacheMaxSize()) * 1024) {
    // Don't throttle the download of small resources. This is to speed
    // up seeking, as seeks into unbuffered ranges would require starting
    // up a new HTTP transaction, which adds latency.
    return false;
  }

  if (Preferences::GetBool("media.throttle-regardless-of-download-rate",
                           false)) {
    return true;
  }

  if (!aStats.mDownloadRateReliable || !aStats.mPlaybackRateReliable) {
    return false;
  }
  uint32_t factor =
    std::max(2u, Preferences::GetUint("media.throttle-factor", 2));
  return aStats.mDownloadRate > factor * aStats.mPlaybackRate;
}
コード例 #14
0
DWORD CQHStateMachineManager::OnQueryStateMachineEvents( DWORD size, void* params )
{
	VERIFY_MESSAGE_SIZE(sizeof(QUERYEVENTSPARAMS), size);
	QUERYEVENTSPARAMS *queryEventsParams = (QUERYEVENTSPARAMS*)params;

	if( queryEventsParams->StateMachineName == NULL )
	{
		m_ToolBox->Log( LOGWARNING, _T("Cannot query events. No state machine specified.\n") );
	}
	else
	{

		CQHStateMachine *stateMachine = GetStateMachine( queryEventsParams->StateMachineName );
		if( stateMachine == NULL )
		{
			m_ToolBox->Log( LOGWARNING, _T("Cannot query events. Specified state machine %s cannot be found.\n"), queryEventsParams->StateMachineName->GetString() );
		}
		else
		{
			stateMachine->QueryEvents( &queryEventsParams->QueryEventsList );
		}
	}

	return MSG_HANDLED_STOP;
}
コード例 #15
0
nsresult
MediaSourceDecoder::Load(nsIStreamListener**, MediaDecoder*)
{
  MOZ_ASSERT(!GetStateMachine());
  SetStateMachine(CreateStateMachine());
  if (!GetStateMachine()) {
    NS_WARNING("Failed to create state machine!");
    return NS_ERROR_FAILURE;
  }

  nsresult rv = GetStateMachine()->Init(nullptr);
  NS_ENSURE_SUCCESS(rv, rv);

  SetStateMachineParameters();
  return NS_OK;
}
コード例 #16
0
ファイル: QHState.cpp プロジェクト: klhurley/ElementalEngine2
DWORD CQHState::OnGetStateMachineStateLabels( DWORD size, void *params )
{
	GETSETSTATEMACHINENAMESPARAMS *gssmn;
	VERIFY_MESSAGE_SIZE( size, sizeof( *gssmn ) );
	gssmn = reinterpret_cast<GETSETSTATEMACHINENAMESPARAMS *>(params);
	GetStateMachine()->FillStateLabels( gssmn->Names );
	return MSG_HANDLED_STOP;
}
コード例 #17
0
void
MediaOmxCommonDecoder::PauseStateMachine()
{
  MOZ_ASSERT(NS_IsMainThread());
  GetReentrantMonitor().AssertCurrentThreadIn();
  DECODER_LOG(LogLevel::Debug, ("%s", __PRETTY_FUNCTION__));

  if (mShuttingDown) {
    return;
  }

  if (!GetStateMachine()) {
    return;
  }
  // enter dormant state
  GetStateMachine()->DispatchSetDormant(true);
}
コード例 #18
0
ファイル: Character.cpp プロジェクト: WiZFramework/DxBase2015
	void RollingTorus::Update2(){
		//衝突判定を得る
		auto PtrCollision = GetComponent<CollisionSphere>();
		if (PtrCollision->GetHitObject()){
			//当たったらステート変更
			GetStateMachine()->ChangeState(TorusShellHitState::Instance());
		}
	}
コード例 #19
0
int
PlayerStateFastForward::FastReverse(void)
{
    cout << "State:" << GetName()
         << " FastReverse pressed, going to FastReverse state."
         << endl;

    return GetStateMachine()->ChangeState(ePlayerStateFR);
}
コード例 #20
0
ファイル: HeroGinny.cpp プロジェクト: cpylua/Quidditch
void cHeroGinny::Spell()
{
	if( m_SpellInterval == 0 &&
		m_currBlue >= GINNY_SPELL_COST )
	{
		m_SpellInterval = GINNY_SPELL_INTERVAL;
		GetStateMachine()->ChangeState(cSpellingState::Instance());
		m_currBlue -= GINNY_SPELL_COST;
	}
}
コード例 #21
0
ファイル: HeroVoldemort.cpp プロジェクト: cpylua/Quidditch
void cHeroVoldemort::Spell()
{
	if( m_SpellInterval == 0 &&
		m_currBlue >= VOLDEMORT_SPELL_COST )
	{
		m_SpellInterval = VOLDEMORT_SPELL_INTERVAL;
		//g_SoundEffectIndex.push_back(SND_RON_GINNY_SPELLING);
		GetStateMachine()->ChangeState(cSpellingState::Instance());
		m_currBlue -= VOLDEMORT_SPELL_COST;
	}
}
コード例 #22
0
void
MediaOmxCommonDecoder::DisableStateMachineAudioOffloading()
{
  MOZ_ASSERT(NS_IsMainThread());
  if (mCanOffloadAudio) {
    // mCanOffloadAudio is true implies we've called
    // |GetStateMachine()->DispatchAudioOffloading(true)| in
    // SetPlatformCanOffloadAudio(). We need to turn off audio offloading
    // for MDSM so it can start playback.
    GetStateMachine()->DispatchAudioOffloading(false);
  }
}
コード例 #23
0
void
ChannelMediaDecoder::NotifyDownloadEnded(nsresult aStatus)
{
  MOZ_ASSERT(NS_IsMainThread());
  MOZ_DIAGNOSTIC_ASSERT(!IsShutdown());
  AbstractThread::AutoEnter context(AbstractMainThread());

  LOG("NotifyDownloadEnded, status=%" PRIx32, static_cast<uint32_t>(aStatus));

  if (NS_SUCCEEDED(aStatus)) {
    // Download ends successfully. This is a stream with a finite length.
    GetStateMachine()->DispatchIsLiveStream(false);
  }

  MediaDecoderOwner* owner = GetOwner();
  if (NS_SUCCEEDED(aStatus) || aStatus == NS_BASE_STREAM_CLOSED) {
    nsCOMPtr<nsIRunnable> r =
      NS_NewRunnableFunction("ChannelMediaDecoder::UpdatePlaybackRate", [
        stats = mPlaybackStatistics,
        res = RefPtr<BaseMediaResource>(mResource),
        duration = mDuration
      ]() {
        auto rate = ComputePlaybackRate(stats, res, duration);
        UpdatePlaybackRate(rate, res);
      });
    nsresult rv = GetStateMachine()->OwnerThread()->Dispatch(r.forget());
    MOZ_DIAGNOSTIC_ASSERT(NS_SUCCEEDED(rv));
    Unused << rv;
    owner->DownloadSuspended();
    // NotifySuspendedStatusChanged will tell the element that download
    // has been suspended "by the cache", which is true since we never
    // download anything. The element can then transition to HAVE_ENOUGH_DATA.
    owner->NotifySuspendedByCache(true);
  } else if (aStatus == NS_BINDING_ABORTED) {
    // Download has been cancelled by user.
    owner->LoadAborted();
  } else {
    NetworkError(MediaResult(aStatus, "Download aborted"));
  }
}
コード例 #24
0
ファイル: HeroMalfoy.cpp プロジェクト: cpylua/Quidditch
void cHeroMalfoy::Spell()
{
	if( m_SpellInterval == 0 &&
		m_currBlue >= MALFOY_SPELL_COST )
	{
		m_SpellInterval = MALFOY_SPELL_INTERVAL;
		//
		// add sound effect
		//
		GetStateMachine()->ChangeState(cSpellingState::Instance());
		m_currBlue -= MALFOY_SPELL_COST;
	}
}
コード例 #25
0
void
MediaOmxCommonDecoder::ResumeStateMachine()
{
  MOZ_ASSERT(NS_IsMainThread());
  ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
  DECODER_LOG(PR_LOG_DEBUG, ("%s current time %f", __PRETTY_FUNCTION__, mLogicalPosition));

  if (mShuttingDown) {
    return;
  }

  if (!GetStateMachine()) {
    return;
  }

  mFallbackToStateMachine = true;
  mAudioOffloadPlayer = nullptr;
  SeekTarget target = SeekTarget(mLogicalPosition,
                                 SeekTarget::Accurate,
                                 MediaDecoderEventVisibility::Suppressed);
  // Call Seek of MediaDecoderStateMachine to suppress seek events.
  RefPtr<nsRunnable> event =
    NS_NewRunnableMethodWithArg<SeekTarget>(
      GetStateMachine(),
      &MediaDecoderStateMachine::Seek,
      target);
  GetStateMachine()->TaskQueue()->Dispatch(event.forget());

  mNextState = mPlayState;
  ChangeState(PLAY_STATE_LOADING);
  // exit dormant state
  event =
    NS_NewRunnableMethodWithArg<bool>(
      GetStateMachine(),
      &MediaDecoderStateMachine::SetDormant,
      false);
  GetStateMachine()->TaskQueue()->Dispatch(event.forget());
  UpdateLogicalPosition();
}
コード例 #26
0
void
MediaOmxCommonDecoder::PauseStateMachine()
{
  MOZ_ASSERT(NS_IsMainThread());
  GetReentrantMonitor().AssertCurrentThreadIn();
  DECODER_LOG(PR_LOG_DEBUG, ("%s", __PRETTY_FUNCTION__));

  if (mShuttingDown) {
    return;
  }

  if (!GetStateMachine()) {
    return;
  }
  // enter dormant state
  RefPtr<nsRunnable> event =
    NS_NewRunnableMethodWithArg<bool>(
      GetStateMachine(),
      &MediaDecoderStateMachine::SetDormant,
      true);
  GetStateMachine()->TaskQueue()->Dispatch(event.forget());
}
コード例 #27
0
ファイル: NFCAIModule.cpp プロジェクト: MacroGu/NoahGameFrame
void NFCAIModule::OnBeAttack(const NFGUID& self, const NFGUID& other, const int nDamageValue)
{
	m_pHateModule->AddHate(self, other, nDamageValue);
	m_pHateModule->CompSortList(self);

    NFIStateMachine* pStateMachine = GetStateMachine(self);
    if (pStateMachine)
    {
        if (FightState != pStateMachine->CurrentState())
        {
            pStateMachine->ChangeState(FightState);
        }
    }
}
コード例 #28
0
ファイル: QHState.cpp プロジェクト: klhurley/ElementalEngine2
///	\brief	unregister state from parent object and state machine
void CQHState::UnregisterState()
{
	if( m_Name.IsEmpty() )
	{
		return;
	}

	IHashString *parentName = GetParentName();
	CQHStateMachineManager *amanager = GetManager();
	CQHState *parentState = amanager->GetState( parentName );
	if( parentState != NULL )
	{
		parentState->RemoveChildState( this );
		GetStateMachine()->RemoveGlobalState( this );
	}
	else
	{
		CQHStateMachine *parentStateMachine = GetStateMachine();
		assert( parentStateMachine != NULL );
		parentStateMachine->RemoveBaseState( this );
		parentStateMachine->RemoveGlobalState( this );
	}
}
コード例 #29
0
void
MediaSourceDecoder::SetMediaSourceDuration(double aDuration, MSRangeRemovalAction aAction)
{
  ReentrantMonitorAutoEnter mon(GetReentrantMonitor());
  double oldDuration = mMediaSourceDuration;
  if (aDuration >= 0) {
    int64_t checkedDuration;
    if (NS_FAILED(SecondsToUsecs(aDuration, checkedDuration))) {
      // INT64_MAX is used as infinity by the state machine.
      // We want a very bigger number, but not infinity.
      checkedDuration = INT64_MAX - 1;
    }
    GetStateMachine()->SetDuration(checkedDuration);
    mMediaSourceDuration = aDuration;
  } else {
    GetStateMachine()->SetDuration(INT64_MAX);
    mMediaSourceDuration = PositiveInfinity<double>();
  }
  if (mReader) {
    mReader->SetMediaSourceDuration(mMediaSourceDuration);
  }
  ScheduleDurationChange(oldDuration, aDuration, aAction);
}
コード例 #30
0
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"); });
}