void Compositor::setRecording(bool value) { unsigned int before = recording(); if (!value && mRecorderCounter > 0) mRecorderCounter--; else mRecorderCounter++; if (before != recording()) recordingChanged(); }
void post_execve(long *return_value, syscall_args_t *args) { process_t *process = processes[current->pid]; #if 0 monitor_t *monitor = process->monitor; #endif VVDLOG("execve() returned"); #if 0 if (*return_value >= 0) { VDLOG("Notifying user space of COUNTER_PATCH"); /* Patch process image */ down(&(monitor->data_write_complete_sem)); monitor->ready_data.type = COUNTER_PATCH; monitor->ready_data.size = 0; up(&(monitor->data_available_sem)); kill_proc(current->pid, SIGSTOP, 1); /* Wait for patch to complete */ down(&(monitor->data_write_complete_sem)); monitor->ready_data.type = NO_DATA; up(&(monitor->data_available_sem)); } #endif if (recording(process)) { write_syscall_log_entry(__NR_execve, *return_value, NULL, 0); } }
int snd_StopRecording(void) { { Synchronized<es::Monitor*> method(monitorRecordState); recordState.inProgress = false; } { Synchronized<es::Monitor*> recording(monitorRecording); recordState.bufSizeInBytes = 0; recordState.maxRecordSize = 0; recordState.stereo = 0; recordState.bytesPerSample = 0; recordState.outputBytesPerSample = 0; recordState.dataFormat = 0; recordState.head = NULL; recordState.tail = NULL; recordState.buffer = NULL; recordState.next = NULL; recordState.nextRecordSize = 0; recordState.recorded = 0; recordState.recordSemaIndex = 0; recordState.open = false; delete [] recordState.buffer; } return true; }
void TrainSamplePage::setupUi() { setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); QString title = i18nc("%1 is current page index, %2 is max page index", "Page %1 of %2", m_thisPage, m_maxPage); setTitle(m_name+": "+title); QVBoxLayout *lay = new QVBoxLayout(this); QLabel *desc = new QLabel(i18n("Please record the Text below." "\n\nTip: Leave about one to two seconds \"silence\" before and after you read " "the text for best results.\n"), this); desc->setWordWrap(true); lay->addWidget(desc); if (recorder) recorder->deleteLater(); QList<SimonSound::DeviceConfiguration> forcedDevs; if (m_forcedDevices) forcedDevs = m_forcedDevices->buildDeviceList(); recorder = new RecWidget("", prompt, m_directory+fileName, false, this, forcedDevs); lay->addWidget(recorder); connect(recorder, SIGNAL(recording()), this, SIGNAL(completeChanged())); connect(recorder, SIGNAL(recordingFinished()), this, SIGNAL(completeChanged())); connect(recorder, SIGNAL(sampleDeleted()), this, SIGNAL(completeChanged())); }
void FileRecorder::advance() { if(!recording()) return; int len = _manager.pos() - _oldPos; if(_bufsize < len) { delete[] _buf; _buf = new int16_t[_nchan*len]; _bufsize = len; } int chani = 0; for(unsigned int i = 0; i < _manager.recordingDevices().size(); i++) { if(_manager.recordingDevices()[i].bound) { _manager.getData(i, _oldPos, len, _buf+chani*_bufsize); chani++; } } for(int i = 0; i < len; i++) { for(int j = 0; j < _nchan; j++) put16(_buf[i+j*_bufsize], _file); } _oldPos = _manager.pos(); }
static void bench_record(SkPicture* src, const char* name, SkBBHFactory* bbhFactory) { BenchTimer timer; timer.start(); const int width = src ? src->width() : FLAGS_nullSize; const int height = src ? src->height() : FLAGS_nullSize; for (int i = 0; i < FLAGS_loops; i++) { if (FLAGS_skr) { EXPERIMENTAL::SkRecording recording(width, height); if (NULL != src) { src->draw(recording.canvas()); } // Release and delete the SkPlayback so that recording optimizes its SkRecord. SkDELETE(recording.releasePlayback()); } else { SkPictureRecorder recorder; SkCanvas* canvas = recorder.beginRecording(width, height, bbhFactory, FLAGS_flags); if (NULL != src) { src->draw(canvas); } if (FLAGS_endRecording) { SkAutoTUnref<SkPicture> dst(recorder.endRecording()); } } } timer.end(); const double msPerLoop = timer.fCpu / (double)FLAGS_loops; printf("%f\t%s\n", scale_time(msPerLoop), name); }
void RDHPIRecordStream::record() { if(debug) { printf("RDHPIRecordStream: received record()\n"); } if(!is_open) { return; } if(!is_ready) { recordReady(); } record_started=false; HPI_InStreamReset(hpi_subsys,hpi_stream); HPI_InStreamStart(hpi_subsys,hpi_stream); is_recording=true; is_paused=false; emit isStopped(false); emit recording(); emit stateChanged(card_number,stream_number,0); // Recording if(debug) { printf("RDHPIRecordStream: emitted isStopped(false)\n"); printf("RDHPIRecordStream: emitted recording()\n"); printf("RDHPIRecordStream: emitted stateChanged(%d,%d,RDHPIRecordStream::Recording)\n",card_number,stream_number); } tickClock(); }
void YigMainWindow::record() { if(recordButton->isChecked()) { recordButton->setText("stop"); } else { recordButton->setText("record"); } emit recording(recordButton->isChecked()); }
jboolean Java_org_opalvoip_opal_andsample_AndOPAL_TestAudio(JNIEnv* env, jclass clazz) { PTRACE(1, "AndOPAL", "Testing audio output"); std::auto_ptr<PSoundChannel> player(PSoundChannel::CreateOpenedChannel("*", "voice", PSoundChannel::Player)); if (player.get() == NULL) return false; player->SetBuffers(400, 8); { PTones tones("C:0.2/D:0.2/E:0.2/F:0.2/G:0.2/A:0.2/B:0.2/C5:1.0"); PTRACE(1, "AndOPAL", "Tones using " << tones.GetSize() << " samples, " << PTimeInterval(1000*tones.GetSize()/tones.GetSampleRate()) << " seconds"); PTime then; if (!tones.Write(*player)) return false; PTRACE(1, "AndOPAL", "Audio queued"); player->WaitForPlayCompletion(); PTRACE(1, "AndOPAL", "Finished tone output: " << PTime() - then << " seconds"); } std::auto_ptr<PSoundChannel> recorder(PSoundChannel::CreateOpenedChannel("*", "*", PSoundChannel::Recorder)); if (player.get() == NULL) return false; PShortArray recording(5*recorder->GetSampleRate()); // Five seconds { PTRACE(1, "AndOPAL", "Started recording"); PTime then; if (!recorder->ReadBlock(recording.GetPointer(), recording.GetSize()*sizeof(short))) return false; PTRACE(1, "AndOPAL", "Finished recording " << PTime() - then << " seconds"); } { PTRACE(1, "AndOPAL", "Started play back"); PTime then; if (!player->Write(recording.GetPointer(), recording.GetSize()*sizeof(short))) return false; PTRACE(1, "AndOPAL", "Finished play back " << PTime() - then << " seconds"); } }
nsresult RemotePrintJobParent::PrintPage(const Shmem& aStoredPage) { MOZ_ASSERT(mPrintDeviceContext); nsresult rv = mPrintDeviceContext->BeginPage(); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } std::istringstream recording(std::string(aStoredPage.get<char>(), aStoredPage.Size<char>())); mPrintTranslator->TranslateRecording(recording); rv = mPrintDeviceContext->EndPage(); if (NS_WARN_IF(NS_FAILED(rv))) { return rv; } return NS_OK; }
void AddCamera::on_Play_ID_clicked(bool checked) { if(checked) { bool isNumber = false; size_t usbId = m_ui->usbId->text().toInt(&isNumber); if(m_ui->usbId->text().isEmpty() || !isNumber) { QMessageBox::warning(this, "No device ID specified", "Couldn't turn on camera, because no device ID is specified"); m_ui->Play_ID->setChecked(false); m_ui->usbId->setEnabled(true); return; } m_cameraRecording = true; m_videoCaptureTemp.open(usbId); if(! m_videoCaptureTemp.isOpened()) { QMessageBox::warning(this, "Wrong device ID", "Specified device ID is wrong, camera could not be opened"); m_ui->Play_ID->setChecked(false); m_ui->usbId->setEnabled(true); m_cameraRecording = false; return; } recording(); } else { endRecording(); } }
void RDCae::DispatchCommand(RDCmdCache *cmd) { int pos; int card; if(!strcmp(cmd->arg(0),"PW")) { // Password Response if(cmd->arg(1)[0]=='+') { emit isConnected(true); } else { emit isConnected(false); } } if(!strcmp(cmd->arg(0),"LP")) { // Load Play int handle=GetHandle(cmd->arg(4)); int card=CardNumber(cmd->arg(1)); int stream=StreamNumber(cmd->arg(3)); syslog(LOG_ERR,"*** RDCae::DispatchCommand: received unhandled play stream from CAE, handle=%d, card=%d, stream=%d, name=\"%s\" ***", handle,card,stream,cmd->arg(2)); unloadPlay(handle); } if(!strcmp(cmd->arg(0),"UP")) { // Unload Play if(cmd->arg(2)[0]=='+') { int handle=GetHandle(cmd->arg(1)); for(int i=0;i<RD_MAX_CARDS;i++) { for(int j=0;j<RD_MAX_STREAMS;j++) { if(cae_handle[i][j]==handle) { cae_handle[i][j]=-1; for(unsigned k=0;k<RD_MAX_PORTS;k++) { cae_output_status_flags[i][k][j]=false; } } } } emit playUnloaded(handle); } } if(!strcmp(cmd->arg(0),"PP")) { // Position Play if(cmd->arg(3)[0]=='+') { int handle=GetHandle(cmd->arg(1)); sscanf(cmd->arg(2),"%u",&pos); for(int i=0;i<RD_MAX_CARDS;i++) { for(int j=0;j<RD_MAX_STREAMS;j++) { if(cae_handle[i][j]==handle) { //emit playPositionChanged(handle,cae_output_positions[i][j]); emit playPositionChanged(handle,pos); } } } emit playPositioned(handle,pos); } } if(!strcmp(cmd->arg(0),"PY")) { // Play if(cmd->arg(4)[0]=='+') { emit playing(GetHandle(cmd->arg(1))); } } if(!strcmp(cmd->arg(0),"SP")) { // Stop Play if(cmd->arg(2)[0]=='+') { emit playStopped(GetHandle(cmd->arg(1))); } } if(!strcmp(cmd->arg(0),"TS")) { // Timescale Supported if(sscanf(cmd->arg(1),"%d",&card)==1) { if(cmd->arg(2)[0]=='+') { emit timescalingSupported(card,true); } else { emit timescalingSupported(card,false); } } } if(!strcmp(cmd->arg(0),"LR")) { // Load Record if(cmd->arg(8)[0]=='+') { emit recordLoaded(CardNumber(cmd->arg(1)),StreamNumber(cmd->arg(2))); } } if(!strcmp(cmd->arg(0),"UR")) { // Unload Record if(cmd->arg(4)[0]=='+') { emit recordUnloaded(CardNumber(cmd->arg(1)),StreamNumber(cmd->arg(2)), QString(cmd->arg(3)).toUInt()); } } if(!strcmp(cmd->arg(0),"RD")) { // Record } if(!strcmp(cmd->arg(0),"RS")) { // Record Start if(cmd->arg(3)[0]=='+') { emit recording(CardNumber(cmd->arg(1)),StreamNumber(cmd->arg(2))); } } if(!strcmp(cmd->arg(0),"SR")) { // Stop Record if(cmd->arg(3)[0]=='+') { emit recordStopped(CardNumber(cmd->arg(1)),StreamNumber(cmd->arg(2))); } } if(!strcmp(cmd->arg(0),"IS")) { // Input Status switch(cmd->arg(3)[0]) { case '0': emit inputStatusChanged(CardNumber(cmd->arg(1)), StreamNumber(cmd->arg(2)),true); input_status[CardNumber(cmd->arg(1))][StreamNumber(cmd->arg(2))]= true; break; case '1': emit inputStatusChanged(CardNumber(cmd->arg(1)), StreamNumber(cmd->arg(2)),false); input_status[CardNumber(cmd->arg(1))][StreamNumber(cmd->arg(2))]= false; break; } } }
static EXPERIMENTAL::SkPlayback* rerecord_with_skr(SkPicture& src) { EXPERIMENTAL::SkRecording recording(src.width(), src.height()); src.draw(recording.canvas()); return recording.releasePlayback(); }
int snd_StartRecording(int desiredSamplesPerSec, int stereo, int semaIndex) { Synchronized<es::Monitor*> recording(monitorRecording); { Synchronized<es::Monitor*> method(monitorRecordState); if (recordState.open == true) { return 0; } recordState.open = true; recordState.bufSizeInBytes = MAX_RECORDING_SIZE * 2; recordState.maxRecordSize = MAX_RECORDING_SIZE; recordState.buffer = new u8[recordState.bufSizeInBytes]; if (!recordState.buffer) { recordState.open = false; return 0; } memset(recordState.buffer, 0x80, recordState.bufSizeInBytes); recordState.head = recordState.tail = recordState.buffer; recordState.next = recordState.head; recordState.nextRecordSize = 0; recordState.recorded = 0; recordState.stereo = stereo; recordState.dataFormat = 1; // 8-bit samples recordState.recordSemaIndex = semaIndex; if (desiredSamplesPerSec < 5000) { recordState.samplingRate = 5000; } else if (44100 < desiredSamplesPerSec) { recordState.samplingRate = 44100; } else { recordState.samplingRate = desiredSamplesPerSec; } int chan; if (stereo) { recordState.bytesPerSample = recordState.dataFormat * 2; recordState.outputBytesPerSample = BYTES_PER_SAMPLE * 2; chan = 2; } else { recordState.bytesPerSample = recordState.dataFormat; recordState.outputBytesPerSample = BYTES_PER_SAMPLE; chan = 1; } Handle<es::AudioFormat> audio(gSoundInput); audio->setBitsPerSample(8 * recordState.dataFormat); audio->setChannels(chan); audio->setSamplingRate(recordState.samplingRate); recordState.inProgress = true; monitorRecordState->notifyAll(); } return true; }
void TimelineToolBar::reset() { if (recording()) m_recording->setChecked(false); }
/* comments in header */ bool MythGesture::record(const QPoint & pt) { /* only record if we haven't exceeded the maximum points */ if (((uint)m_points.size() >= m_max_points) || !recording()) return false; if (m_points.size() == 0) { m_points.push_back(pt); return true; } /* interpolate between last and current point */ int delx = pt.x() - m_points.back().x(); int dely = pt.y() - m_points.back().y(); /* step by the greatest delta direction */ if (abs(delx) > abs(dely)) { float iy = m_points.back().y(); /* go from the last point to the current, whatever direction * it may be */ for (float ix = m_points.back().x(); (delx > 0) ? (ix < pt.x()) : (ix > pt.x()); ix += (delx > 0) ? 1 : -1) { /* step the other axis by the correct increment */ iy += std::fabs(((float) dely / (float) delx)) * (float) ((dely < 0) ? -1.0 : 1.0); m_points.push_back(QPoint((int)ix, (int)iy)); adjustExtremes((int)ix, (int)iy); } } else /* same thing, but for dely larger than delx case... */ { float ix = m_points.back().x(); /* go from the last point to the current, whatever direction it may be */ for (float iy = m_points.back().y(); (dely > 0) ? (iy < pt.y()) : (iy > pt.y()); iy += (dely > 0) ? 1 : -1) { /* step the other axis by the correct increment */ ix += std::fabs(((float) delx / (float) dely)) * (float) ((delx < 0) ? -1.0 : 1.0); /* add the interpolated point */ m_points.push_back(QPoint((int)ix, (int)iy)); adjustExtremes((int)ix, (int)iy); } } m_points.push_back(pt); return true; }
int main(int argc, char *argv[]){ // Options char *in_filename = NULL; // 問題ファイル名 char *out_filename = NULL; // 出力解答ファイル名 char *fix_filename = NULL; // 固定セル情報ファイル名 int outer_loops = O_LOOP; // 外ループ回数 bool fixed = false; // 固定フラグ // Options 取得 struct option longopts[] = { {"loop", required_argument, NULL, 'l'}, {"fixfile", required_argument, NULL, 'x'}, {"output", required_argument, NULL, 'o'}, {"fix-flag", no_argument, NULL, 'f'}, {"version", no_argument, NULL, 'v'}, {"help", no_argument, NULL, 'h'}, {0, 0, 0, 0} }; int opt, optidx; while ((opt = getopt_long(argc, argv, "l:o:fvh", longopts, &optidx)) != -1) { switch (opt) { case 'l': outer_loops = atoi(optarg); break; case 'x': fix_filename = optarg; break; case 'o': out_filename = optarg; break; case 'f': fixed = true; break; case 'v': version(); case 'h': case ':': case '?': default: usage(); } } if (argc <= optind) { usage(); } in_filename = argv[optind]; assert(in_filename != NULL); clock_t start_time, finish_time; start_time = clock(); initialize(in_filename); // 問題盤の生成 printBoard(); // 問題盤の表示 // 固定セルの生成 (機械学習の結果に基づく) if (fix_filename != NULL) { setFixFlagFromFile(fix_filename); printFixFlag(); } // 固定フラグの生成 else if (fixed) { generateFixFlag(); printFixFlag(); } // 乱数の初期化 mt_init_genrand((unsigned long)time(NULL)); // ペナルティの初期化 penalty_T = 0; penalty_C = 0; // 初期ルーティング for(int i=1;i<=board->getLineNum();i++){ // 数字が隣接する場合スキップ if(board->line(i)->getHasLine() == false) continue; if(!routing(i)){ cerr << "Cannot solve!! (error: 1)" << endl; exit(1); } } for(int i=1;i<=board->getLineNum();i++){ // 数字が隣接する場合スキップ if(board->line(i)->getHasLine() == false) continue; recording(i); } // 中間ポートを利用するか? // 利用している間,ライン不通過回数をカウントしない bool use_intermediate_port = false; // 中間ポートに設定するマスとそれを利用する数字 int inter_x, inter_y, inter_line = -1; // 探索スタート!! for (int m = 2; m <= outer_loops + 1; m++) { // 外ループ if(!use_intermediate_port){ // 中間ポートを利用しない場合 if ((m - 1) % 100 == 0) { cout << "loop " << (m-1) << endl; } if(m>INIT){ resetCandidate(); } } else{ // 中間ポートを利用する場合 if ((m - 1) % 100 == 0) { cout << "loop " << (m-1) << "+" << endl; } } // 解導出フラグ bool complete = false; for (int n = 1; n <= I_LOOP; n++) { // 内ループ if (INIT < m && !use_intermediate_port){ checkLineNonPassed(); } // 問題のおいて数字が隣接していないラインを選択する int id; do { id = (int)mt_genrand_int32(1, board->getLineNum()); } while (board->line(id)->getHasLine() == false); //cout << "(" << m << "," << n << ")Re-route Line" << id << endl; // 経路の削除 deleting(id); // ペナルティの設定 penalty_T = (int)(NT * (mt_genrand_int32(0, m - 1))); penalty_C = (int)(NC * (mt_genrand_int32(0, m - 1))); // 中間ポートを利用しない場合 if ( !((board->line(id))->isIntermediateUsed()) ) { // 経路の探索 if ( !routing(id) ) { cerr << "Cannot solve!! (error: 2)" << endl; // 失敗したらプログラム終了 exit(2); } // 経路の記録 recording(id); } // 中間ポートを利用する場合 else { // 経路の探索 (INTTRY 回) bool success = false; for (int count = 0; count < INTTRY; count++) { if (routingSourceToI(id)) { success = routingIToSink(id); break; } } // 中間ポート利用に失敗した場合,通常経路探索した後に内ループ脱出 if ( !success ) { if ( !routing(id) ) { cerr << "Cannot solve!! (error: 3)" << endl; // 失敗したらプログラム終了 exit(3); } recording(id); break; } // 経路の記録 recording(id); } // 終了判定(解導出できた場合,正解を出力) if(isFinished()){ finish_time = clock(); printSolution(); if (out_filename != NULL) { printSolutionToFile(out_filename); cout << "--> Saved to " << out_filename << endl << endl; } cout << "SUMMARY" << endl; cout << "-------" << endl; cout << " - filename: " << in_filename << endl; cout << " - size: " << board->getSizeX() << " x " << board->getSizeY() << endl; cout << " - iterations: " << (m - 1) << endl; cout << " - CPU time: " << ((double)(finish_time - start_time) / (double)CLOCKS_PER_SEC) << " sec" << endl; complete = true; break; } } if(complete) break; // 正解出力後は外ループも脱出 // 中間ポートを使用した次のループでは,中間ポートを利用しない if(use_intermediate_port){ use_intermediate_port = false; board->line(inter_line)->setIntermediateUnuse(); continue; } // 不通過マスの調査->中間ポートを利用するか? int candidate_count = 0; // 候補数 inter_x = -1; inter_y = -1; for(int y=0;y<board->getSizeY();y++){ for(int x=0;x<board->getSizeX();x++){ Box* trgt_box = board->box(x,y); if(trgt_box->isCandidate()){ candidate_count++; //cout << "(" << x << "," << y << ")"; // 不通過マス } } } //cout << endl; if(candidate_count==0) continue; // 候補数0なら利用しない // 候補の中から中間ポートに設定するマスをランダムに選択 int c_d = (int)mt_genrand_int32(0, candidate_count - 1); // 選択は候補の中で何番目か? int n_d = 0; // 何番目なのかをカウントする用の変数 bool flag = false; // 二重ループのためフラグが必要 for(int y=0;y<board->getSizeY();y++){ for(int x=0;x<board->getSizeX();x++){ Box* trgt_box = board->box(x,y); if(!trgt_box->isCandidate()){ continue; } if(n_d==c_d){ flag = true; inter_x = x; inter_y = y; break; } n_d++; } if(flag) break; } // 中間ポートの四方を見て,中間ポートを利用する数字をランダムに選択 checkCandidateLine(inter_x,inter_y); // 候補となるラインを調査 candidate_count = 0; // 候補数 inter_line = -1; for(int i=1;i<=board->getLineNum();i++){ Line* trgt_line = board->line(i); if(trgt_line->isCandidate()){ candidate_count++; //if(candidate_count>1) cout << ", "; //cout << i; } } //cout << endl; if(candidate_count==0) continue; // 候補数0なら利用しない c_d = (int)mt_genrand_int32(0, candidate_count - 1); // 選択は候補の中で何番目か? n_d = 0; // 何番目なのかをカウントする用の変数 for(int i=1;i<=board->getLineNum();i++){ Line* trgt_line = board->line(i); if(!trgt_line->isCandidate()) continue; if(n_d==c_d){ inter_line = i; break; } n_d++; } //cout << "Set (" << inter_x << "," << inter_y << ") InterPort of Line " << inter_line << endl; Line* line_i = board->line(inter_line); line_i->setIntermediateUse(); line_i->setIntermediatePort(inter_x,inter_y); use_intermediate_port = true; // m--; // 使うかどうか思案中・・・ // ペナルティ更新(旧) //penalty_T = (int)(NT * m); //penalty_C = (int)(NC * m); } // 解導出できなかった場合 if(!isFinished()){ for(int i=1;i<=board->getLineNum();i++){ printLine(i); } cerr << "Cannot solve!! (error: 4)" << endl; exit(4); } //デバッグ用 //for(int y=0;y<board->getSizeY();y++){ //for(int x=0;x<board->getSizeX();x++){ //cout << "(" << x << "," << y << ") "; //Box* trgt_box = board->box(x,y); //cout << " N:" << trgt_box->getNorthNum(); //cout << " E:" << trgt_box->getEastNum(); //cout << " S:" << trgt_box->getSouthNum(); //cout << " W:" << trgt_box->getWestNum(); //cout << endl; //} //} //for(int i=1;i<=board->getLineNum();i++){ // calcCost(i); //} delete board; return 0; }