void Generator::done(TypedValue tv) { assert(isRunning()); cellSetNull(m_key); cellSet(*tvToCell(&tv), m_value); setState(State::Done); }
/** * Wykonuje POJEDYNCZĄ instrukcję aż do zakończenia pracy programu. Jeśli tryb gadatliwy został uprzednio włączony, wszystkie informacje o przebeigu pracy są wyświetlane. */ bool PVirtualMachine::executeSingleInstr() { if (verbose) { stream << std::endl << "krok:" << step << "; "; __dev__printConsole(); } bool result = true; // czy operacja została wykonana int ivar; if ( isRunning() ) { PInstructions instruction = movePointerAndGetInstructionToExecute(); if (verbose) { stream << "instr: " << PEnums::instruction(instruction) << std::endl; } // w zależności od tego jaką instrukcję zwróci maszyna kodu switch(instruction) { // wykonaj inną operację używając stosu case pietInstr_special_empty: // pusta instrukcja - głowica przesunięta po białym bloku break; case pietInstr_stack_push: stack->instrPush( block_manager->getCodelBlockCount() ); // połóż na stosie liczbę równą liczbie kodeli w bloku kolorów wskazywanym aktualnie przez głowicę break; case pietInstr_stack_pop: if (stack->hasAtLeastNElements(1)) { ivar = stack->instrPop(); // zdejmuje ze stosu liczbę (i nic z nią nie robi) } else { result = false; } break; case pietInstr_arithm_add: if (stack->hasAtLeastNElements(2)) { stack->instrAdd(); // zdejmuje 2 szczytowe elementy i odkłada ich sumę } else { result = false; } break; case pietInstr_arithm_subtract: if (stack->hasAtLeastNElements(2)) { stack->instrSubtract(); // zdejmuje 2 szczytowe elementy i odkłada ich różnicę } else { result = false; } break; case pietInstr_arithm_multiply: if (stack->hasAtLeastNElements(2)) { stack->instrMultiply(); // zdejmuje 2 szczytowe elementy i odkłada ich iloczyn } else { result = false; } break; case pietInstr_arithm_divide: if (stack->hasAtLeastNElements(2)) { stack->instrDivide(); // zdejmuje 2 szczytowe elementy i odkłada ich iloraz } else { result = false; } break; case pietInstr_arithm_modulo: if (stack->hasAtLeastNElements(2)) { stack->instrModulo(); // zdejmuje 2 szczytowe elementy i odkłada resztę z ich dzielenia } else { result = false; } break; case pietInstr_logic_not: if (stack->hasAtLeastNElements(1)) { stack->instrNot(); // zdejmuje element szczytowy i odkłada 1 (el = 0) lub 0 (el != 0) } else { result = false; } break; case pietInstr_logic_greater: if (stack->hasAtLeastNElements(2)) { stack->instrGreater(); // zdejmuje 2 szczytowe elementy i odkłada 1 (jeśli ostatni większy) lub 0 (przeciwnie) } else { result = false; } break; case pietInstr_runtime_pointer: if (stack->hasAtLeastNElements(1)) { for (int num = stack->instrPop(); num > 0; num--) pointer->toggleDirectionPointer(); } else { result = false; } break; case pietInstr_runtime_switch: if (stack->hasAtLeastNElements(1)) { if (stack->instrPop() % 2) pointer->toggleCodelChooser(); } else { result = false; } break; case pietInstr_stack_duplicate: if (stack->hasAtLeastNElements(1)) { stack->instrDuplicate(); } else { result = false; } break; case pietInstr_stack_roll: if (stack->hasAtLeastNElements(2)) { stack->instrRoll(); } else { result = false; } break; case pietInstr_io_in_number: readNumber(); break; case pietInstr_io_in_char: readChar(); break; case pietInstr_io_out_number: if (stack->hasAtLeastNElements(1)) { console->printNumber(stack->instrPop()); } else { result = false; } break; case pietInstr_io_out_char: if (stack->hasAtLeastNElements(1)) { console->printChar(stack->instrPop()); } else { result = false; } break; case pietInstr_special_terminate: // 8 nieudanych prób przesunięcia głowicy do następnego kodela kończy pracę interpretera if ( !stopMachine() ) { stream << "ERROR: bool PVirtualMachine::executeSingleInstr()" << std::endl; exit(1); } break; default: stream << "ERROR: bool PVirtualMachine::executeSingleInstr()" << std::endl; exit(1); } } else { result = false; } step++; return result; }
bool ShuttleWeapon::canFireWeapon() { return !isRunning(); }
void Timer::stop() { if(isRunning()) { gettimeofday(&mEnd, NULL); mRunning = false; } }
void QgsSvgSelectorLoader::stop() { mCanceled = true; while ( isRunning() ) {} }
void sinTraj::update(){ if(isRunning()){ /*if(timeMove<ofGetElapsedTimef()){ double secondPos=((ofGetElapsedTimeMillis()-startTime)%1000)/1000.; double delay=.005; double ti=(ofGetElapsedTimef()-(timeMove-delay)); timeMove=ofGetElapsedTimef()+delay; double yPos=pt.pos/maxAmp*h/2+y+h/2; //if(!index){ pts.push_front(ofPoint(x+w,yPos)); //} while(pts.size()&&pts[pts.size()-1].x<x) pts.pop_back(); for(unsigned int i=0; i<pts.size(); i++){ //if(abs(pts[i].y-pts[i+1].y)>7) pts[i].y=(pts[i].y+pts[i+1].y)/2; pts[i].x-=ti*(w/seconds); } tickPos-=ti*(w/seconds); if(tickPos<=0) tickPos+=w/numDivs; //index++; //if(index==4) index=0; }*/ /*if(timeMove<ofGetElapsedTimef()){ timeMove=ofGetElapsedTimef()+1/sampleRate; wave.push_front(waveform(amplPercent,ofGetElapsedTimef(),freq,aug)); while(wave.size()>=seconds*sampleRate) wave.pop_back(); index-=(1/sampleRate)*(w/seconds); if(index<=0) index+=w/numDivs; double prevF=0; double augs=0; //if(wave.size()) augs=wave[0].aug; pts.clear(); for(unsigned int i=0; i<wave.size(); i++){ double d=(w/seconds)/sampleRate; for(double j=d*i; j<d*(i+1); j+=4){ double indp=j/(w/seconds)+double((ofGetElapsedTimeMillis()-startTime)%1000)/1000./wave[i].freq; if(prevF!=wave[i].freq){ double ind2=indp; //change the augment value to line up the previous sin wave with the current augs=2*M_PI*(wave[i].freq-prevF)*ind2+augs; prevF=wave[i].freq; // set the previous freq to the current freq } indp*=2*M_PI*wave[i].freq; int pos=sin(indp)*h/2*wave[i].amp; if(!j) cout << pos << " " << double((ofGetElapsedTimeMillis()-startTime)%1000)/1000. << endl; pts.push_front(ofPoint(x+j,y+h/2+pos)); //if(pts.size()&&pts[pts.size()-1].x<x) pts.pop_back(); } } lastTime=ofGetElapsedTimef(); }*/ /*if(timeMove<ofGetElapsedTimef()){ timeMove=ofGetElapsedTimef()+1/sampleRate; double ind=double((ofGetElapsedTimeMillis()-int(1000/sampleRate)-startTime)%1000)/1000.; for(double i=0; i<(w/seconds)/sampleRate; i+=2){ double ind2=ind+i/(w/seconds); ind2*=2*M_PI*freq; // multiply the index time by 2*pi*freq double pos=sin(ind2-aug)*h/2; pts.push_front(ofPoint(x+w-(w/seconds)/sampleRate+i,y+h/2+pos)); if(pts.size()&&pts[pts.size()-1].x<x) pts.pop_back(); } }*/ } }
bool AmplifierEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { return( false ); } double outSum = 0.0; const float d = dryLevel(); const float w = wetLevel(); ValueBuffer * volBuf = m_ampControls.m_volumeModel.valueBuffer(); ValueBuffer * panBuf = m_ampControls.m_panModel.valueBuffer(); ValueBuffer * leftBuf = m_ampControls.m_leftModel.valueBuffer(); ValueBuffer * rightBuf = m_ampControls.m_rightModel.valueBuffer(); for( fpp_t f = 0; f < frames; ++f ) { // qDebug( "offset %d, value %f", f, m_ampControls.m_volumeModel.value( f ) ); sample_t s[2] = { buf[f][0], buf[f][1] }; // vol knob if( volBuf ) { s[0] *= volBuf->values()[ f ] * 0.01f; s[1] *= volBuf->values()[ f ] * 0.01f; } else { s[0] *= m_ampControls.m_volumeModel.value() * 0.01f; s[1] *= m_ampControls.m_volumeModel.value() * 0.01f; } // convert pan values to left/right values const float pan = panBuf ? panBuf->values()[ f ] : m_ampControls.m_panModel.value(); const float left1 = pan <= 0 ? 1.0 : 1.0 - pan * 0.01f; const float right1 = pan >= 0 ? 1.0 : 1.0 + pan * 0.01f; // second stage amplification const float left2 = leftBuf ? leftBuf->values()[ f ] : m_ampControls.m_leftModel.value(); const float right2 = rightBuf ? rightBuf->values()[ f ] : m_ampControls.m_rightModel.value(); s[0] *= left1 * left2 * 0.01; s[1] *= right1 * right2 * 0.01; buf[f][0] = d * buf[f][0] + w * s[0]; buf[f][1] = d * buf[f][1] + w * s[1]; outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1]; } checkGate( outSum / frames ); return isRunning(); }
bool TWinService::isRunning() { return isRunning(this->ServiceName); }
/*! *启动mplayer 进程 \param QString & fileName 要播放的资源名称 \param Media_Type type 媒体模式 \param int seek 从指定位置开始播放以秒为单位,当小于2时从头开始播放 */ bool IBMediaControlC::play( const QString & fileName, Media_Type type,int seek) { if( d->m_media_type != type ) { d->m_media_type = MEDIA_TYPE_NONE; } if(isRunning()) { /* if(fileName == d->m_s_current_media && d->m_current_play_state != MEDIA_RUNNING_STATE_STOP)//如果正在播放放当前的文件 { pause(); return true; }*/ stop(); } //获取媒体文件类型,并对视屏文件进行特别处理 //l_type = d->parseMediaTypeByName(fileName); if(d->m_media_type !=type) { d->m_media_type = type; emit sigMediaTypeChanged(type); } // if(type == MEDIA_TYPE_MOVIE) // { // if(!d->m_video_sreen_keeping) // { // d->initVideoFrameBuffer();//打开视屏文件时需要初始化 // } // else // d->m_video_sreen_keeping = false; // } d->playOrPause=true; //设置播放参数 QStringList args = getArglist(); //记忆上次的视屏播放模式 if(true == isFullScreenWindowMode()) { args<<"-fs"; } #ifdef _8925_VERSION if(seek >2) { QString str = QString::number(seek); args<<"-ss"; args<<str; } #endif /*QString s_equalizer =QString("-af"); args<<s_equalizer; s_equalizer= QString("equalizer=")+d->getEqualizerString(); args <<s_equalizer;*/ args << fileName; start(MPLAYER_PATH, args); bool res=waitForStarted(); //小于2s 从头播放 #ifndef _8925_VERSION if(seek >2) { sendCommand(QString("pausing_keep ")+QString("seek ") + QString::number(seek) +QString(" 2")); } #endif return res; }
// tor identity control void updateIdentity() { if (isRunning()) control_.updateIdentity(); }
/****************************************************************************** * Return whether the alarm daemon is monitoring alarms. */ bool Daemon::monitoringAlarms() { bool ok = !mCalendarDisabled && isRunning(); emit mInstance->daemonRunning(ok); return ok; }
void stop() { if (isRunning()) control_.shutdown(); }
// tor instance void start() { if (!isRunning()) launcher_.start("tor.exe -f " + settings_->torrc()); }
void ChatNetworkingIRC::destroyConnection() { irc_disconnect( _p_session ); // wait until thread is shut down while( isRunning() ); }
bool LoginDialog::isSteamRunning() const { auto steamClient = PluginManager::getInstance()->getSteamClientPlugin(); return steamClient && steamClient->isRunning(); }
/** * Discard the current frame, assuming that a PHP exception given in * phpException argument, or C++ exception (phpException == nullptr) * is being thrown. Returns an exception to propagate, or nulltpr * if the VM execution should be resumed. */ ObjectData* tearDownFrame(ActRec*& fp, Stack& stack, PC& pc, ObjectData* phpException) { auto const func = fp->func(); auto const curOp = peek_op(pc); auto const prevFp = fp->sfp(); auto const soff = fp->m_soff; ITRACE(1, "tearDownFrame: {} ({})\n", func->fullName()->data(), func->unit()->filepath()->data()); ITRACE(1, " fp {} prevFp {}\n", implicit_cast<void*>(fp), implicit_cast<void*>(prevFp)); // When throwing from a constructor, we normally want to avoid running the // destructor on an object that hasn't been fully constructed yet. But if // we're unwinding through the constructor's RetC, the constructor has // logically finished and we're unwinding for some internal reason (timeout // or user profiler, most likely). More importantly, fp->m_this may have // already been destructed and/or overwritten due to sharing space with // fp->m_r. if (curOp != OpRetC && fp->hasThis() && fp->getThis()->getVMClass()->getCtor() == func && fp->getThis()->getVMClass()->getDtor()) { /* * Looks like an FPushCtor call, but it could still have been called * directly. Check the fpi region to be sure. */ Offset prevPc; auto outer = g_context->getPrevVMState(fp, &prevPc); if (outer) { auto fe = outer->func()->findPrecedingFPI(prevPc); if (fe && isFPushCtor(outer->func()->unit()->getOp(fe->m_fpushOff))) { fp->getThis()->setNoDestruct(); } } } auto const decRefLocals = [&] { /* * It is possible that locals have already been decref'd. * * Here's why: * * - If a destructor for any of these things throws a php * exception, it's swallowed at the dtor boundary and we keep * running php. * * - If the destructor for any of these things throws a fatal, * it's swallowed, and we set surprise flags to throw a fatal * from now on. * * - If the second case happened and we have to run another * destructor, its enter hook will throw, but it will be * swallowed again. * * - Finally, the exit hook for the returning function can * throw, but this happens last so everything is destructed. * * - When that happens, exit hook sets localsDecRefd flag. */ if (!fp->localsDecRefd()) { try { // Note that we must convert locals and the $this to // uninit/zero during unwind. This is because a backtrace // from another destructing object during this unwind may try // to read them. frame_free_locals_unwind(fp, func->numLocals(), phpException); } catch (...) {} } }; if (LIKELY(!fp->resumed())) { decRefLocals(); if (UNLIKELY(func->isAsyncFunction()) && phpException && !fp->isFCallAwait()) { // If in an eagerly executed async function, wrap the user exception // into a failed StaticWaitHandle and return it to the caller. auto const waitHandle = c_StaticWaitHandle::CreateFailed(phpException); phpException = nullptr; stack.ndiscard(func->numSlotsInFrame()); stack.ret(); assert(stack.topTV() == &fp->m_r); cellCopy(make_tv<KindOfObject>(waitHandle), fp->m_r); } else { // Free ActRec. stack.ndiscard(func->numSlotsInFrame()); stack.discardAR(); } } else if (func->isAsyncFunction()) { auto const waitHandle = frame_afwh(fp); if (phpException) { // Handle exception thrown by async function. decRefLocals(); waitHandle->fail(phpException); phpException = nullptr; } else if (waitHandle->isRunning()) { // Let the C++ exception propagate. If the current frame represents async // function that is running, mark it as abruptly interrupted. Some opcodes // like Await may change state of the async function just before exit hook // decides to throw C++ exception. decRefLocals(); waitHandle->failCpp(); } } else if (func->isAsyncGenerator()) { auto const gen = frame_async_generator(fp); if (phpException) { // Handle exception thrown by async generator. decRefLocals(); auto eagerResult = gen->fail(phpException); phpException = nullptr; if (eagerResult) { stack.pushObjectNoRc(eagerResult); } } else if (gen->isEagerlyExecuted() || gen->getWaitHandle()->isRunning()) { // Fail the async generator and let the C++ exception propagate. decRefLocals(); gen->failCpp(); } } else if (func->isNonAsyncGenerator()) { // Mark the generator as finished. decRefLocals(); frame_generator(fp)->fail(); } else { not_reached(); } /* * At the final ActRec in this nesting level. */ if (UNLIKELY(!prevFp)) { pc = nullptr; fp = nullptr; return phpException; } assert(stack.isValidAddress(reinterpret_cast<uintptr_t>(prevFp)) || prevFp->resumed()); auto const prevOff = soff + prevFp->func()->base(); pc = prevFp->func()->unit()->at(prevOff); fp = prevFp; return phpException; }
bool DelayEffect::processAudioBuffer( sampleFrame* buf, const fpp_t frames ) { if( !isEnabled() || !isRunning () ) { return( false ); } double outSum = 0.0; const float sr = Engine::mixer()->processingSampleRate(); const float d = dryLevel(); const float w = wetLevel(); sample_t dryS[2]; float lPeak = 0.0; float rPeak = 0.0; float length = m_delayControls.m_delayTimeModel.value(); float amplitude = m_delayControls.m_lfoAmountModel.value() * sr; float lfoTime = 1.0 / m_delayControls.m_lfoTimeModel.value(); float feedback = m_delayControls.m_feedbackModel.value(); ValueBuffer *lengthBuffer = m_delayControls.m_delayTimeModel.valueBuffer(); ValueBuffer *feedbackBuffer = m_delayControls.m_feedbackModel.valueBuffer(); ValueBuffer *lfoTimeBuffer = m_delayControls.m_lfoTimeModel.valueBuffer(); ValueBuffer *lfoAmountBuffer = m_delayControls.m_lfoAmountModel.valueBuffer(); int lengthInc = lengthBuffer ? 1 : 0; int amplitudeInc = lfoAmountBuffer ? 1 : 0; int lfoTimeInc = lfoTimeBuffer ? 1 : 0; int feedbackInc = feedbackBuffer ? 1 : 0; float *lengthPtr = lengthBuffer ? &( lengthBuffer->values()[ 0 ] ) : &length; float *amplitudePtr = lfoAmountBuffer ? &( lfoAmountBuffer->values()[ 0 ] ) : &litude; float *lfoTimePtr = lfoTimeBuffer ? &( lfoTimeBuffer->values()[ 0 ] ) : &lfoTime; float *feedbackPtr = feedbackBuffer ? &( feedbackBuffer->values()[ 0 ] ) : &feedback; if( m_delayControls.m_outGainModel.isValueChanged() ) { m_outGain = dbfsToAmp( m_delayControls.m_outGainModel.value() ); } int sampleLength; for( fpp_t f = 0; f < frames; ++f ) { dryS[0] = buf[f][0]; dryS[1] = buf[f][1]; m_delay->setFeedback( *feedbackPtr ); m_lfo->setFrequency( *lfoTimePtr ); sampleLength = *lengthPtr * Engine::mixer()->processingSampleRate(); m_currentLength = sampleLength; m_delay->setLength( m_currentLength + ( *amplitudePtr * ( float )m_lfo->tick() ) ); m_delay->tick( buf[f] ); buf[f][0] *= m_outGain; buf[f][1] *= m_outGain; lPeak = buf[f][0] > lPeak ? buf[f][0] : lPeak; rPeak = buf[f][1] > rPeak ? buf[f][1] : rPeak; buf[f][0] = ( d * dryS[0] ) + ( w * buf[f][0] ); buf[f][1] = ( d * dryS[1] ) + ( w * buf[f][1] ); outSum += buf[f][0]*buf[f][0] + buf[f][1]*buf[f][1]; lengthPtr += lengthInc; amplitudePtr += amplitudeInc; lfoTimePtr += lfoTimeInc; feedbackPtr += feedbackInc; } checkGate( outSum / frames ); m_delayControls.m_outPeakL = lPeak; m_delayControls.m_outPeakR = rPeak; return isRunning(); }
bool AudioInput::isAlive() const { return isRunning(); }
void SoundInThread::setInputDevice(int n) //setInputDevice() { if (isRunning()) return; this->m_nDevIn=n; }
int LLProcessLauncher::launch(void) { // If there was already a process associated with this object, kill it. kill(); orphan(); int result = 0; int current_wd = -1; // create an argv vector for the child process const char ** fake_argv = new const char *[mLaunchArguments.size() + 2]; // 1 for the executable path, 1 for the NULL terminator int i = 0; // add the executable path fake_argv[i++] = mExecutable.c_str(); // and any arguments for(int j=0; j < mLaunchArguments.size(); j++) fake_argv[i++] = mLaunchArguments[j].c_str(); // terminate with a null pointer fake_argv[i] = NULL; if(!mWorkingDir.empty()) { // save the current working directory current_wd = ::open(".", O_RDONLY); // and change to the one the child will be executed in if (::chdir(mWorkingDir.c_str())) { // chdir failed } } // flush all buffers before the child inherits them ::fflush(NULL); pid_t id = vfork(); if(id == 0) { // child process ::execv(mExecutable.c_str(), (char * const *)fake_argv); // If we reach this point, the exec failed. // Use _exit() instead of exit() per the vfork man page. _exit(0); } // parent process if(current_wd >= 0) { // restore the previous working directory if (::fchdir(current_wd)) { // chdir failed } ::close(current_wd); } delete[] fake_argv; mProcessID = id; // At this point, the child process will have been created (since that's how vfork works -- the child borrowed our execution context until it forked) // If the process doesn't exist at this point, the exec failed. if(!isRunning()) { result = -1; } return result; }
void CSimpleTaskPanel::UpdateTaskSelectionList(bool reskin) { wxLogTrace(wxT("Function Start/End"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Function Begin")); int i, j, count, newIcon; TaskSelectionData *selData; RESULT* result; RESULT* ctrlResult; PROJECT* project; std::vector<bool>is_alive; bool needRefresh = false; wxString resname; CMainDocument* pDoc = wxGetApp().GetDocument(); CSkinSimple* pSkinSimple = wxGetApp().GetSkinManager()->GetSimple(); static bool bAlreadyRunning = false; wxASSERT(pDoc); wxASSERT(pSkinSimple); wxASSERT(wxDynamicCast(pSkinSimple, CSkinSimple)); if (bAlreadyRunning) { return; } bAlreadyRunning = true; count = m_TaskSelectionCtrl->GetCount(); // Mark all inactive (this lets us loop only once) for (i=0; i<count; ++i) { is_alive.push_back(false); } // First update existing entries and add new ones for(i = 0; i < (int) pDoc->results.results.size(); i++) { bool found = false; result = pDoc->result(i); // only check tasks that are active if ( result == NULL || !result->active_task ) { continue; } resname = wxEmptyString; #if SELECTBYRESULTNAME resname = wxString::FromUTF8(result->name); #else // SELECTBYRESULTNAME GetApplicationAndProjectNames(result, &resname, NULL); #endif // SELECTBYRESULTNAME // loop through the items already in Task Selection Control to find this result count = m_TaskSelectionCtrl->GetCount(); for(j = 0; j < count; ++j) { selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(j); if (!strcmp(result->name, selData->result_name) && !strcmp(result->project_url, selData->project_url) ) { selData->result = result; found = true; is_alive.at(j) = true; break; // skip out of this loop } } // if it isn't currently in the list then we have a new one! lets add it if (!found) { int alphaOrder; for(j = 0; j < count; ++j) { alphaOrder = (m_TaskSelectionCtrl->GetString(j)).CmpNoCase(resname); #if SORTTASKLIST if (alphaOrder > 0) { break; // Insert the new item here (sorted by item label) } #endif // wxComboBox and wxBitmapComboBox have bugs on Windows when multiple // entries have identical text, so add enough spaces to make each // entry's text unique. if (alphaOrder == 0) { resname.Append((const wxChar *)wxT(" ")); #if !SORTTASKLIST j = -1; // If not sorted, check new name from start for duplicate #endif } } selData = new TaskSelectionData; selData->result = result; strncpy(selData->result_name, result->name, sizeof(selData->result_name)); strncpy(selData->project_url, result->project_url, sizeof(selData->project_url)); selData->dotColor = -1; FindSlideShowFiles(selData); project = pDoc->state.lookup_project(result->project_url); if (project) { selData->project_files_downloaded_time = project->project_files_downloaded_time; } else { selData->project_files_downloaded_time = 0.0; } #if SORTTASKLIST if (j < count) { std::vector<bool>::iterator iter = is_alive.begin(); m_TaskSelectionCtrl->Insert(resname, wxNullBitmap, j, (void*)selData); is_alive.insert(iter+j, true); if (j <= m_CurrentTaskSelection) { ++m_CurrentTaskSelection; m_TaskSelectionCtrl->SetSelection(m_CurrentTaskSelection); } } else #endif { m_TaskSelectionCtrl->Append(resname, wxNullBitmap, (void*)selData); is_alive.push_back(true); } ++count; } // End if (!found) } // End for (i) loop // Check items in descending order so deletion won't change indexes of items yet to be checked for(j = count-1; j >=0; --j) { if(!is_alive.at(j)) { wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Task '%d' no longer alive"), j); selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(j); wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - selData '%p' "), selData); wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - result_name '%s' "), selData->result_name); selData->slideShowFileNames.Clear(); wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Deleting selData")); delete selData; wxLogTrace(wxT("Function Status"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Deleting control data")); // Indicate to Delete() we have cleaned up the Selection Data m_TaskSelectionCtrl->SetClientData(j, NULL); m_TaskSelectionCtrl->Delete(j); if (j == m_CurrentTaskSelection) { int newCount = m_TaskSelectionCtrl->GetCount(); if (m_CurrentTaskSelection < newCount) { // Select the next item if one exists m_TaskSelectionCtrl->SetSelection(m_CurrentTaskSelection); } else if (newCount > 0) { // Select the previous item if one exists m_CurrentTaskSelection = newCount-1; m_TaskSelectionCtrl->SetSelection(m_CurrentTaskSelection); } else { m_CurrentTaskSelection = -1; m_TaskSelectionCtrl->SetSelection(wxNOT_FOUND); } m_bStableTaskInfoChanged = true; needRefresh = true; } else if (j < m_CurrentTaskSelection) { --m_CurrentTaskSelection; m_TaskSelectionCtrl->SetSelection(m_CurrentTaskSelection); } } } if ((m_CurrentTaskSelection >= 0) && !m_bStableTaskInfoChanged) { selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(m_CurrentTaskSelection); project = pDoc->state.lookup_project(selData->project_url); if ( project && (project->project_files_downloaded_time > selData->project_files_downloaded_time) ) { FindSlideShowFiles(selData); selData->project_files_downloaded_time = project->project_files_downloaded_time; } } count = m_TaskSelectionCtrl->GetCount(); for(j = 0; j < count; ++j) { selData = (TaskSelectionData*)m_TaskSelectionCtrl->GetClientData(j); ctrlResult = selData->result; if (Suspended() || ctrlResult->suspended_via_gui || ctrlResult->project_suspended_via_gui) { newIcon = suspendedIcon; } else if (isRunning(ctrlResult)) { newIcon = runningIcon; } else if (ctrlResult->scheduler_state == CPU_SCHED_PREEMPTED) { newIcon = waitingIcon; } else { newIcon = suspendedIcon; } if (reskin || (newIcon != selData->dotColor)) { switch (newIcon) { case runningIcon: m_TaskSelectionCtrl->SetItemBitmap(j, *pSkinSimple->GetWorkunitRunningImage()->GetBitmap()); break; case waitingIcon: m_TaskSelectionCtrl->SetItemBitmap(j, *pSkinSimple->GetWorkunitWaitingImage()->GetBitmap()); break; case suspendedIcon: m_TaskSelectionCtrl->SetItemBitmap(j, *pSkinSimple->GetWorkunitSuspendedImage()->GetBitmap()); break; } selData->dotColor = newIcon; needRefresh = true; } } if (needRefresh) { m_TaskSelectionCtrl->Refresh(); } bAlreadyRunning = false; wxLogTrace(wxT("Function Start/End"), wxT("CSimpleTaskPanel::UpdateTaskSelectionList - Function End")); }
void PanoramaTracker::run() { while (isRunning() && m_scaled.size() <= MAX_TRACKER_FRAMES) { QScopedPointer<QtCamGstSample> sample(m_input->sample()); if (!sample) { continue; } if (!Tracker::isInitialized()) { QSize size = QSize(sample->width(), sample->height()); int m_width = size.width() > 720 ? size.width() / 8 : size.width() / 4; int m_height = size.width() > 720 ? size.height() / 8 : size.height() / 4; m_inputSize = size; // TODO: This should be 5.0 but we fail to stitch sometimes if we set it to 5 if (!Tracker::initialize(m_width, m_height, 2.0f)) { emit error(Panorama::ErrorTrackerInit); return; } } // Now we can process the sample: const guint8 *src = sample->data(); QScopedArrayPointer<guint8> dst(new guint8[m_inputSize.width() * m_inputSize.height() * 3 / 2]); enum libyuv::FourCC fmt; switch (sample->format()) { case GST_VIDEO_FORMAT_UYVY: fmt = libyuv::FOURCC_UYVY; break; default: qCritical() << "Unsupported color format"; emit error(Panorama::ErrorTrackerFormat); return; } guint8 *y = dst.data(), *u = y + m_inputSize.width() * m_inputSize.height(), *v = u + m_inputSize.width()/2 * m_inputSize.height()/2; if (ConvertToI420(src, sample->size(), y, m_inputSize.width(), u, m_inputSize.width() / 2, v, m_inputSize.width() / 2, 0, 0, m_inputSize.width(), m_inputSize.height(), m_inputSize.width(), m_inputSize.height(), libyuv::kRotate0, fmt) != 0) { emit error(Panorama::ErrorTrackerConvert); return; } QScopedArrayPointer<guint8> scaled(new guint8[m_width * m_height * 3 / 2]); guint8 *ys = scaled.data(), *us = ys + m_width * m_height, *vs = us + m_width/2 * m_height/2; // Now scale: // No need for error checking because the function always returns 0 libyuv::I420Scale(y, m_inputSize.width(), u, m_inputSize.width()/2, v, m_inputSize.width()/2, m_inputSize.width(), m_inputSize.height(), ys, m_width, us, m_width/2, vs, m_width/2, m_width, m_height, libyuv::kFilterBilinear); int err = addFrame(scaled.data()); if (err >= 0) { m_scaled.push_back(scaled.take()); m_frames.push_back(dst.take()); emit frameCountChanged(); } } }
bool LadspaEffect::processAudioBuffer( sampleFrame * _buf, const fpp_t _frames ) { m_pluginMutex.lock(); if( !isOkay() || dontRun() || !isRunning() || !isEnabled() ) { m_pluginMutex.unlock(); return( false ); } int frames = _frames; sampleFrame * o_buf = NULL; if( m_maxSampleRate < engine::mixer()->processingSampleRate() ) { o_buf = _buf; _buf = new sampleFrame[_frames]; sampleDown( o_buf, _buf, m_maxSampleRate ); frames = _frames * m_maxSampleRate / engine::mixer()->processingSampleRate(); } // Copy the LMMS audio buffer to the LADSPA input buffer and initialize // the control ports. Need to change this to handle non-in-place-broken // plugins--would speed things up to use the same buffer for both // LMMS and LADSPA. ch_cnt_t channel = 0; for( ch_cnt_t proc = 0; proc < processorCount(); ++proc ) { for( int port = 0; port < m_portCount; ++port ) { port_desc_t * pp = m_ports.at( proc ).at( port ); switch( pp->rate ) { case CHANNEL_IN: for( fpp_t frame = 0; frame < frames; ++frame ) { pp->buffer[frame] = _buf[frame][channel]; } ++channel; break; case AUDIO_RATE_INPUT: pp->value = static_cast<LADSPA_Data>( pp->control->value() / pp->scale ); // This only supports control rate ports, so the audio rates are // treated as though they were control rate by setting the // port buffer to all the same value. for( fpp_t frame = 0; frame < frames; ++frame ) { pp->buffer[frame] = pp->value; } break; case CONTROL_RATE_INPUT: if( pp->control == NULL ) { break; } pp->value = static_cast<LADSPA_Data>( pp->control->value() / pp->scale ); pp->buffer[0] = pp->value; break; case CHANNEL_OUT: case AUDIO_RATE_OUTPUT: case CONTROL_RATE_OUTPUT: break; default: break; } } } // Process the buffers. for( ch_cnt_t proc = 0; proc < processorCount(); ++proc ) { (m_descriptor->run)( m_handles[proc], frames ); } // Copy the LADSPA output buffers to the LMMS buffer. double out_sum = 0.0; channel = 0; const float d = dryLevel(); const float w = wetLevel(); for( ch_cnt_t proc = 0; proc < processorCount(); ++proc ) { for( int port = 0; port < m_portCount; ++port ) { port_desc_t * pp = m_ports.at( proc ).at( port ); switch( pp->rate ) { case CHANNEL_IN: case AUDIO_RATE_INPUT: case CONTROL_RATE_INPUT: break; case CHANNEL_OUT: for( fpp_t frame = 0; frame < frames; ++frame ) { _buf[frame][channel] = d * _buf[frame][channel] + w * pp->buffer[frame]; out_sum += _buf[frame][channel] * _buf[frame][channel]; } ++channel; break; case AUDIO_RATE_OUTPUT: case CONTROL_RATE_OUTPUT: break; default: break; } } } if( o_buf != NULL ) { sampleBack( _buf, o_buf, m_maxSampleRate ); delete[] _buf; } checkGate( out_sum / frames ); bool is_running = isRunning(); m_pluginMutex.unlock(); return( is_running ); }
WebThread& ScriptStreamerThread::platformThread() { if (!isRunning()) m_thread = adoptPtr(Platform::current()->createThread("ScriptStreamerThread")); return *m_thread; }
QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths, QStringList *files, QStringList *directories) { QStringList p = paths; { QMutexLocker locker(&mutex); QMutableListIterator<QString> it(p); while (it.hasNext()) { QString path = it.next(); int fd; #if defined(O_EVTONLY) fd = qt_safe_open(QFile::encodeName(path), O_EVTONLY); #else fd = qt_safe_open(QFile::encodeName(path), O_RDONLY); #endif if (fd == -1) { perror("QKqueueFileSystemWatcherEngine::addPaths: open"); continue; } if (fd >= (int)FD_SETSIZE / 2 && fd < (int)FD_SETSIZE) { int fddup = fcntl(fd, F_DUPFD, FD_SETSIZE); if (fddup != -1) { ::close(fd); fd = fddup; } } fcntl(fd, F_SETFD, FD_CLOEXEC); QT_STATBUF st; if (QT_FSTAT(fd, &st) == -1) { perror("QKqueueFileSystemWatcherEngine::addPaths: fstat"); ::close(fd); continue; } int id = (S_ISDIR(st.st_mode)) ? -fd : fd; if (id < 0) { if (directories->contains(path)) { ::close(fd); continue; } } else { if (files->contains(path)) { ::close(fd); continue; } } struct kevent kev; EV_SET(&kev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_CLEAR, NOTE_DELETE | NOTE_WRITE | NOTE_EXTEND | NOTE_ATTRIB | NOTE_RENAME | NOTE_REVOKE, 0, 0); if (kevent(kqfd, &kev, 1, 0, 0, 0) == -1) { perror("QKqueueFileSystemWatcherEngine::addPaths: kevent"); ::close(fd); continue; } it.remove(); if (id < 0) { DEBUG() << "QKqueueFileSystemWatcherEngine: added directory path" << path; directories->append(path); } else { DEBUG() << "QKqueueFileSystemWatcherEngine: added file path" << path; files->append(path); } pathToID.insert(path, id); idToPath.insert(id, path); } } if (!isRunning()) start(); else write(kqpipe[1], "@", 1); return p; }
void SerialPortListener::stop() { m_stop = true; while(isRunning()) ; }
qword sys_isRunning(char * name, qword ret, qword rcx, qword r8, qword r9) { int * pret = (int*) ret; *pret = isRunning(name); return 0; }
bool RemotePlugin::process( const sampleFrame * _in_buf, sampleFrame * _out_buf ) { const fpp_t frames = Engine::mixer()->framesPerPeriod(); if( m_failed || !isRunning() ) { if( _out_buf != NULL ) { BufferManager::clear( _out_buf, frames ); } return false; } if( m_shm == NULL ) { // m_shm being zero means we didn't initialize everything so // far so process one message each time (and hope we get // information like SHM-key etc.) until we process messages // in a later stage of this procedure if( m_shmSize == 0 ) { lock(); fetchAndProcessAllMessages(); unlock(); } if( _out_buf != NULL ) { BufferManager::clear( _out_buf, frames ); } return false; } memset( m_shm, 0, m_shmSize ); ch_cnt_t inputs = qMin<ch_cnt_t>( m_inputCount, DEFAULT_CHANNELS ); if( _in_buf != NULL && inputs > 0 ) { if( m_splitChannels ) { for( ch_cnt_t ch = 0; ch < inputs; ++ch ) { for( fpp_t frame = 0; frame < frames; ++frame ) { m_shm[ch * frames + frame] = _in_buf[frame][ch]; } } } else if( inputs == DEFAULT_CHANNELS ) { memcpy( m_shm, _in_buf, frames * BYTES_PER_FRAME ); } else { sampleFrame * o = (sampleFrame *) m_shm; for( ch_cnt_t ch = 0; ch < inputs; ++ch ) { for( fpp_t frame = 0; frame < frames; ++frame ) { o[frame][ch] = _in_buf[frame][ch]; } } } } lock(); sendMessage( IdStartProcessing ); if( m_failed || _out_buf == NULL || m_outputCount == 0 ) { unlock(); return false; } waitForMessage( IdProcessingDone ); unlock(); const ch_cnt_t outputs = qMin<ch_cnt_t>( m_outputCount, DEFAULT_CHANNELS ); if( m_splitChannels ) { for( ch_cnt_t ch = 0; ch < outputs; ++ch ) { for( fpp_t frame = 0; frame < frames; ++frame ) { _out_buf[frame][ch] = m_shm[( m_inputCount+ch )* frames + frame]; } } } else if( outputs == DEFAULT_CHANNELS ) { memcpy( _out_buf, m_shm + m_inputCount * frames, frames * BYTES_PER_FRAME ); } else { sampleFrame * o = (sampleFrame *) ( m_shm + m_inputCount*frames ); // clear buffer, if plugin didn't fill up both channels BufferManager::clear( _out_buf, frames ); for( ch_cnt_t ch = 0; ch < qMin<int>( DEFAULT_CHANNELS, outputs ); ++ch ) { for( fpp_t frame = 0; frame < frames; ++frame ) { _out_buf[frame][ch] = o[frame][ch]; } } } return true; }
mrcGraphicsItem::~mrcGraphicsItem() { //qDebug()<<"mrcGraphicsItem "<<pX<<" "<<pY<<" released."; if(isRunning()) wait(); }
bool ConsoleProcess::start(const QString &program, const QString &args) { if (isRunning()) return false; d->m_errorString.clear(); d->m_error = QProcess::UnknownError; QtcProcess::SplitError perr; QtcProcess::Arguments pargs = QtcProcess::prepareArgs(args, &perr, HostOsInfo::hostOs(), &d->m_environment, &d->m_workingDir); QString pcmd; if (perr == QtcProcess::SplitOk) { pcmd = program; } else { if (perr != QtcProcess::FoundMeta) { emitError(QProcess::FailedToStart, tr("Quoting error in command.")); return false; } if (d->m_mode == Debug) { // FIXME: QTCREATORBUG-2809 emitError(QProcess::FailedToStart, tr("Debugging complex shell commands in a terminal" " is currently not supported.")); return false; } pcmd = QLatin1String("/bin/sh"); pargs = QtcProcess::Arguments::createUnixArgs(QStringList() << QLatin1String("-c") << (QtcProcess::quoteArg(program) + QLatin1Char(' ') + args)); } QtcProcess::SplitError qerr; QtcProcess::Arguments xtermArgs = QtcProcess::prepareArgs(terminalEmulator(d->m_settings), &qerr, HostOsInfo::hostOs(), &d->m_environment, &d->m_workingDir); if (qerr != QtcProcess::SplitOk) { emitError(QProcess::FailedToStart, qerr == QtcProcess::BadQuoting ? tr("Quoting error in terminal command.") : tr("Terminal command may not be a shell command.")); return false; } const QString err = stubServerListen(); if (!err.isEmpty()) { emitError(QProcess::FailedToStart, msgCommChannelFailed(err)); return false; } d->m_environment.unset(QLatin1String("TERM")); QStringList env = d->m_environment.toStringList(); if (!env.isEmpty()) { d->m_tempFile = new QTemporaryFile(); if (!d->m_tempFile->open()) { stubServerShutdown(); emitError(QProcess::FailedToStart, msgCannotCreateTempFile(d->m_tempFile->errorString())); delete d->m_tempFile; d->m_tempFile = 0; return false; } QByteArray contents; foreach (const QString &var, env) { QByteArray l8b = var.toLocal8Bit(); contents.append(l8b.constData(), l8b.size() + 1); }