Ejemplo n.º 1
0
bool V4L2encRecorder::PauseAndWait(int timeout)
{
    QMutexLocker locker(&m_pauseLock);
    if (m_request_pause)
    {
        if (!IsPaused(true))
        {
            LOG(VB_RECORD, LOG_INFO, LOC + "PauseAndWait() -- pause");

            StopEncoding();

            m_paused = true;
            m_pauseWait.wakeAll();

            if (m_tvrec)
                m_tvrec->RecorderPaused();
        }
    }
    else if (IsPaused(true))
    {
        LOG(VB_RECORD, LOG_INFO, LOC + "PauseAndWait() -- unpause");
        StartEncoding();

        if (m_stream_data)
            m_stream_data->Reset(m_stream_data->DesiredProgram());

        m_paused = false;
    }

    // Always wait a little bit, unless woken up
    m_unpauseWait.wait(&m_pauseLock, timeout);

    return IsPaused(true);
}
Ejemplo n.º 2
0
bool IPTVRecorder::PauseAndWait(int timeout)
{
    QMutexLocker locker(&pauseLock);
    if (request_pause)
    {
        if (!IsPaused(true))
        {
            _channel->GetFeeder()->Stop();
            _channel->GetFeeder()->Close();

            paused = true;
            pauseWait.wakeAll();
            if (tvrec)
                tvrec->RecorderPaused();
        }

        unpauseWait.wait(&pauseLock, timeout);
    }

    if (!request_pause && IsPaused(true))
    {
        paused = false;

        if (recording && !_channel->GetFeeder()->IsOpen())
            Open();

        if (_stream_data)
            _stream_data->Reset(_stream_data->DesiredProgram());

        unpauseWait.wakeAll();
    }

    return IsPaused(true);
}
Ejemplo n.º 3
0
// documented in recorderbase.cpp
bool FirewireRecorder::PauseAndWait(int timeout)
{
    QMutexLocker locker(&pauseLock);
    if (request_pause)
    {
        LOG(VB_RECORD, LOG_INFO, LOC +
            QString("PauseAndWait(%1) -- pause").arg(timeout));
        if (!IsPaused(true))
        {
            StopStreaming();
            paused = true;
            pauseWait.wakeAll();
            if (tvrec)
                tvrec->RecorderPaused();
        }
        unpauseWait.wait(&pauseLock, timeout);
    }

    if (!request_pause && IsPaused(true))
    {
        LOG(VB_RECORD, LOG_INFO, LOC +
            QString("PauseAndWait(%1) -- unpause").arg(timeout));
        paused = false;
        StartStreaming();
        unpauseWait.wakeAll();
    }

    return IsPaused(true);
}
Ejemplo n.º 4
0
void byoSnake::OnKeyDown(wxKeyEvent& event)
{
    if ( event.GetKeyCode() == 'p' || event.GetKeyCode() == 'P' )
    {
        SetPause(!IsPaused());
        Refresh();
    }

    if ( IsPaused() ) return;

    if ( event.GetKeyCode() == WXK_LEFT )
    {
        m_Direction = dLeft;
        Move();
    }

    if ( event.GetKeyCode() == WXK_RIGHT )
    {
        m_Direction = dRight;
        Move();
    }

    if ( event.GetKeyCode() == WXK_UP )
    {
        m_Direction = dUp;
        Move();
    }

    if ( event.GetKeyCode() == WXK_DOWN )
    {
        m_Direction = dDown;
        Move();
    }
}
Ejemplo n.º 5
0
bool DVBRecorder::PauseAndWait(int timeout)
{
    QMutexLocker locker(&pauseLock);
    if (request_pause)
    {
        if (!IsPaused(true))
        {
            _stream_handler->RemoveListener(_stream_data);

            paused = true;
            pauseWait.wakeAll();
            if (tvrec)
                tvrec->RecorderPaused();
        }

        unpauseWait.wait(&pauseLock, timeout);
    }

    if (!request_pause && IsPaused(true))
    {
        paused = false;
        _stream_handler->AddListener(_stream_data, false, true);
        unpauseWait.wakeAll();
    }

    return IsPaused(true);
}
Ejemplo n.º 6
0
// documented in recorderbase.cpp
bool FirewireRecorder::PauseAndWait(int timeout)
{
    QMutexLocker locker(&pauseLock);
    if (request_pause)
    {
        VERBOSE(VB_RECORD, LOC + "PauseAndWait("<<timeout<<") -- pause");
        if (!IsPaused(true))
        {
            StopStreaming();
            paused = true;
            pauseWait.wakeAll();
            if (tvrec)
                tvrec->RecorderPaused();
        }
        unpauseWait.wait(&pauseLock, timeout);
    }

    if (!request_pause && IsPaused(true))
    {
        paused = false;
        VERBOSE(VB_RECORD, LOC + "PauseAndWait("<<timeout<<") -- unpause");
        StartStreaming();
        unpauseWait.wakeAll();
    }

    return IsPaused(true);
}
Ejemplo n.º 7
0
bool UPawnAction::Activate()
{
	bool bResult = false; 

	UE_VLOG(GetPawn(), LogPawnAction, Log, TEXT("%s> Activating at priority %s! First start? %s Paused? %s")
		, *GetName()
		, *GetPriorityName()
		, HasBeenStarted() ? TEXT("NO") : TEXT("YES")
		, IsPaused() ? TEXT("YES") : TEXT("NO"));

	if (HasBeenStarted() && IsPaused())
	{
		bResult = Resume();
	}
	else 
	{
		bResult = Start();
		if (bResult == false)
		{
			UE_VLOG(GetPawn(), LogPawnAction, Log, TEXT("%s> Failed to start.")
				, *GetName());
			bFailedToStart = true;
			SetFinishResult(EPawnActionResult::Failed);
			SendEvent(EPawnActionEventType::FailedToStart);
		}
	}

	return bResult;
}
Ejemplo n.º 8
0
void FSoundSource::UpdatePause()
{
	if (IsPaused() && !bIsPausedByGame && !bIsManuallyPaused)
	{
		Play();
	}
	else if (!IsPaused() && (bIsManuallyPaused || bIsPausedByGame))
	{
		Pause();
	}
}
Ejemplo n.º 9
0
void CDownload::StartTrying()
{
	ASSERT( ! IsCompleted() || IsSeeding() );
	ASSERT( ! IsPaused() );
	if ( IsTrying() || IsPaused() || ( IsCompleted() && ! IsSeeding() ) )
		return;

	if ( ! Network.IsConnected() && ! Network.Connect( TRUE ) )
		return;

	m_tBegan = GetTickCount();
}
Ejemplo n.º 10
0
// ----------------------------------------------------------------------------
void CMannequinAGState::Pause( bool pause, EAnimationGraphPauser pauser, float fOverrideTransTime /*= -1.0f */ )
{
	bool bWasPaused = IsPaused();

	if (pause)
		m_pauseState |= (1<<pauser);
	else
		m_pauseState &= ~(1<<pauser);

	if (bWasPaused != IsPaused())
	{
		// TODO: do something here?
	}
}
Ejemplo n.º 11
0
void
nsSMILTimeContainer::SetCurrentTime(nsSMILTime aSeekTo)
{
  // SVG 1.1 doesn't specify what to do for negative times so we adopt SVGT1.2's
  // behaviour of clamping negative times to 0.
  aSeekTo = NS_MAX<nsSMILTime>(0, aSeekTo);

  // The following behaviour is consistent with:
  // http://www.w3.org/2003/01/REC-SVG11-20030114-errata
  //  #getCurrentTime_setCurrentTime_undefined_before_document_timeline_begin
  // which says that if SetCurrentTime is called before the document timeline
  // has begun we should still adjust the offset.
  nsSMILTime parentTime = GetParentTime();
  mParentOffset = parentTime - aSeekTo;
  mIsSeeking = PR_TRUE;

  if (IsPaused()) {
    mNeedsPauseSample = PR_TRUE;
    mPauseStart = parentTime;
  }

  if (aSeekTo < mCurrentTime) {
    // Backwards seek
    mNeedsRewind = PR_TRUE;
    ClearMilestones();
  }

  // Force an update to the current time in case we get a call to GetCurrentTime
  // before another call to Sample().
  UpdateCurrentTime();

  NotifyTimeChange();
}
Ejemplo n.º 12
0
void Emulator::Run()
{
	if (!IsReady())
	{
		Load();
		if(!IsReady()) return;
	}

	if (IsRunning()) Stop();

	if (IsPaused())
	{
		Resume();
		return;
	}

	rpcs3::on_run()();

	SendDbgCommand(DID_START_EMU);

	m_pause_start_time = 0;
	m_pause_amend_time = 0;
	m_status = Running;

	idm::select<ppu_thread, SPUThread, RawSPUThread, ARMv7Thread>([](u32, cpu_thread& cpu)
	{
		cpu.run();
	});

	SendDbgCommand(DID_STARTED_EMU);
}
Ejemplo n.º 13
0
bool PAPlayer::CloseFileInternal(bool bAudioDevice /*= true*/)
{
  if (IsPaused())
    Pause();

  m_bStopPlaying = true;
  m_bStop = true;

  m_visBufferLength = 0;
  StopThread();

  // kill both our streams if we need to
  for (int i = 0; i < 2; i++)
  {
    m_decoder[i].Destroy();
    if (bAudioDevice)
      FreeStream(i);
  }

  m_currentFile->Reset();
  m_nextFile->Reset();

  if(bAudioDevice)
    g_audioContext.SetActiveDevice(CAudioContext::DEFAULT_DEVICE);
  else
    FlushStreams();

  return true;
}
Ejemplo n.º 14
0
void csMovieRecorder::ClockAdvance ()
{
  csTicks lastFakeClockTicks = fakeClockTicks;
  realVirtualClock->Advance();
  csTicks realTicksPerFrame = realVirtualClock->GetElapsedTicks();

  /*
    To avoid 'jumps' in time when the clock is throttled/unthrottled
    we keep our own tick counter, which is either increased by the
    real elapsed time (normal mode) or the required frame time (recording).
   */
  if (!IsRecording() || IsPaused()) {
    fakeClockElapsed = realTicksPerFrame;
    fakeClockTicks += realTicksPerFrame;
  }
  else {
    ffakeClockTicks += fakeTicksPerFrame;
    fakeClockTicks = (csTicks)ffakeClockTicks;

    fakeClockElapsed = fakeClockTicks - 
      lastFakeClockTicks;
    // If we're rendering slower than real time, there's nothing we can do about it.
    // If we're rendering faster, put in a little delay here.
    if (throttle && ((fakeClockElapsed > realTicksPerFrame)))
    {
      csSleep(fakeClockElapsed - realTicksPerFrame);
    }
  } 
}
Ejemplo n.º 15
0
bool csMovieRecorder::EatKey (iEvent& event)
{
  SetupPlugin();
  bool down = csKeyEventHelper::GetEventType (&event) == csKeyEventTypeDown;
  csKeyModifiers m;
  csKeyEventHelper::GetModifiers (&event, m);
  bool alt = m.modifiers[csKeyModifierTypeAlt] != 0;
  bool ctrl = m.modifiers[csKeyModifierTypeCtrl] != 0;
  bool shift = m.modifiers[csKeyModifierTypeShift] != 0;
  utf32_char key = csKeyEventHelper::GetCookedCode (&event);

  if (down && (key == keyRecord.code) && (alt == keyRecord.alt) && 
      (ctrl == keyRecord.ctrl) && (shift == keyRecord.shift)) 
  {
    if (IsRecording())
	Stop();
    else
	Start();
    return true;
  }

  if (down && key==keyPause.code && alt==keyPause.alt && 
      ctrl==keyPause.ctrl && shift==keyPause.shift) 
  {
    if (IsPaused())
	UnPause();
    else
	Pause();
    return true;
  }

  return false;
}
Ejemplo n.º 16
0
		DWORD _RecvImpl()
		{
			while(!recvThread_.IsAborted())
			{
				try
				{
					common::Buffer buf(common::MakeBuffer(common::MAX_UDP_PACKAGE));

					SOCKADDR_IN addr = {0};
					size_t len = recvSck_.RecvFrom(iocp::Buffer(buf.first.get(), buf.second), &addr);
					if( len == 0 )
						continue;

					char retBuf[4] = {0};
					size_t sendLen = recvSck_.SendTo(iocp::Buffer(retBuf), &addr);
					assert(sendLen == sizeof(retBuf));

					buf.second = len;

					if( !IsPaused() )
						queue_.Put(buf);
				}
				catch(std::exception &e)
				{
					::InterlockedExchange(&isOK_, 0);

					::OutputDebugStringA(e.what());
				}
			}

			return 0;
		}
