Example #1
0
void SpeechSystem::setup()
{
	// ewwww
	jconf = j_config_load_file_new(const_cast<char*>(jconf_filename.c_str()));

	/* 2. create recognition instance according to the jconf */
	/* it loads models, setup final parameters, build lexicon
     and set up work area for recognition */
	recog = j_create_instance_from_jconf(jconf);
	if (recog == NULL)
	{
		fprintf(stderr, "Error in startup\n");
		return;
	}

	/*********************/
	/* Register callback */
	/*********************/
	/* register result callback functions */
	callback_add(recog, CALLBACK_EVENT_SPEECH_READY, recready, this);
	callback_add(recog, CALLBACK_EVENT_SPEECH_START, recstart, this);
	callback_add(recog, CALLBACK_RESULT, recdone, this);

	/**************************/
	/* Initialize audio input */
	/**************************/
	/* initialize audio input device */
	/* ad-in thread starts at this time for microphone */
	if (j_adin_init(recog) == FALSE) {    /* error */
		return;
	}

//#ifdef JULIUS_DEBUG
	/* output system information to log */
	j_recog_info(recog);
//#endif

	/***********************************/
	/* Open input stream and recognize */
	/***********************************/
	/* raw speech input (microphone etc.) */

	switch(j_open_stream(recog, NULL)) {
		case 0:			/* succeeded */
			break;
		case -1:      		/* error */
			fprintf(stderr, "error in input stream\n");
			return;
		case -2:			/* end of recognition process */
			fprintf(stderr, "failed to begin input stream\n");
			return;
	}

	startThread(true, false); // blocking, verbose
}
Example #2
0
void EntityScriptServer::run() {
    // make sure we request our script once the agent connects to the domain
    auto nodeList = DependencyManager::get<NodeList>();

    ThreadedAssignment::commonInit(ENTITY_SCRIPT_SERVER_LOGGING_NAME, NodeType::EntityScriptServer);

    // Setup MessagesClient
    auto messagesClient = DependencyManager::set<MessagesClient>();
    messagesClient->startThread();

    DomainHandler& domainHandler = DependencyManager::get<NodeList>()->getDomainHandler();
    connect(&domainHandler, &DomainHandler::settingsReceived, this, &EntityScriptServer::handleSettings);

    // make sure we hear about connected nodes so we can grab an ATP script if a request is pending
    connect(nodeList.data(), &LimitedNodeList::nodeActivated, this, &EntityScriptServer::nodeActivated);
    connect(nodeList.data(), &LimitedNodeList::nodeKilled, this, &EntityScriptServer::nodeKilled);

    nodeList->addSetOfNodeTypesToNodeInterestSet({
        NodeType::Agent, NodeType::AudioMixer, NodeType::AvatarMixer,
        NodeType::EntityServer, NodeType::MessagesMixer, NodeType::AssetServer
    });

    // Setup Script Engine
    resetEntitiesScriptEngine();

    auto entityScriptingInterface = DependencyManager::get<EntityScriptingInterface>();
    entityScriptingInterface->init();

    _entityViewer.init();
    
    // setup the JSON filter that asks for entities with a non-default serverScripts property
    QJsonObject queryJSONParameters;
    queryJSONParameters[EntityJSONQueryProperties::SERVER_SCRIPTS_PROPERTY] = EntityQueryFilterSymbol::NonDefault;

    QJsonObject queryFlags;

    queryFlags[EntityJSONQueryProperties::INCLUDE_ANCESTORS_PROPERTY] = true;
    queryFlags[EntityJSONQueryProperties::INCLUDE_DESCENDANTS_PROPERTY] = true;

    queryJSONParameters[EntityJSONQueryProperties::FLAGS_PROPERTY] = queryFlags;
    
    // setup the JSON parameters so that OctreeQuery does not use a frustum and uses our JSON filter
    _entityViewer.getOctreeQuery().setUsesFrustum(false);
    _entityViewer.getOctreeQuery().setJSONParameters(queryJSONParameters);

    entityScriptingInterface->setEntityTree(_entityViewer.getTree());

    DependencyManager::set<AssignmentParentFinder>(_entityViewer.getTree());


    auto tree = _entityViewer.getTree().get();
    connect(tree, &EntityTree::deletingEntity, this, &EntityScriptServer::deletingEntity, Qt::QueuedConnection);
    connect(tree, &EntityTree::addingEntity, this, &EntityScriptServer::addingEntity, Qt::QueuedConnection);
    connect(tree, &EntityTree::entityServerScriptChanging, this, &EntityScriptServer::entityServerScriptChanging, Qt::QueuedConnection);
}
int main(int arg, char** argv) {

    sbinder_start();

    int ret;

    ret = cb_add(_cb_callback);
    printf("main 1ret = %d\n",ret);

    ret = cb_add(_cb_callback1);
    printf("main 2ret = %d\n",ret);

    ret = cb_invoke(10);
    printf("main 3ret = %d\n",ret);

    sleep(5);

    ret = cb_invoke(11);
    printf("main 4ret = %d\n",ret);

    sleep(5);

    ret = cb_remove(_cb_callback1);
    printf("main 5ret = %d\n",ret);


	startThread(13);
    printf("main 6ret = %d\n",ret);
	startThread(14);
    printf("main 7ret = %d\n",ret);
	startThread(15);
    printf("main 8ret = %d\n",ret);
	startThread(16);
    printf("main 9ret = %d\n",ret);
	startThread(17);
    printf("main 10ret = %d\n",ret);

    ret = cb_invoke(12);
    printf("main 11ret = %d\n",ret);

    return sbinder_serv();
}
Example #4
0
// メッセージを投稿するタスク(別スレッド)を開始する
void CSCConnection::startPostMessageTask(const IUser* user,
        const wxString& message, const wxString& channel)
{
    CSCPostMessageTask* postMessageTask = new CSCPostMessageTask();
    postMessageTask->init(this, user->getBasic());
    postMessageTask->setChannel(channel);
    postMessageTask->setMessage(message);

    // 別スレッドでの開始
    startThread(postMessageTask);
}
void CtrlrUpdateManager::timerCallback()
{
	stopTimer();

	if ((bool)owner.getProperty(Ids::ctrlrCheckForUpdates) == false)
	{
		return;
	}

	startThread();
}
//--------------------------------------------------------------
void
GeoData::setup()
{
#ifdef USE_OGR
	OGRRegisterAll();
	
    datasource = OGRSFDriverRegistrar::Open(dataSourceName.c_str(), FALSE);
#endif

	startThread(true, false); // blocking, non-verbose
}
Example #7
0
// チャンネルのメッセージを取得するタスク(別スレッド)を開始する
void CSCConnection::startGetMessageTask(const IUser* user,
        const wxString& channel)
{
    if (channel != ""){
        CSCGetMessageTask* getMessageTask = new CSCGetMessageTask();
        getMessageTask->init(this, user->getBasic());
        getMessageTask->setChannel(channel);
        // 別スレッドでの開始
        startThread(getMessageTask);
    }
}
void ofxThreadedImage::loadHttpImageThreaded(string url_){
	alpha = 0;
	whatToDo = LOAD_HTTP;
	url = url_;
	pendingTexture = true;
	imageLoaded = false;
	problemLoading = false;
	readyToDraw = false;
	setUseTexture(false);
	startThread(true, false);
}
//--------------------------------------------------------------
bool threadedScanLoader::start(string & _folderName) {

	if (!isThreadRunning() && (_folderName != "")) {
		state		= TH_STATE_LOADING;
		folderName	= _folderName;
		startThread(true, false);  // blocking, verbose
		return true;
	}else{
		return false;
	}
}
void ListFileProvider::init(
	const std::string& type,
	const std::string& paths,
	const std::string& extensions,
	const std::string& includeFolders,
	const std::string& excludeFolders,
	int flags )
{
	stopThread();

	// member variables
	type_ = type;

	flags_ = flags;

	paths_.clear();
	extensions_.clear();
	includeFolders_.clear();
	excludeFolders_.clear();

	std::string pathsL = paths;
	std::replace( pathsL.begin(), pathsL.end(), '/', '\\' );
	StringUtils::vectorFromString( pathsL, paths_ );

	std::string extL = extensions;
	StringUtils::toLowerCase( extL );
	StringUtils::vectorFromString( extL, extensions_ );
	hasImages_ = false;
	for( std::vector<std::string>::iterator i = extensions_.begin();
		i != extensions_.end(); ++i )
	{
		if ( (*i) == "dds" )
		{
			hasImages_ = true;
			break;
		}
	}

	std::string includeFoldersL = includeFolders;
	std::replace( includeFoldersL.begin(), includeFoldersL.end(), '/', '\\' );
	StringUtils::vectorFromString( includeFoldersL, includeFolders_ );

	std::string excludeFoldersL = excludeFolders;
	std::replace( excludeFoldersL.begin(), excludeFoldersL.end(), '/', '\\' );
	StringUtils::vectorFromString( excludeFoldersL, excludeFolders_ );

	StringUtils::filterSpecVector( paths_, excludeFolders_ );

	// clear items and start file-seeking thread
	clearItems();

	if ( !paths_.empty() ) 
		startThread();
}
Example #11
0
void HandJockey::setup()
{
	nite::Status niteRc;
	niteRc = nite::NiTE::initialize();
	if (niteRc != nite::STATUS_OK)
	{
		throw ("NiTE initialization failed\n");
	}

	startThread(false, true);
}
Example #12
0
void Acceptor::block() throw ( ConfigError, RuntimeError )
{   QF_STACK_PUSH( Acceptor::start )

    m_stop = false;
    onConfigure( m_settings );
    onInitialize( m_settings );

    startThread(this);

    QF_STACK_POP
}
Example #13
0
PopupWnd2::PopupWnd2(POPUPDATA2 *ppd, POPUPOPTIONS *theCustomOptions, bool renderOnly)
{
	m_signature = POPUP_OBJECT_SIGNARURE;
	m_textType = TT_NONE;
	m_options = theCustomOptions ? theCustomOptions : &PopupOptions;
	m_hfnText = fonts.text;
	m_hfnTitle = fonts.title;
	updateData(ppd);
	if (!renderOnly)
		startThread();
}
Example #14
0
int Edge305Device::startReadFitnessDirectory(string dataTypeName) {
    if (Log::enabledDbg()) Log::dbg("Starting thread to read fitness dir from garmin device: "+this->displayName);

    this->workType = READFITNESSDIR;

    if (startThread()) {
        return 1;
    }

    return 0;
}
    const String open (const BitArray& inputChannels, const BitArray& outputChannels,
                       double sampleRate, int bufferSizeSamples)
    {
        close();
        lastError = String::empty;

        if (sampleRates.size() == 0 && inputDevice != 0 && outputDevice != 0)
        {
            lastError = "The input and output devices don't share a common sample rate!";
            return lastError;
        }

        currentBufferSizeSamples = bufferSizeSamples <= 0 ? defaultBufferSize : jmax (bufferSizeSamples, minBufferSize);
        currentSampleRate = sampleRate > 0 ? sampleRate : defaultSampleRate;

        if (inputDevice != 0 && ! inputDevice->open (currentSampleRate, inputChannels))
        {
            lastError = "Couldn't open the input device!";
            return lastError;
        }

        if (outputDevice != 0 && ! outputDevice->open (currentSampleRate, outputChannels))
        {
            close();
            lastError = "Couldn't open the output device!";
            return lastError;
        }

        if (inputDevice != 0)
            ResetEvent (inputDevice->clientEvent);
        if (outputDevice != 0)
            ResetEvent (outputDevice->clientEvent);

        startThread (8);
        Thread::sleep (5);

        if (inputDevice != 0 && inputDevice->client != 0)
        {
            latencyIn = inputDevice->latencySamples + inputDevice->actualBufferSize + inputDevice->minBufferSize;
            HRESULT hr = inputDevice->client->Start();
            logFailure (hr); //xxx handle this
        }

        if (outputDevice != 0 && outputDevice->client != 0)
        {
            latencyOut = outputDevice->latencySamples + outputDevice->actualBufferSize + outputDevice->minBufferSize;
            HRESULT hr = outputDevice->client->Start();
            logFailure (hr); //xxx handle this
        }

        isOpen_ = true;
        return lastError;
    }
