void QSequentialAnimationGroupJob::activateCurrentAnimation(bool intermediate) { if (!m_currentAnimation || isStopped()) return; m_currentAnimation->stop(); // we ensure the direction is consistent with the group's direction m_currentAnimation->setDirection(m_direction); // reset the finish time of the animation if it is uncontrolled if (m_currentAnimation->totalDuration() == -1) resetUncontrolledAnimationFinishTime(m_currentAnimation); RETURN_IF_DELETED(m_currentAnimation->start()); if (!intermediate && isPaused()) m_currentAnimation->pause(); }
void WorkerScriptDebugServer::runMessageLoopOnPause(v8::Handle<v8::Context> context) { WorkerContext* workerContext = retrieveWorkerContext(context); WorkerThread* workerThread = workerContext->thread(); m_pausedWorkerContext = workerContext; MessageQueueWaitResult result; do { result = workerThread->runLoop().runInMode(workerContext, debuggerTaskMode); // Keep waiting until execution is resumed. } while (result == MessageQueueMessageReceived && isPaused()); m_pausedWorkerContext = 0; // The listener may have been removed in the nested loop. if (ScriptDebugListener* listener = m_listenersMap.get(workerContext)) listener->didContinue(); }
void ScriptDebugServer::dispatchDidPause(ScriptDebugListener* listener) { ASSERT(isPaused()); DebuggerCallFrame* debuggerCallFrame = currentDebuggerCallFrame(); JSGlobalObject* globalObject = debuggerCallFrame->scope()->globalObject(); JSC::ExecState* state = globalObject->globalExec(); RefPtr<JavaScriptCallFrame> javaScriptCallFrame = JavaScriptCallFrame::create(debuggerCallFrame); JSValue jsCallFrame; { if (globalObject->inherits(JSDOMGlobalObject::info())) { JSDOMGlobalObject* domGlobalObject = jsCast<JSDOMGlobalObject*>(globalObject); JSLockHolder lock(state); jsCallFrame = toJS(state, domGlobalObject, javaScriptCallFrame.get()); } else jsCallFrame = jsUndefined(); } listener->didPause(state, ScriptValue(state->vm(), jsCallFrame), ScriptValue()); }
bool BassPlayer::setOutputDevice(const QString & device_name) { int curr_device = BASS_GetDevice(); int new_device = outputDeviceList().value(device_name, default_device).toInt(); if (curr_device == new_device) return true; bool res = false; if ((res = initOutputDevice(new_device))) { //INFO: we cant close here old device // we must close it later res = BASS_SetDevice(new_device); if (isPlayed() || isPaused()) res &= BASS_ChannelSetDevice(chan, new_device); } return res; }
void SMILTimeContainer::setElapsed(SMILTime time) { if (!m_beginTime) { m_presetStartTime = time.value(); return; } double now = currentTime(); m_beginTime = now - time.value(); m_accumulatedPauseTime = 0; Vector<SVGSMILElement*> toReset; copyToVector(m_scheduledAnimations, toReset); for (unsigned n = 0; n < toReset.size(); ++n) toReset[n]->reset(); if (isPaused()) updateAnimations(now - m_beginTime - m_accumulatedPauseTime); }
ScriptValue ScriptController::executeScriptInWorld(DOMWrapperWorld* world, const String& script, bool forceUserGesture) { ScriptSourceCode sourceCode(script, forceUserGesture ? KURL() : m_frame->document()->url()); if (!canExecuteScripts(AboutToExecuteScript) || isPaused()) return ScriptValue(); bool wasInExecuteScript = m_inExecuteScript; m_inExecuteScript = true; ScriptValue result = evaluateInWorld(sourceCode, world); if (!wasInExecuteScript) { m_inExecuteScript = false; Document::updateStyleForAllDocuments(); } return result; }
void Engine::update() { // We're about to start another frame. It's safe to delete our level, and start cleaning up the // old b2World. performLevelChange(); mWorldToDelete.reset(); emit beforeUpdate(); if (isPaused()) { updateCamera(); return; } // If no level has yet to be loaded (which can happen if the queued event // hasn't yet been processed) then we must skip if (!mLevelReady) { return; } setPhase(LOGICS_PHASE); forEach<Logic>([] (Logic* logic) { if (logic->isActive()) { logic->update(); } }); setPhase(BEFORE_PHYSICS_PHASE); forEach<Body>([] (Body* body) { body->updateBeforePhysics(); }); setPhase(PHYSICS_PHASE); mWorldStepCount++; getWorld()->Step(TIME_STEP_S, VELOCITY_ITERATIONS, POSITION_ITERATIONS, PARTICLE_ITERATIONS); setPhase(AFTER_PHYSICS_PHASE); forEach<Body>([] (Body* body) { body->updateAfterPhysics(); }); emit afterUpdate(); setPhase(CAMERA_PHASE); updateCamera(); mTextureManager->processDeletion(); setPhase(RENDERING_PHASE); }
ScriptValue ScriptController::executeScript(const ScriptSourceCode& sourceCode) { if (!canExecuteScripts(AboutToExecuteScript) || isPaused()) return ScriptValue(); bool wasInExecuteScript = m_inExecuteScript; m_inExecuteScript = true; RefPtr<Frame> protect(m_frame); // Script execution can destroy the frame, and thus the ScriptController. ScriptValue result = evaluate(sourceCode); if (!wasInExecuteScript) { m_inExecuteScript = false; Document::updateStyleForAllDocuments(); } return result; }
void ovSndPlayer::update() { if(!this) return; ALint buffers = 0; alGetSourcei(_source_name, AL_BUFFERS_QUEUED, &buffers); if(buffers == 0) { int size, buffer_name; for(int i = 0; i < (int)_array_buffer.size(); ++i) { size = stream(); if(size) { buffer_name = _array_buffer[i]->buffer_name(); alBufferData(buffer_name, _format, &*_buffer.begin(), size, ((vorbis_info*)_ov_info)->rate); alSourceQueueBuffers(_source_name, 1, (const unsigned int*)&buffer_name); } } } else { int buffers = 0; int size, buffer_name; alGetSourcei(_source_name, AL_BUFFERS_PROCESSED, &buffers); if(buffers > 0) { alSourceUnqueueBuffers(_source_name, 1, (unsigned int*)&buffer_name); size = stream(); if(size) { alBufferData(buffer_name, _format, &*_buffer.begin(), size, ((vorbis_info*)_ov_info)->rate); alSourceQueueBuffers(_source_name, 1, (const unsigned int*)&buffer_name); } } } if(isPaused() || isStopped()) SndPlayer::play(); }
bool VLCVideoWrapper::pause(void) { // check if the player can be paused if(libvlc_media_player_can_pause(_MediaPlayer)) { // can pause it? do it libvlc_media_player_pause(_MediaPlayer); // error checking of course checkVLCError("pausing"); } if(isPaused()) { producePaused(); return true; } else { return false; } }
void AVClock::timerEvent(QTimerEvent *event) { Q_ASSERT_X(clockType() != AudioClock, "AVClock::timerEvent", "Internal error. AudioClock can not call this"); if (event->timerId() != correction_schedule_timer.timerId()) return; if (isPaused()) return; const double delta_pts = (value() - last_pts)/speed(); //const double err = double(correction_timer.restart()) * kThousandth - delta_pts; const qint64 now = QDateTime::currentMSecsSinceEpoch(); const double err = double(now - t) * kThousandth - delta_pts; t = now; // FIXME: avfoundation camera error is large (about -0.6s) if (qAbs(err*10.0) < kCorrectionInterval || clock_type == VideoClock) { avg_err += err/(nb_restarted+1); } //qDebug("correction timer event. error = %f, avg_err=%f, nb_restarted=%d", err, avg_err, nb_restarted); last_pts = value(); nb_restarted = 0; }
uint32 VideoDecoder::getTime() const { if (!isPlaying()) return _lastTimeChange.msecs(); if (isPaused()) return MAX<int>((_playbackRate * (_pauseStartTime - _startTime)).toInt(), 0); if (useAudioSync()) { for (TrackList::const_iterator it = _tracks.begin(); it != _tracks.end(); it++) { if ((*it)->getTrackType() == Track::kTrackTypeAudio && !(*it)->endOfTrack()) { uint32 time = ((const AudioTrack *)*it)->getRunningTime(); if (time != 0) return time + _lastTimeChange.msecs(); } } } return MAX<int>((_playbackRate * (g_system->getMillis() - _startTime)).toInt(), 0); }
bool AVPlayer::captureVideo() { if (!video_capture) return false; bool pause_old = isPaused(); if (!video_capture->isAsync()) pause(true); video_capture->setCaptureDir(capture_dir); QString cap_name(capture_name); if (cap_name.isEmpty()) cap_name = QFileInfo(path).completeBaseName(); //FIXME: pts is not correct because of multi-thread double pts = video_thread->currentPts(); cap_name += "_" + QString::number(pts, 'f', 3); video_capture->setCaptureName(cap_name); qDebug("request capture: %s", qPrintable(cap_name)); video_capture->request(); if (!video_capture->isAsync()) pause(pause_old); return true; }
bool PauseWaiter::checkPause() { if (isPaused()) { if (!itsInPause) LINFO("****** PAUSED ******"); itsInPause = true; usleep(itsUsecsWait); } else { if (itsInPause) LINFO("****** RESUMING ******"); itsInPause = false; } return itsInPause; }
bool TechTask::update() { if(mUnit) { if(mUnit->isResearching()) { if(mUnit->getTech() != mType || isStopped() || isPaused() || isCanceled()) mUnit->cancel(); else if(mReservedResources) { ResourceTracker::Instance().releaseCurrentMinerals(mRequiredSatisfyTime, mType.mineralPrice()); ResourceTracker::Instance().releaseCurrentGas(mRequiredSatisfyTime, mType.gasPrice()); mReservedResources = false; } } else if(!shouldReturnUnit()) mUnit->research(mType); } return hasEnded() && !mUnit; }
void LiveStream::setState(State newState) { if (m_state == newState) return; State oldState = m_state; m_state = newState; if (m_state != Error) m_errorMessage.clear(); emit stateChanged(newState); if (newState >= Streaming && oldState < Streaming) emit streamRunning(); else if (oldState >= Streaming && newState < Streaming) emit streamStopped(); if (oldState == Paused || newState == Paused) emit pausedChanged(isPaused()); }
//! @brief Starts the timer. If a MutuallyExclusiveTime timer is running, it will be stopped. //! @pre Timer is not already paused. //! @post Timer is running. Other MutuallyExclusiveTime timers are paused or stopped. void start(bool reset=false) { TEUCHOS_TEST_FOR_EXCEPTION(isPaused(), Exceptions::RuntimeError, "MueLu::MutuallyExclusiveTime::start(): timer is paused. Use resume()."); if (isRunning()) { return; } // If timer is already running, do not pause/push-in-the-stack/start the timer. // Otherwise, something bad will happen when this.stop() will be called // pause currently running timer if (!timerStack_.empty()) { GetOStream(Debug) << "pausing parent timer " << timerStack_.top()->name_ << std::endl; timerStack_.top()->pause(); GetOStream(Debug) << "starting child timer " << this->name_ << std::endl; myParent_[this->name_] = timerStack_.top()->name_; } else { GetOStream(Debug) << "starting orphan timer " << this->name_ << std::endl; myParent_[this->name_] = "no parent"; } // start this timer timer_->start(reset); timerStack_.push(this); }
void OpenSLPlayer::restore() { lock(); accessTime = currentTimeMillis(); if (player == NULL) { unlock(); return; } if (isPaused() && AtomicExchange(&resume, false)) { if (AtomicExchange(&reset, false)) (*playerSeek)->SetPosition(playerSeek, 0, SL_SEEKMODE_FAST); (*playerSeek)->SetLoop(playerSeek, AtomicGet(&loop) ? SL_BOOLEAN_TRUE : SL_BOOLEAN_FALSE, 0, SL_TIME_UNKNOWN); (*player)->SetPlayState(player, SL_PLAYSTATE_PLAYING); AtomicSet(&state, SL_PLAYSTATE_PLAYING); } unlock(); }
void VideoDecoder::addTrack(Track *track) { _tracks.push_back(track); if (track->getTrackType() == Track::kTrackTypeAudio) { // Update volume settings if it's an audio track ((AudioTrack *)track)->setVolume(_audioVolume); ((AudioTrack *)track)->setBalance(_audioBalance); } else if (track->getTrackType() == Track::kTrackTypeVideo) { // If this track has a better time, update _nextVideoTrack if (!_nextVideoTrack || ((VideoTrack *)track)->getNextFrameStartTime() < _nextVideoTrack->getNextFrameStartTime()) _nextVideoTrack = (VideoTrack *)track; } // Keep the track paused if we're paused if (isPaused()) track->pause(true); // Start the track if we're playing if (isPlaying() && track->getTrackType() == Track::kTrackTypeAudio) ((AudioTrack *)track)->start(); }
bool NetDemo::startRecording(const std::string &filename) { this->filename = filename; if (isPlaying() || isPaused()) { error("Cannot record a netdemo while not connected to a server."); return false; } // Already recording so just ignore the command if (isRecording()) return true; if (demofp != NULL) // file is already open for some reason { fclose(demofp); demofp = NULL; } demofp = fopen(filename.c_str(), "wb"); if (!demofp) { error("Unable to create netdemo file."); return false; } memset(&header, 0, NetDemo::HEADER_SIZE); // Note: The header is not finalized at this point. Write it anyway to // reserve space in the output file for it and overwrite it later. if (!writeHeader()) { error("Unable to write netdemo header."); return false; } state = NetDemo::recording; return true; }
// MAIN thread bool LLQueuedThread::waitForResult(LLQueuedThread::handle_t handle, bool auto_complete) { llassert (handle != nullHandle()); bool res = false; bool waspaused = isPaused(); bool done = false; while(!done) { update(0); // unpauses lockData(); QueuedRequest* req = (QueuedRequest*)mRequestHash.find(handle); if (!req) { done = true; // request does not exist } else if (req->getStatus() == STATUS_COMPLETE && !(req->getFlags() & FLAG_LOCKED)) { res = true; if (auto_complete) { mRequestHash.erase(handle); req->deleteRequest(); // check(); } done = true; } unlockData(); if (!done && mThreaded) { yield(); } } if (waspaused) { pause(); } return res; }
bool ConstructionTask::preUpdate() { if(mProducedUnit) { if(mProducedUnit->exists()) { freeResources(); freeLocation(); } if(!isStopped() && !isCanceled() && mProducedUnit->isCompleted()) { complete(); return true; } } if(mReservedLocation) { if(hasEnded()) freeLocation(); else if(isPaused() || isStopped()) { freeResources(); mRequiredSatisfyTime = Requirement::maxTime; mRequiredDelayTime = Requirement::maxTime; mReservedLocation->setStartTime(Requirement::maxTime); } } if(!shouldReturnUnit()) updateRequirements(); if(mBuilder && finishedWithBuilder() && (mType.getRace() == BWAPI::Races::Protoss || !mBuilder->isConstructing())) return true; return false; }
//remember last value because we don't reset pts_, pts_v, delay_ void AVClock::pause(bool p) { if (isPaused() == p) return; if (clock_type == AudioClock) return; m_paused = p; if (p) { correction_schedule_timer.stop(); #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) timer.invalidate(); #else timer.stop(); #endif //QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) emit paused(); } else { timer.start(); correction_schedule_timer.start(kCorrectionInterval*1000, this); emit resumed(); } t = QDateTime::currentMSecsSinceEpoch(); emit paused(p); }
//remember last value because we don't reset pts_, pts_v, delay_ void AVClock::pause(bool p) { if (isPaused() == p) return; if (clock_type == AudioClock) return; m_state = p ? kPaused : kRunning; if (p) { QTimer::singleShot(0, this, SLOT(stopCorrectionTimer())); #if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) timer.invalidate(); #else timer.stop(); #endif //QT_VERSION >= QT_VERSION_CHECK(4, 7, 0) emit paused(); } else { timer.start(); QTimer::singleShot(0, this, SLOT(restartCorrectionTimer())); emit resumed(); } t = QDateTime::currentMSecsSinceEpoch(); emit paused(p); }
/** * Render all graphics for a single frame */ void GameStatePlay::render() { // Create a list of Renderables from all objects not already on the map. // split the list into the beings alive (may move) and dead beings (must not move) std::vector<Renderable> rens; std::vector<Renderable> rens_dead; pc->addRenders(rens, rens_dead); enemies->addRenders(rens, rens_dead); npcs->addRenders(rens); // npcs cannot be dead loot->addRenders(rens, rens_dead); hazards->addRenders(rens, rens_dead); // render the static map layers plus the renderables mapr->render(rens, rens_dead); // mouseover tooltips loot->renderTooltips(mapr->cam); if (mapr->map_change) { menu->mini->prerender(&mapr->collider, mapr->w, mapr->h); mapr->map_change = false; } menu->mini->getMapTitle(mapr->title); menu->mini->render(pc->stats.pos); menu->render(); // render combat text last - this should make it obvious you're being // attacked, even if you have menus open if (!isPaused()) comb->render(); }
void AVDemuxThread::seekInternal(qint64 pos, SeekType type) { AVThread* av[] = { audio_thread, video_thread}; qDebug("seek to %s %lld ms (%f%%)", QTime(0, 0, 0).addMSecs(pos).toString().toUtf8().constData(), pos, double(pos - demuxer->startTime())/double(demuxer->duration())*100.0); demuxer->setSeekType(type); demuxer->seek(pos); if (ademuxer) { ademuxer->setSeekType(type); ademuxer->seek(pos); } AVThread *watch_thread = 0; // TODO: why queue may not empty? for (size_t i = 0; i < sizeof(av)/sizeof(av[0]); ++i) { AVThread *t = av[i]; if (!t) continue; t->packetQueue()->clear(); // TODO: the first frame (key frame) will not be decoded correctly if flush() is called. //PacketBuffer *pb = t->packetQueue(); //qDebug("%s put seek packet. %d/%d-%.3f, progress: %.3f", t->metaObject()->className(), pb->buffered(), pb->bufferValue(), pb->bufferMax(), pb->bufferProgress()); t->packetQueue()->setBlocking(false); // aqueue bufferValue can be small (1), we can not put and take Packet pkt; pkt.pts = qreal(pos)/1000.0; t->packetQueue()->put(pkt); t->packetQueue()->setBlocking(true); // blockEmpty was false when eof is read. if (isPaused()) { t->pause(false); watch_thread = t; } } if (watch_thread) { pauseInternal(false); emit requestClockPause(false); // need direct connection // direct connection is fine here connect(watch_thread, SIGNAL(seekFinished(qint64)), this, SLOT(seekOnPauseFinished()), Qt::DirectConnection); } }
void StarkEngine::updateDisplayScene() { if (_global->isFastForward()) { // The original engine was frame limited to 30 fps. // Set the frame duration to 1000 / 30 ms so that fast forward // skips the same amount of simulated time as the original. _global->setMillisecondsPerGameloop(33); } else { _global->setMillisecondsPerGameloop(_frameLimiter->getLastFrameDuration()); } // Clear the screen _gfx->clearScreen(); // Only update the world resources when on the game screen if (_userInterface->isInGameScreen() && !isPaused()) { int frames = 0; do { // Update the game resources _global->getLevel()->onGameLoop(); _global->getCurrent()->getLevel()->onGameLoop(); _global->getCurrent()->getLocation()->onGameLoop(); frames++; // When the game is in fast forward mode, update // the game resources for multiple frames, // but render only once. } while (_global->isFastForward() && frames < 100); _global->setNormalSpeed(); } // Render the current scene // Update the UI state before displaying the scene _userInterface->update(); // Tell the UI to render, and update implicitly, if this leads to new mouse-over events. _userInterface->render(); }
void VideoDecoder::addTrack(Track *track, bool isExternal) { _tracks.push_back(track); if (isExternal) _externalTracks.push_back(track); else _internalTracks.push_back(track); if (track->getTrackType() == Track::kTrackTypeAudio) { // Update volume settings if it's an audio track ((AudioTrack *)track)->setVolume(_audioVolume); ((AudioTrack *)track)->setBalance(_audioBalance); if (!isExternal && supportsAudioTrackSwitching()) { if (_mainAudioTrack) { // The main audio track has already been found ((AudioTrack *)track)->setMute(true); } else { // First audio track found -> now the main one _mainAudioTrack = (AudioTrack *)track; _mainAudioTrack->setMute(false); } } } else if (track->getTrackType() == Track::kTrackTypeVideo) { // If this track has a better time, update _nextVideoTrack if (!_nextVideoTrack || ((VideoTrack *)track)->getNextFrameStartTime() < _nextVideoTrack->getNextFrameStartTime()) _nextVideoTrack = (VideoTrack *)track; } // Keep the track paused if we're paused if (isPaused()) track->pause(true); // Start the track if we're playing if (isPlaying() && track->getTrackType() == Track::kTrackTypeAudio) ((AudioTrack *)track)->start(); }
std::string gt::Torrent::getTextState() { std::ostringstream o; int precision = 1; if(getHandle().status().queue_position != -1 && getHandle().status().queue_position >= stoi(gt::Settings::settings["ActiveDownloads"])) return "Queued"; switch (getState()) { case libtorrent::torrent_status::queued_for_checking: return "Queued for checking"; case libtorrent::torrent_status::downloading_metadata: return "Downloading metadata..."; case libtorrent::torrent_status::finished: return "Finished"; case libtorrent::torrent_status::allocating: return "Allocating..."; case libtorrent::torrent_status::checking_resume_data: return "Resuming..."; case libtorrent::torrent_status::checking_files: return "Checking..."; case libtorrent::torrent_status::seeding: return "Seeding"; case libtorrent::torrent_status::downloading: break; } if(isPaused()) return "Paused"; if (m_torrent_params.ti != NULL) //m_torrent_params.ti is not initial initialized for magnet links precision = m_torrent_params.ti->total_size() < 0x2000000;//Set 0 decimal places if file is less than 1 gig. o << std::fixed << std::setprecision(precision) << getTotalProgress() << '%'; return o.str(); }
void AIOpponent::simulate(float dt) { auto world = G_getWorld(); if (!world->hasStarted()) return; if (world->isPaused() || world->isGameOver()) return; if (orderedOpponents == NULL) return; if (powerUpExecuted && pwrupType == PowerUp::PowerUpType::GHOST) return; if (powerUpExecuted && pwrupType == PowerUp::PowerUpType::SPEED) return; if (orderedOpponents->size() == 0) return; this->setPrzedniTylni(); if (tylni && tylni->getVelocityX() > 1.2f*this->getVelocityX() && tylni->isJumping()) { jump(); } else if (przedni && przedni->getVelocityX() < 0.8f*this->getVelocityX()) { jump(); } else if (stykasie()) { jump(); } if (pwrupType != PowerUp::PowerUpType::NONE) maintainPowerUp(); }