예제 #1
0
//---------------------------------------------------------------
void threadedEncoding::threadedFunction(){
    if(lock()){
        encode(fileName, audioFileName, frameRate,compression,exportAudio);
        unlock();
    }
    stopThread();
}
예제 #2
0
 bool Camera::close() {
     stopThread();
     // for some reason waiting for the thread keeps it from
     // completing, but sleeping then stopping capture is ok.
     ofSleepMillis(100);
     stopCapture();
 }
예제 #3
0
// ----------------------------------------------------------------------------
void ofOpenALSoundPlayer::stop(){
	alSourceStopv(channels,&sources[sources.size()-channels]);
	if(isStreaming){
		setPosition(0);
		stopThread();
	}
}
예제 #4
0
// the principal program sequence
void VisionEngine::start() {
    
	if (!interface_) interface_ = new ConsoleInterface(app_name_.c_str());
	
	if (!interface_->openDisplay(this)) {
		delete interface_;
		interface_ = new ConsoleInterface(app_name_.c_str());
		interface_->openDisplay(this);
	}
	
    if(camera_==NULL ) {
        interface_->displayError("No camera found!");
        return;
    }
    
    if( camera_->startCamera() ) {
        
        initFrameProcessors();
        startThread();
        mainLoop();
        stopThread();
        
    } else interface_->displayError("Could not start camera!");
    
    teardownCamera();
    freeBuffers();
}
예제 #5
0
//--------------------------------------------------------------
// Stops the client thread.  You don't really need to do this ever.
//--------------------------------------------------------------
void mpeClientTCP::stop() {
    out("Quitting.");
    stopThread();
	if(useMainThread){
		ofRemoveListener(ofEvents.draw, this, &mpeClientTCP::draw);
	}
}
//--------------------------------------------------------------
// Stops the client thread.  You don't really need to do this ever.
//--------------------------------------------------------------
void ofxMPEClient::stop() {
    log("Quitting.");
    stopThread();
    if(useMainThread){
        ofRemoveListener(ofEvents().draw, this, &ofxMPEClient::draw);
    }
}
//-------------------------------------------------
void ofThread::waitForThread(bool callStopThread, long milliseconds){
	if(!threadDone){
		// tell thread to stop
        if(callStopThread){
            stopThread();
		}

		// wait for the thread to finish
        if(isCurrentThread()){
			return; // waitForThread should only be called outside thread
		}

        if (INFINITE_JOIN_TIMEOUT == milliseconds){
			if(thread.joinable()){
				try{
					thread.join();
				}catch(...){}
			}
        }else{
            // Wait for "joinWaitMillis" milliseconds for thread to finish
            std::unique_lock<std::mutex> lck(mutex);
            if(!threadDone && condition.wait_for(lck,std::chrono::milliseconds(milliseconds))==std::cv_status::timeout){
				// unable to completely wait for thread
            }
        }
    }
}
예제 #8
0
	void Renderinstance::shutdownRenderer()
	{
		stopThread();
		if (m_pRenderer!=0) delete m_pRenderer; m_pRenderer=0;
		if ((m_pScene!=0) && (m_pScene!=m_pTestscene)) delete m_pScene; m_pScene=0;
		if (m_pTestscene!=0) delete m_pTestscene; m_pTestscene=0;
	}
예제 #9
0
// ----------------------------------------------------------------------------
// Stop the thread and DMX interface
//
DMX_STATUS AbstractDMXDriver::stop() {
    if ( !stopThread() )
        return DMX_ERROR;

    // Disconnect interface
    return dmx_close();
}
예제 #10
0
    //--------------------------------------------------------------
    void threadedClock::stop()
    {

        // Stop thread
        stopThread();

    }
예제 #11
0
//-------------------------------------------------
void ofThread::waitForThread(bool callStopThread, long milliseconds){
	if(thread.isRunning()){
		threadBeingWaitedFor = true;

		// tell thread to stop
		if(callStopThread){
            stopThread();
			ofLogVerbose("ofThread") << "- name: " << getThreadName() << " - Signaled to stop.";
		}

		// wait for the thread to finish
		ofLogVerbose("ofThread") << "- name: " << getThreadName() << " - waiting to stop";

        if(isCurrentThread()){
			ofLogWarning("ofThread") << "- name: " << getThreadName() << " - waitForThread should only be called from outside the this ofThread.";
			return;
		}

        if (INFINITE_JOIN_TIMEOUT == milliseconds){
            thread.join();
        }else{
            // Wait for "joinWaitMillis" milliseconds for thread to finish
            if(!thread.tryJoin(milliseconds)){
                ofLogError("ofThread") << "- name: " << getThreadName() << " - Unable to completely waitForThread.";
            }
        }
    }
}
예제 #12
0
ofxPixelPusherUnit::~ofxPixelPusherUnit() {
    stopThread();
    while (isThreadRunning())
        ;

    udp.Close();
}
예제 #13
0
void ofxColorStream::exit()
{
	stopThread();
	waitForThread();

	stream->stop();
	stream->destroy();
}
예제 #14
0
 void close()
 {
     stop();
     stopThread (6000);
     deviceOpen = false;
     recorder = nullptr;
     player = nullptr;
 }