Example #16
0
void Client::start()
{
    if (!isThreadRunning())
    {
        ofLogVerbose("Client::start") << "Starting thread.";
        startThread(true);   // blocking, verbose
    }
    else
    {
        ofLogVerbose("Client::start") << "New message queued, signalling.";
    }
}
Example #17
0
void FaceTracker::update(ofBaseVideoDraws& video)
{
	if (!isThreadRunning())
	{
		//videoMat = Mat(h, w, CV_8UC3);
		videoMat = toCv(video).clone();
		convertColor(videoMat, grayMat, CV_RGB2GRAY);
		resize(grayMat, graySmallMat, graySmallMat.size());
		
		startThread(true, false);
	}
}
Example #18
0
void mpeClientTCP::retryConnectionLoop(ofEventArgs& e)
{
	float now = ofGetElapsedTimef();
	if(now - lastConnectionAttempt > 1.0){ //retry every second
		if(tcpClient.setup(hostName, serverPort)) {
			//cout << "retry succeeded, removing listener!" << endl;
			ofRemoveListener(ofEvents().update, this, &mpeClientTCP::retryConnectionLoop);
			startThread(true, false);  // blocking, verbose
		}
		lastConnectionAttempt = now;
	}
}
Example #19
0
    void onStart ()
    {
#if RIPPLE_USE_VALIDATORS
        m_journal.info << "Validators starting";

        // Do this late so the sources have a chance to be added.
        m_queue.dispatch (m_context.wrap (bind (
            &ManagerImp::setCheckSources, this)));

        startThread();
#endif
    }
