Example #1
0
/*/////////////////////////////////////////////////////////////////*/
void OgreOggStaticSound::_stopImpl() {
    if(mSource == AL_NONE || isStopped()) return;

    alSourceStop(mSource);
    alSourceRewind(mSource);
    mPlay = false;
    mPreviousOffset = 0;

    // Notify listener
    if(mSoundListener) mSoundListener->soundStopped(this);

    // Mark for destruction
    if(mTemporary) {
        OgreOggSoundManager::getSingletonPtr()->_destroyTemporarySound(this);
    }
    // Give up source immediately if specfied
    else if(mGiveUpSource)
        OgreOggSoundManager::getSingleton()._releaseSoundSource(this);
}
Example #2
0
void LLQueuedThread::shutdown()
{
	setQuitting();

	unpause(); // MAIN THREAD
	if (mThreaded)
	{
		S32 timeout = 100;
		for ( ; timeout>0; timeout--)
		{
			if (isStopped())
			{
				break;
			}
			ms_sleep(100);
			LLThread::yield();
		}
		if (timeout == 0)
		{
			llwarns << "~LLQueuedThread (" << mName << ") timed out!" << llendl;
		}
	}
	else
	{
		mStatus = STOPPED;
	}

	QueuedRequest* req;
	S32 active_count = 0;
	while ( (req = (QueuedRequest*)mRequestHash.pop_element()) )
	{
		if (req->getStatus() == STATUS_QUEUED || req->getStatus() == STATUS_INPROGRESS)
		{
			++active_count;
			req->setStatus(STATUS_ABORTED); // avoid assert in deleteRequest
		}
		req->deleteRequest();
	}
	if (active_count)
	{
		llwarns << "~LLQueuedThread() called with active requests: " << active_count << llendl;
	}
}
Example #3
0
File: Song.cpp Project: rcorre/lmms
void Song::playSong()
{
	m_recording = false;

	if( isStopped() == false )
	{
		stop();
	}

	m_playMode = Mode_PlaySong;
	m_playing = true;
	m_paused = false;

	m_vstSyncController.setPlaybackState( true );

	savePos();

	emit playbackStateChanged();
}
Example #4
0
		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();
		}
StkFrames& NxSoundMediaFileVSTi::Update( StkFrames& Frame ) {

	if(!Frame.size()) Frame.resize( SND_BUFFER_SIZE, GetNumChannels() );

	if( isMuted() || isStopped() ) {

		for ( unsigned int i=0; i < Frame.size(); i++ ){ 
			Frame[i] = 0.0f;
		} 
		return Frame;
	}

	if( VSTInstrument ){

		VstInt32 numinputs = VSTInstrument->GetNumInputs() ;
		VstInt32 numoutputs = VSTInstrument->GetNumOutputs() ;

		if(( VSTInstrument->GetEffect()->flags & effFlagsCanReplacing) != 0) {

			try {
				VSTInstrument->GetEffect()->processReplacing (VSTInstrument->GetEffect(), NULL , outBufs , VSTInstrument->GetBlockSize() );
			}
            catch (...) {
				Log( "NxSound : Error processing NxSoundMediaFileVSTi::Update" );
			}

		 

			for ( unsigned int i=0; i< VSTInstrument->GetBlockSize() ; i++ ){
				float * buffer = outBufs[0];//VSTInstrument->GetOutputBuffer(0) ;
				Frame( i , 0 ) = buffer[i]  ;
			} 

			for ( unsigned int i=0; i< VSTInstrument->GetBlockSize() ; i++ ){
				float * buffer = outBufs[1];//VSTInstrument->GetOutputBuffer(1) ;
				Frame( i , 1 ) = buffer[i] ;
			} 
		}
	}

	return Frame ;
}
Example #6
0
bool HGTController::saveData(const char* data, uint32 size)
{
	if (isStopped())
		return true;

	if (size == 0)
		return false;

	if (!m_pCurBlock || m_pCurBlock->vBlockList.size() == 0)
		return true;

	MCFCore::Thread::Misc::WGTBlock* block = m_pCurBlock->vBlockList[0];

	uint64 done = m_pCurBlock->done;
	uint64 ds = block->size - done;

	if (done == 0)
	{
		m_hFile.seek(block->fileOffset);
		block->file->addFlag(MCFCore::MCFFileI::FLAG_STARTEDDL);
	}

	if (size >= ds)
	{
		m_hFile.write((char*)data, (uint32)ds);

		m_pCurBlock->vBlockList.pop_front();
		m_pCurBlock->done = 0;

		block->file->addFlag(MCFCore::MCFFileI::FLAG_COMPLETE);
		block->file->delFlag(MCFCore::MCFFileI::FLAG_STARTEDDL);

		saveData(data+ds, (uint32)(size-ds));
	}
	else
	{
		m_hFile.write((char*)data, size);
		m_pCurBlock->done += size;
	}

	return false;
}
Example #7
0
/*!
 * \brief Sends a joint angle command to the Jaco arm.
 *
 * Waits until the arm has stopped moving before releasing control of the API.
 */