예제 #15
0
파일: Reactor.cpp 프로젝트: griv/openTSPS
 //--------------------------------------------------------------
 void Reactor::exit(){
     if (context != NULL)
     {
         stopThread();
         libwebsocket_context_destroy(context);
         context = NULL;
     }
 }
예제 #16
0
//-------------------------------------------------------------------
void pbOscReceiver::close()
{
	_cb = 0;
	if ( _threaded ) {
		stopThread();		//TODO - it crashes application!
	}
	//oscReceiver.close();
}
예제 #17
0
NMListener::~NMListener() {
  DBG(__func__ << ": cleanup thread");
  if (isThreadRunning()) {
    signalThreadShouldExit();
    notify();
    stopThread(2000);
  }
}
예제 #18
0
// ----------------------------------------------------------------------------
//
bool AnimationTask::stop()
{
    clearAnimations();

    if ( !stopThread() )
        return false;

    return true;
}
void CryptobullionApplication::startThread()
{
    coreThread = new QThread(this);
    CryptobullionCore *executor = new CryptobullionCore();
    executor->moveToThread(coreThread);

    /*  communication to and from thread */
    connect(executor, SIGNAL(initializeResult(int)), this, SLOT(initializeResult(int)));
    connect(executor, SIGNAL(shutdownResult(int)), this, SLOT(shutdownResult(int)));
    connect(executor, SIGNAL(runawayException(QString)), this, SLOT(handleRunawayException(QString)));
    connect(this, SIGNAL(requestedInitialize()), executor, SLOT(initialize()));
    connect(this, SIGNAL(requestedShutdown()), executor, SLOT(shutdown()));
    /*  make sure executor object is deleted in its own thread */
    connect(this, SIGNAL(stopThread()), executor, SLOT(deleteLater()));
    connect(this, SIGNAL(stopThread()), coreThread, SLOT(quit()));

    coreThread->start();
}
예제 #20
0
void SpeechSystem::destroy()
{
	if (verbose) printf("SpeechSystem::destroy()\n");
	/* calling j_close_stream(recog) at any time will terminate
     recognition and exit j_recognize_stream() */
	j_close_stream(recog);

	stopThread();
}
예제 #21
0
SoundBuffer::~SoundBuffer()
{
	stopThread();

	delete m_nextBufferSegmentFillRequest;
	delete m_nextBufferSegmentFillCompleted;

	delete m_updatingStream;
}
예제 #22
0
// ----------------------------------------------------------------------------
void ofOpenALSoundPlayer::stop(){
	if(sources.empty()) return;
	std::unique_lock<std::mutex> lock(mutex);
	alSourceStopv(channels,&sources[sources.size()-channels]);
	if(isStreaming){
		setPosition(0);
		stopThread();
	}
}
void ListFileProvider::refresh()
{
	stopThread();

	clearItems();

	if ( !paths_.empty() ) 
		startThread();
}
bool ofxNetworkSyncClientState::close(){
	if(isThreadRunning()){
		stopThread();
		waitForThread();
	}
	calibrator.close();
	server = NULL;
	tcpServer = NULL;
}
예제 #25
0
void ofxPS3EyeGrabber::stop()
{
    stopThread();

    if (_cam)
    {
        _cam->stop();
    }
}
//---------------------------------------------------------------------------
void ofxKinect::close(){
	if(isThreadRunning()){
		stopThread();
	}

	usleep(500000); // some time while thread is stopping ...

	//libusb_exit(NULL);
}
예제 #27
0
ofxTCPSyncClient::~ofxTCPSyncClient() {
	stopThread();
	if(bTCP)
		tcpClient.close();
	else{
		udpSender.Close();
		udpReceiver.Close();
	}
}
예제 #28
0
 void close()
 {
     if (isRunning)
     {
         stopThread (2000);
         isRunning = false;
         closeDevices();
     }
 }
예제 #29
0
void ofxMSAThreadedImageSaver::threadedFunction() {
	if(lock()) {
		saveImage(fileName);
		unlock();
	} else {
		printf("ofxMSAThreadedImageSaver - cannot save %s cos I'm locked", fileName.c_str());
	}
	stopThread();
}
예제 #30
0
threadedSerial::~threadedSerial()
{
	if( isThreadRunning() ) { 
		stopThread();
	}
    
//    oscSender.clear();

}