Example #20
0
int Edge305Device::startReadFitnessDetail(string id) {
    if (Log::enabledDbg()) Log::dbg("Starting thread to read fitness detail from garmin device: "+this->displayName+ " Searching for "+id);

    this->workType = READFITNESSDETAIL;
    this->readFitnessDetailId = id;

    if (startThread()) {
        return 1;
    }

    return 0;
}
Example #21
0
int Edge305Device::startReadFromGps() {
    if (Log::enabledDbg()) Log::dbg("Starting thread to read gpx from garmin device: "+this->displayName);

    this->workType = READFROMGPS;
    this->threadState = 1;

    if (startThread()) {
        return 1;
    }

    return 0;
}
Example #22
0
// MAIN THREAD
// virtual
S32 LLQueuedThread::update(U32 max_time_ms)
{
	if (!mStarted)
	{
		if (!mThreaded)
		{
			startThread();
			mStarted = TRUE;
		}
	}
	return updateQueue(max_time_ms);
}
SqliteDatabase::SqliteDatabase (const char* host)
    : Database (host)
    , Thread ("sqlitedb")
    , mWalQ (nullptr)
    , walRunning (false)
{
    startThread ();

    mConnection     = nullptr;
    mAuxConnection  = nullptr;
    mCurrentStmt    = nullptr;
}
void CtrlrPanelMIDISnapshot::handleAsyncUpdate()
{
	gatherSnapshotData();
	startThread();

	startTimer (100);
    if (alertWindow)
    {
        const ScopedLock sl (messageLock);
        alertWindow->setMessage (message);
        alertWindow->enterModalState();
    }
}
Example #25
0
    //--------------------------------------------------------------
    void threadedClock::start( ClockManager * _p)
    {

        // Get parent app
        parent = _p;

        // Initialize note count
        ticks = 0;

        // Start thread -- blocking, venbose
        startThread(true, false);

    }