Ejemplo n.º 17
0
void
Moose::Sound::CMusicClip::Play()
{
    
 if ( IsPaused())
 {
     m_bPaused = false;
     pthread_mutex_lock(&m_pData->mutex); 
     AudioQueueStart(m_pData->audioQueue, NULL);
     pthread_mutex_unlock(&m_pData->mutex);
 }
 else 
 {
     if ( IsRunning()) Stop();
     if ( m_bHasThread ) 
     {
         void *status;
         pthread_join(m_thread, &status);
         m_bHasThread = false;
     }
     OSStatus err = pthread_create( &m_thread, NULL, audio_decode_play_proc, this);
     if ( err ) {
         g_Error << "Could not create thread for music clip, error: " << err << endl;
         
     }
    }
      
	
	    
    
}
Ejemplo n.º 18
0
void AnimationComponent::Update(float dt)
{
	if (IsPaused() || !IsPlaying())
	{
		return;
	}
	AnimationData thisAnim = GetCurrentAnim();
	int startFrame = thisAnim.startFrame;

	float dur = thisAnim.frames[currentFrame];
	time += dt * playbackSpeed;
	while (time > dur && currentFrame < thisAnim.frames.size())
	{
		time -= dur;
		++currentFrame;
		if (playbackFlags & Anim_Loop)
		{
			currentFrame %= thisAnim.frames.size();
		}
		else if (currentFrame >= thisAnim.frames.size())
		{
			state = 0;
			return;
		}
		dur = thisAnim.frames[currentFrame];
	}

	unsigned int framesPerRow = (unsigned int)(1.0f / mUV.scale.x);
	
	mUV.position.x = ( (currentFrame + startFrame) % framesPerRow) * mUV.scale.x;
	mUV.position.y = ( (currentFrame + startFrame) / framesPerRow) * mUV.scale.y;

}
Ejemplo n.º 19
0
void Emulator::Run()
{
	if (!IsReady())
	{
		Load();
		if(!IsReady()) return;
	}

	if (IsRunning()) Stop();

	if (IsPaused())
	{
		Resume();
		return;
	}

	
	GetCallbacks().on_run();

	m_pause_start_time = 0;
	m_pause_amend_time = 0;
	m_state = system_state::running;

	auto on_select = [](u32, cpu_thread& cpu)
	{
		cpu.run();
	};

	idm::select<ppu_thread>(on_select);
	idm::select<ARMv7Thread>(on_select);
	idm::select<RawSPUThread>(on_select);
	idm::select<SPUThread>(on_select);
}
Ejemplo n.º 20
0
void Emulator::Run()
{
	if (!IsReady())
	{
		Load();
		if(!IsReady()) return;
	}

	if (IsRunning()) Stop();

	if (IsPaused())
	{
		Resume();
		return;
	}

	rpcs3::on_run()();

	SendDbgCommand(DID_START_EMU);

	m_pause_start_time = 0;
	m_pause_amend_time = 0;
	m_status = Running;

	for (auto& thread : get_all_cpu_threads())
	{
		thread->state -= cpu_state::stop;
		thread->safe_notify();
	}

	SendDbgCommand(DID_STARTED_EMU);
}
Ejemplo n.º 21
0
void CGEGameTimer::AddToLength(float length_seconds)
{
	// Don't do anything we are are not enabled
	if (!IsEnabled())
		return;

	// If paused, resume the time to capture our real end time
	bool was_paused = IsPaused();
	if (was_paused)
		Resume();

	// If changing the time would result in negative time, end the round.
	if (m_flEndTime - gpGlobals->curtime + length_seconds > 0) // If the time to be adjusted to is greater than 0, go ahead and offset
	{
		m_flEndTime += length_seconds;
		m_flLength += length_seconds;
	}
	else // Otherwise we took off all the remaining round time and ended it.
	{
		m_flEndTime = gpGlobals->curtime;
		m_flLength = 1;
	}

	// If we were paused, put as back in that state
	if (was_paused)
		Pause();
}
Ejemplo n.º 22
0
Game::Game(const SystemPath &path, double time) :
	m_time(time),
	m_state(STATE_NORMAL),
	m_wantHyperspace(false),
	m_timeAccel(TIMEACCEL_1X),
	m_requestedTimeAccel(TIMEACCEL_1X),
	m_forceTimeAccel(false)
{
	Pi::FlushCaches();
	if (!Pi::GetGalaxy()->GetGenerator().IsDefault())
		Pi::CreateGalaxy();

	m_space.reset(new Space(this, path));
	SpaceStation *station = static_cast<SpaceStation*>(m_space->FindBodyForPath(&path));
	assert(station);

	m_player.reset(new Player("kanara"));

	m_space->AddBody(m_player.get());

	m_player->SetFrame(station->GetFrame());
	m_player->SetDockedWith(station, 0);

	Polit::Init();

	CreateViews();

	EmitPauseState(IsPaused());
}
Ejemplo n.º 23
0
void CPUThread::Run()
{
	if(IsRunning()) Stop();
	if(IsPaused())
	{
		Resume();
		return;
	}
	
#ifndef QT_UI
	wxGetApp().SendDbgCommand(DID_START_THREAD, this);
#endif

	m_status = Running;

	SetPc(entry);
	InitStack();
	InitRegs();
	DoRun();
	Emu.CheckStatus();

#ifndef QT_UI
	wxGetApp().SendDbgCommand(DID_STARTED_THREAD, this);
#endif
}
Ejemplo n.º 24
0
void 
AnimatedSprite::Process(float deltaTime)
{
	// Ex007.1: If not paused...
	if (!IsPaused()) {
		// Ex007.1: Count the time elapsed.
		m_timeElapsed += deltaTime;
		// Ex007.1: If the time elapsed is greater than the frame speed.
		if (m_timeElapsed > m_frameSpeed) {
			// Ex007.1: Move to the next frame.
			++m_currentFrame;
			// Ex007.1: Reset the time elapsed counter.
			m_timeElapsed = 0;
		}

		// Ex007.1: If the current frame is greater than the number 
		//          of frame in this animation...
		if (m_currentFrame > m_frameCoords.size() - 1) {
			if (IsLooping()) {
				// Ex007.1: Reset to the first frame.
				m_currentFrame = 0;
			}
			else {
				// Ex007.1: Stop the animation if it is not looping...
				m_animating = false;
			}
		}
	}	
}
Ejemplo n.º 25
0
void
nsSMILTimeContainer::UpdateCurrentTime()
{
  nsSMILTime now = IsPaused() ? mPauseStart : GetParentTime();
  mCurrentTime = now - mParentOffset;
  NS_ABORT_IF_FALSE(mCurrentTime >= 0, "Container has negative time");
}
Ejemplo n.º 26
0
float CUPnPPlayer::GetSpeed()
{
  if (IsPaused())
    return 0;
  else
    return 1;
}
Ejemplo n.º 27
0
void VFmodSoundObject::MessageFunction(int iID, INT_PTR iParamA, INT_PTR iParamB)
{
  VisObject3D_cl::MessageFunction(iID, iParamA, iParamB);

  if (iID==VIS_MSG_TRIGGER)
  {
    // cache IDs to avoid string comparisons
    if (VFMOD_TRIGGER_ID_PAUSE == -1)
    {
      VFMOD_TRIGGER_ID_PAUSE = IVObjectComponent::RegisterStringID(VFMOD_TRIGGER_PAUSE);
      VFMOD_TRIGGER_ID_RESUME = IVObjectComponent::RegisterStringID(VFMOD_TRIGGER_RESUME);
    }

    // the trigger components are added by vForge and serialized if used
    VisTriggerTargetComponent_cl *pTarget = (VisTriggerTargetComponent_cl *)iParamB;
    if (pTarget->m_iComponentID==VFMOD_TRIGGER_ID_PAUSE)
      SetPaused(true);
    else if (pTarget->m_iComponentID==VFMOD_TRIGGER_ID_RESUME)
    {
      if (IsPaused())
        SetPaused(false);
      else
      {
        Helper_SetFlag(VFMOD_FLAG_PAUSED, false);
        Play();
      }
    }
    return;
  }
}
void CDownloadWithSearch::RunSearch(DWORD tNow)
{
	if ( ! CanSearch() )
	{
		StopSearch();
		return;
	}
	
	if ( tNow > m_tSearchTime && tNow - m_tSearchTime < Settings.Downloads.SearchPeriod )
	{
		StartManualSearch();
	}
	else if ( tNow > m_tSearchCheck && tNow - m_tSearchCheck >= 1000 )
	{
		BOOL bFewSources = GetSourceCount( FALSE, TRUE ) < Settings.Downloads.MinSources;
		BOOL bDataStarve = ( tNow > m_tReceived ? tNow - m_tReceived : 0 ) > Settings.Downloads.StarveTimeout * 1000;
		
		m_tSearchCheck = tNow;
		
		if ( IsPaused() == FALSE && ( bFewSources || bDataStarve ) )
		{
			StartAutomaticSearch();
		}
		else
		{
			StopSearch();
		}
	}
}
Ejemplo n.º 29
0
void CGEGameTimer::SetCurrentLength(float length_seconds)
{
	// Don't do anything we are are not enabled
	if (!IsEnabled())
		return;

	// Stop the timer if we change to no length
	if (length_seconds <= 0) {
		Stop();
		return;
	}

	// Simply start the timer if not running already
	if (!IsStarted()) {
		Start(length_seconds);
		return;
	}

	// If paused, resume the time to capture our real end time
	bool was_paused = IsPaused();
	if (was_paused)
		Resume();

	// We always directly set to this time.
	m_flEndTime = gpGlobals->curtime + length_seconds;
	m_flLength = length_seconds;

	// If we were paused, put as back in that state
	if (was_paused)
		Pause();
}
Ejemplo n.º 30
0
Game::Game(const SystemPath &path, const vector3d &pos, double time) :
	m_time(time),
	m_state(STATE_NORMAL),
	m_wantHyperspace(false),
	m_timeAccel(TIMEACCEL_1X),
	m_requestedTimeAccel(TIMEACCEL_1X),
	m_forceTimeAccel(false)
{
	Pi::FlushCaches();
	if (!Pi::GetGalaxy()->GetGenerator().IsDefault())
		Pi::CreateGalaxy();

	m_space.reset(new Space(this, path));
	Body *b = m_space->FindBodyForPath(&path);
	assert(b);

	m_player.reset(new Player("kanara"));

	m_space->AddBody(m_player.get());

	m_player->SetFrame(b->GetFrame());

	m_player->SetPosition(pos);
	m_player->SetVelocity(vector3d(0,0,0));

	Polit::Init();

	CreateViews();

	EmitPauseState(IsPaused());
}