void JacoComm::setJointAngles(const JacoAngles &angles, int timeout, bool push)
{
    boost::recursive_mutex::scoped_lock lock(api_mutex_);

    if (isStopped())
    {
        ROS_INFO("The angles could not be set because the arm is stopped");
        return;
    }

    int result = NO_ERROR_KINOVA;
    TrajectoryPoint jaco_position;
    jaco_position.InitStruct();
    memset(&jaco_position, 0, sizeof(jaco_position));  // zero structure

    if (push)
    {
        result = jaco_api_.eraseAllTrajectories();
        if (result != NO_ERROR_KINOVA)
        {
            throw JacoCommException("Could not erase trajectories", result);
        }
    }

    //startAPI();

    result = jaco_api_.setAngularControl();
    if (result != NO_ERROR_KINOVA)
    {
        throw JacoCommException("Could not set angular control", result);
    }

    jaco_position.Position.Delay = 0.0;
    jaco_position.Position.Type = ANGULAR_POSITION;
    jaco_position.Position.Actuators = angles;

    result = jaco_api_.sendAdvanceTrajectory(jaco_position);
    if (result != NO_ERROR_KINOVA)
    {
        throw JacoCommException("Could not send advanced joint angle trajectory", result);
    }
}
Example #8
0
void Initiator::stop( bool force )
{
  if( isStopped() ) return;

  HttpServer::stopGlobal();

  std::vector<Session*> enabledSessions;

  SessionIDs connected = m_connected;
  SessionIDs::iterator i = connected.begin();
  for ( ; i != connected.end(); ++i )
  {
    Session* pSession = Session::lookupSession(*i);
    if( pSession && pSession->isEnabled() )
    {
      enabledSessions.push_back( pSession );
      pSession->logout();
    }
  }

  if( !force )
  {
    for ( int second = 1; second <= 10 && isLoggedOn(); ++second )
      process_sleep( 1 );
  }

  {
    Locker l(m_mutex);
    for ( i = connected.begin(); i != connected.end(); ++i )
      setDisconnected( Session::lookupSession(*i)->getSessionID() );
  }

  m_stop = true;
  onStop();
  if( m_threadid )
    thread_join( m_threadid );
  m_threadid = 0;

  std::vector<Session*>::iterator session = enabledSessions.begin();
  for( ; session != enabledSessions.end(); ++session )
    (*session)->logon();
}
Example #9
0
void GatherInfoThread::doRun()
{
	auto wildc = gcRefPtr<WildcardManager>::create();
	wildc->onNeedSpecialEvent += delegate(&onNeedWCEvent);

	uint32 prog = 0;
	onProgUpdateEvent(prog);
	getUserCore()->getItemManager()->retrieveItemInfo(getItemId(), 0, wildc, MCFBranch::BranchFromInt(getMcfBranch()), MCFBuild::BuildFromInt(getMcfBuild()));

	if (isStopped())
		return;

	auto item = getItemInfo();

	if (!item)
		throw gcException(ERR_INVALIDDATA, "The item handle was null (gather info failed)");

	uint32 itemId = item->getId().getItem();
	onCompleteEvent(itemId);
}
Example #10
0
void ChangeDirThread::copyFiles(FileList &list)
{
	uint32 stage = 2;
	onStageEvent(stage);

	for (size_t x=0; x<list.size(); x++)
	{
		uint32 prog = x*100/list.size();
		onProgressEvent(prog);
		
		UTIL::FS::recMakeFolder(list[x].second);
		UTIL::FS::moveFile(list[x].first, list[x].second);

		if (isStopped())
			break;
	}

	delLeftOverMcf();
	UTIL::FS::delEmptyFolders(m_szCurDir);
}
Example #11
0
bool VSCheckInstall::doTask(bool completeMcf)
{
	if (HasAnyFlags(getItemInfo()->getStatus(), UserCore::Item::ItemInfoI::STATUS_INSTALLED))
	{
		if (checkInstallComplex(completeMcf))
		{
			return true;
		}
		else
		{
			bool res = checkInstall();

			if (isStopped())
				return false;

			if (res)
			{
				setResult(RES_COMPLETE);
			}
			else
			{
				setResult(RES_DOWNLOADMISSING);
				m_hMcf->saveMCFHeader();
			}
		}
	}
	else if (HasAnyFlags(getItemInfo()->getStatus(), UserCore::Item::ItemInfoI::STATUS_INSTALLING))
	{
		//continue installing
		if (!completeMcf)
			setResult(RES_DOWNLOAD);
		else
			setResult(RES_INSTALL);
	}
	else
	{
		return false;
	}

	return true;
}
Example #12
0
bool VSCheckMcf::doTask(bool &goodMcf)
{
	auto mm = getUserCore()->getInternal()->getMCFManager();
	gcString filePath = mm->getMcfPath(getItemId(), getMcfBranch(), getMcfBuild());



	if (!checkMcf(filePath))
	{
		UTIL::FS::delFile(filePath);
		filePath = downloadMCFHeader();
	}

	if (!checkMcf(filePath))
		return false;

	goodMcf = false;


	m_hMcf->setFile(filePath.c_str());

	if (isStopped())
		return false;

	try
	{
		m_hMcf->parseMCF();

		bool passedVerify = m_hMcf->verifyMCF();

		if (m_hMcf->isComplete())
			goodMcf = passedVerify;

		m_hMcf->saveMCFHeader();
	}
	catch (gcException &)
	{
	}

	return true;
}
void RobotController::turnRight()
{
    if (isTurningRight())
    {
        return;
    }

    if(!isStopped())
    {
        stop();
    }

    leftMotor.setSpeed(motor_maxSpeed);
    rightMotor.setSpeed(motor_maxSpeed);

    leftMotor.run(FORWARD);
    rightMotor.run(BACKWARD);

    movement = TURNING_RIGHT;

}
Example #14
0
void song::playPattern( Pattern* patternToPlay, bool _loop )
{
	if( isStopped() == false )
	{
		stop();
	}

	m_patternToPlay = patternToPlay;
	m_loopPattern = _loop;

	if( m_patternToPlay != NULL )
	{
		m_playMode = Mode_PlayPattern;
		m_playing = true;
		m_paused = false;
	}

	savePos();

	emit playbackStateChanged();
}
Example #15
0
bool SocketInitiator::onPoll( double timeout )
{ QF_STACK_PUSH(SocketInitiator::onPoll)

  time_t start = 0;
  time_t now = 0;

  if( isStopped() )
  {
    if( start == 0 )
      ::time( &start );
    if( !isLoggedOn() )
      return false;
    if( ::time(&now) - 5 >= start )
      return false;
  }

  m_connector.block( *this, true, timeout );
  return true;

  QF_STACK_POP
}
Example #16
0
void SocketInitiator::onStart()
{ QF_STACK_PUSH(SocketInitiator::onStart)

  connect();

  while ( !isStopped() )
    m_connector.block( *this );

  time_t start = 0;
  time_t now = 0;

  ::time( &start );
  while ( isLoggedOn() )
  {
    m_connector.block( *this );
    if( ::time(&now) -5 >= start )
      break;
  }

  QF_STACK_POP
}
Example #17
0
void ItemThread::queueTask(UserCore::ItemTask::BaseItemTask *task)
{
    if (isStopped())
    {
        safe_delete(task);
        return;
    }

    if (!task)
        return;

    task->setUserCore(m_pUserCore);
    task->setWebCore(m_pWebCore);

    m_TaskMutex.lock();
    m_vTaskList.push_back(task);
    m_TaskMutex.unlock();

    //get thread running again.
    m_WaitCond.notify();
}
Example #18
0
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;
}
Example #19
0
void VSDownloadMissing::onNewProvider(MCFCore::Misc::DP_s& dp)
{
	if (isStopped())
		return;

	if (!dp.provider)
		return;

	if (dp.action == MCFCore::Misc::DownloadProvider::ADD)
	{
		UserCore::User* pUser = dynamic_cast<UserCore::User*>(getUserCore());

		if (pUser)
			pUser->getBDManager()->downloadBanner(this, dp.provider);
	}
	else if (dp.action == MCFCore::Misc::DownloadProvider::REMOVE)
	{
		UserCore::Misc::GuiDownloadProvider gdp(MCFCore::Misc::DownloadProvider::REMOVE, dp.provider);
		onNewProviderEvent(gdp);
	}
}
void VideoProcessor::run(){
	
	cv::Mat frame;
	cv::Mat output;

	if (!isOpened())		// if no capture device has been set
		return;
	stop= false;


	while (!isStopped()) {
		if (!readNextFrame(frame))				// read next frame if any
			break;

		if (windowNameInput.length()!=0)			// display input frame
			cv::imshow(windowNameInput,frame);
	
		if (callIt) {						// calling the process function or method
			if (process){					// process the frame
				process(frame, output);
			}
			else if (frameProcessor){
				frameProcessor->process(frame,output);
			}
			fnumber++;					// increment frame number
		} else {
			output= frame;
		}
		if (outputFile.length()!=0)
			writeNextFrame(output);

		if (windowNameOutput.length()!=0)			// display output frame
			cv::imshow(windowNameOutput,output);
		if (delay>=0 && cv::waitKey(delay)>=0)			// introduce a delay
			stopIt();

		if (frameToStop>=0 && getFrameNumber()==frameToStop)// check if we should stop
			stopIt();
	}
}
Example #21
0
bool ItemThread::performTask()
{
    if (isStopped())
        return true;

    UserCore::ItemTask::BaseItemTask* task = getNewTask();

    if (!task)
        return false;

    m_DeleteMutex.lock();
    m_bDeleteCurrentTask = false;
    m_DeleteMutex.unlock();

    uint32 taskType = task->getTaskType();

    m_DeleteMutex.lock();
    m_pCurrentTask = task;
    m_DeleteMutex.unlock();

    if (!m_bDeleteCurrentTask)
    {
        m_bRunningTask = true;
        onTaskStartEvent(taskType);

        task->doTask();

        onTaskCompleteEvent(taskType);
        m_bRunningTask = false;
    }

    m_DeleteMutex.lock();
    m_pCurrentTask = NULL;
    m_DeleteMutex.unlock();

    safe_delete(task);
    setThreadName(m_szBaseName.c_str());

    return true;
}
Example #22
0
void LLThread::start()
{
    llassert(isStopped());

    // Set thread state to running
    mStatus = RUNNING;

    apr_status_t status =
        apr_thread_create(&mAPRThreadp, NULL, staticRun, (void *)this, tldata().mRootPool());

    if(status == APR_SUCCESS)
    {
        // We won't bother joining
        apr_thread_detach(mAPRThreadp);
    }
    else
    {
        mStatus = STOPPED;
        llwarns << "failed to start thread " << mName << llendl;
        ll_apr_warn_status(status);
    }
}
Example #23
0
int Screen::run()
{
  GfxEngine &engine = GfxEngine::instance();
  unsigned int lastclock = DateTime::getElapsedTime();
  unsigned int currentclock = 0;
  unsigned int ref_delay = 1000 / 20;  // 20fps

  _isStopped = false;

  while ( !isStopped() )
  {
     drawFrame();
     afterFrame();

     NEvent nEvent;
     while( engine.haveEvent( nEvent )  )
     {
       handleEvent( nEvent );
     }

     // sets a fix frameRate
     currentclock = DateTime::getElapsedTime();
     long delay = ref_delay - (currentclock - lastclock);
     if( delay < 0 )
     {
        // std::cout << "frame takes too much time! " << currentclock - lastclock << std::endl;
        delay = 0;
     }
     // FIX: game spontanous hangs
     else if (delay > ref_delay)
     {
       delay = ref_delay;
     }
     lastclock = currentclock;
     engine.delay( delay );
  }

  return getResult();
}
Example #24
0
void Acceptor::stop( bool force )
{
  if( isStopped() ) return;

  HttpServer::stopGlobal();

  std::vector<Session*> tempSessions;

  Sessions sessions = m_sessions;
  Sessions::iterator i = sessions.begin();
  for ( ; i != sessions.end(); ++i )
  {
    Session* pSession = Session::lookupSession(i->first);
    if( pSession )
    {
      tempSessions.push_back( pSession );
      pSession->logout();
      Session::unregisterSession( pSession->getSessionID() );
    }
  }

  if( !force )
  {
    for ( int second = 1; second <= 10 && isLoggedOn(); ++second )
      process_sleep( 1 );
  }

  m_stop = true;
  onStop();
  if( m_threadid )
    thread_join( m_threadid );
  m_threadid = 0;

  /* why logon again?
  std::vector<Session*>::iterator session = tempSessions.begin();
  for( ; session != tempSessions.end(); ++session )
    (*session)->logon();
    */
}
Example #25
0
void DownloadToolTask::onComplete()
{
	bool notComplete = isStopped() || m_bCancelled;

	getUserCore()->getToolManager()->removeTransaction(m_ToolTTID, notComplete);
	m_ToolTTID = UINT_MAX;

	std::vector<DesuraId> toolList;
	getItemInfo()->getCurrentBranch()->getToolList(toolList);

	if (!m_bCancelled && !getUserCore()->getToolManager()->areAllToolsDownloaded(toolList))
	{
		gcException e(ERR_INVALID, "Failed to download tools.");
		onErrorEvent(e);
		notComplete = true;
	}

	if (notComplete)
	{
		getItemHandle()->completeStage(true);
		return;
	}

	uint32 blank = 0;
	onCompleteEvent(blank);

	if (m_bInstallAfter)
	{
		getItemHandle()->goToStageInstallTools(m_bLaunch);
	}
	else
	{
		if (HasAllFlags(getItemInfo()->getStatus(), UserCore::Item::ItemInfoI::STATUS_INSTALLCOMPLEX))
			getItemHandle()->goToStageInstallComplex(getMcfBranch(), getMcfBuild());
		else
			getItemHandle()->goToStageInstall(m_szDownloadPath.c_str(), getMcfBranch());
	}
}
Example #26
0
bool VSDownloadMissing::doTask()
{
	m_hMcf->getNewProvider() += delegate(this, &VSDownloadMissing::onNewProvider);

	try
	{
		MCFCore::Misc::UserCookies uc;
		getWebCore()->setMCFCookies(&uc); 

		m_hMcf->getDownloadProviders(getWebCore()->getMCFDownloadUrl(), &uc);
		m_hMcf->dlFilesFromWeb();
	}
	catch (gcException &except)
	{
		onErrorEvent(except);
		return false;
	}

	if (isStopped())
		return false;

	return checkComplex();
}
Example #27
0
void VideoBuffer::pushNewVideoFrameTracer(VideoFrame & frame){
    if(isStopped()){
        return;
    }
    int64_t time = frame.getTimestamp().epochMicroseconds();
    if(microsOneSec==-1) microsOneSec=time;
    framesOneSec++;
    int64_t diff = time-microsOneSec;
    if(diff>=1000000){
        realFps = double(framesOneSec*1000000.)/double(diff);
        framesOneSec = 0;
        microsOneSec = time-(diff-1000000);
    }
    totalFrames++;
    if(size()==0)initTime=frame.getTimestamp();
    //timeMutex.lock();
    
    frames.push_back(frame);
    
    while(size()>maxSize){
        frames.erase(frames.begin());
    }
}
Example #28
0
bool game_player_stopped_near_point_on_foot_3d(const ScriptArguments& args)
{
	auto character = static_cast<CharacterObject*>(args.getPlayerCharacter(0));
	glm::vec3 center(args[1].real, args[2].real, args[3].real);
	glm::vec3 size(args[4].real, args[5].real, args[6].real);
	bool drawCylinder = !!args[7].integer;

	auto vehicle = character->getCurrentVehicle();
	if( ! vehicle ) {
		auto distance = center - character->getPosition();
		distance /= size;
		if( glm::length( distance ) < 1.f && character->isStopped() ) {
			return true;
		}
	}

	if( drawCylinder )
	{
		args.getWorld()->drawAreaIndicator(AreaIndicatorInfo::Cylinder, center, size);
	}

	return false;
}
Example #29
0
void SerielleSchnittstelle::execute(void *arg)
{
	Nachricht nachricht;

	initialize();

	while(!isStopped())
	{
		empfangeNachricht(&nachricht);

		switch(nachricht)
		{
			case RESET_P:
				sendePulsMessage(nachricht, 1);
				break;
			case RESET_N:
				sendePulsMessage(nachricht, 0);
				break;
			case ESTOPP_P:
				sendePulsMessage(nachricht, 1);
				break;
			case ESTOPP_N:
				sendePulsMessage(nachricht, 0);
				break;
			case START_MOTOR:
				sendePulsMessage(nachricht, 0);
				break;
			case WERKSTUECK:
				empfangeWerkstueckDaten(&werkstueckDaten);
				break;
			case EMPFANGS_BEREIT:
				PetriNetzBandEins::SynBandEins::getInstance()->inkrementSynUebergabeBereit();
				break;
		}
//		MsgSendPulse(dispatcherConnectionID, SIGEV_PULSE_PRIO_INHERIT, SERIAL_PULSE_CODE, nachricht);
	}
}
Example #30
0
result_t Thread::start ()
{
    TAutoLock<Mutex> lock(m_threadMutex);

    // If the thread is already started
    if ( !isStopped() )
    {
        ex_warning ( "Thread(%s) start failed: the thread already started.", m_name.c_str() );
        return EResult::failed;
    }

    // start the thread
    uint threadID; 
    m_handle = (void*) _beginthreadex( 0,                                   // security
                                       m_stackSize,                         // stack size
                                       _private::ThreadRunCallback,
                                       this,                                // ThreadRunCallback arg_list
                                       CREATE_SUSPENDED,                    // create suspended.
                                       &threadID );
    // error creating thread.
    if ( m_handle == NULL )
    {
        ex_error ( "Thread(%s) start failed: the thread can't be create.", m_name.c_str() );
        return EResult::create_failed;
    }
    m_ID = threadID;

    // suspend the thread
    m_state = eState_Paused;
    setPriority ((EPriority)m_priority);
    usePriorityBoost (m_usePriorityBoost);
    setName (m_name);

    // now start the thread
    ex_check_return ( resume (true) == EResult::ok, EResult::failed, "failed to start thread %s", m_name.c_str() );
    return EResult::ok;
}