Example #26
0
//-------------------------------------------------------------------
void pbOscReceiver::setup( int port, bool threaded )		
{
	_threaded = threaded;

	cout << "Starting OSC receiver, port " << port << endl;
	oscReceiver.setup( port );

	if ( _threaded ) {
		startThread( true, false );   //blocking, verbose
	}

	count = 0;
}
ofxThreadedImageLoader::ofxThreadedImageLoader() 
:ofThread()
{
    nextID = 0;
//    Poco::Thread& pocoThread =  getPocoThread();
//    pocoThread.setName("ofxThreadedImageLoader" + ofToString(nextID));
//	
    ofAddListener(ofEvents().update, this, &ofxThreadedImageLoader::update);
	ofAddListener(ofURLResponseEvent(),this,&ofxThreadedImageLoader::urlResponse);
    
    startThread();
    lastUpdate = 0;
}
void ofxCvCheckerboardPreview::setup(int squaresWide, int squaresTall, float squareSize) {
    boardFound = false;
    newBoardToFind = false;

    squarePixelSize = 11;
    calib.setPatternSize(squaresWide, squaresTall);
    calib.setSquareSize(squareSize);
    calib.setSubpixelSize(4);
    boardLastFoundTime = 0;

    startThread(true, false);

}
Example #29
0
int Edge305Device::startReadFitnessData()
{
    if (Log::enabledDbg()) Log::dbg("Starting thread to read from garmin device: "+this->displayName);

    this->workType = READFITNESS;
    this->threadState = 1;

    if (startThread()) {
        return 1;
    }

    return 0;
}
Example #30
0
void Thread::startThread (const int priority)
{
    const RecursiveMutex::ScopedLockType sl (startStopLock);

    if (threadHandle == nullptr)
    {
        threadPriority = priority;
        startThread();
    }
    else
    {
        setPriority (priority);
    }
}