int CXBMCRenderManager::WaitForBuffer(volatile bool& bStop, int timeout) { CSingleLock lock2(m_presentlock); // check if gui is active and discard buffer if not // this keeps videoplayer going if (!m_bRenderGUI || !g_application.GetRenderGUI()) { m_bRenderGUI = false; double presenttime = 0; double clock = GetPresentTime(); if (!m_queued.empty()) { int idx = m_queued.front(); presenttime = m_Queue[idx].timestamp; } else presenttime = clock + 0.02; int sleeptime = (presenttime - clock) * 1000; if (sleeptime < 0) sleeptime = 0; sleeptime = std::min(sleeptime, 20); m_presentevent.wait(lock2, sleeptime); DiscardBuffer(); return 0; } XbmcThreads::EndTime endtime(timeout); while(m_free.empty()) { m_presentevent.wait(lock2, std::min(50, timeout)); if(endtime.IsTimePast() || bStop) { if (timeout != 0 && !bStop) { CLog::Log(LOGWARNING, "CRenderManager::WaitForBuffer - timeout waiting for buffer"); m_waitForBufferCount++; if (m_waitForBufferCount > 2) { m_bRenderGUI = false; } } return -1; } } m_waitForBufferCount = 0; // make sure overlay buffer is released, this won't happen on AddOverlay m_overlays.Release(m_free.front()); // return buffer level return m_queued.size() + m_discard.size();; }
Area& operator=(const Area& area) { id(area.id()); version(area.version()); changeset(area.changeset()); timestamp(area.timestamp()); endtime(area.endtime()); uid(area.uid()); user(area.user()); visible(area.visible()); tags(area.tags()); m_node_list = area.m_node_list; m_relation_member_list = area.m_relation_member_list; m_geos_geometry = dynamic_cast<geos::geom::MultiPolygon*>(area.m_geos_geometry->clone()); return *this; }
int main(int argc, char *argv[]) { struct timeval etim; float elapsed; if (argc != 2) { fprintf(stderr, "usage: %s dir\n", argv[0]); exit(1); } starttime(); statit(argv[1]); endtime(&etim); elapsed = (float)etim.tv_sec + (float)etim.tv_usec / 1000000.0; fprintf(stdout, "%d calls in %f seconds (%f calls/sec)\n", stats, elapsed, (float)stats / elapsed); return (0); }
int CXBMCRenderManager::WaitForBuffer(volatile bool& bStop, int timeout) { CSingleLock lock2(m_presentlock); XbmcThreads::EndTime endtime(timeout); while(m_free.empty()) { m_presentevent.wait(lock2, std::min(50, timeout)); if(endtime.IsTimePast() || bStop) { if (timeout != 0 && !bStop) CLog::Log(LOGWARNING, "CRenderManager::WaitForBuffer - timeout waiting for buffer"); return -1; } } // make sure overlay buffer is released, this won't happen on AddOverlay m_overlays.Release(m_free.front()); // return buffer level return m_queued.size() + m_discard.size();; }
bool CXBMCRenderManager::Configure(unsigned int width, unsigned int height, unsigned int d_width, unsigned int d_height, float fps, unsigned flags, ERenderFormat format, unsigned extended_format, unsigned int orientation, int buffers) { CSingleLock lock2(m_presentlock); /* make sure any queued frame was fully presented */ XbmcThreads::EndTime endtime(5000); while(m_presentstep != PRESENT_IDLE) { if(endtime.IsTimePast()) { CLog::Log(LOGWARNING, "CRenderManager::Configure - timeout waiting for state"); return false; } m_presentevent.wait(lock2, endtime.MillisLeft()); }; lock2.Leave(); CExclusiveLock lock(m_sharedSection); if(!m_pRenderer) { CLog::Log(LOGERROR, "%s called without a valid Renderer object", __FUNCTION__); return false; } bool result = m_pRenderer->Configure(width, height, d_width, d_height, fps, flags, format, extended_format, orientation); if(result) { if( flags & CONF_FLAGS_FULLSCREEN ) { lock.Leave(); CApplicationMessenger::Get().SwitchToFullscreen(); lock.Enter(); } lock2.Enter(); m_format = format; int renderbuffers = m_pRenderer->GetOptimalBufferSize(); m_QueueSize = std::min(buffers, renderbuffers); m_QueueSize = std::min(m_QueueSize, (int)m_pRenderer->GetMaxBufferSize()); m_QueueSize = std::min(m_QueueSize, NUM_BUFFERS); if(m_QueueSize < 2) { m_QueueSize = 2; CLog::Log(LOGWARNING, "CXBMCRenderManager::Configure - queue size too small (%d, %d, %d)", m_QueueSize, renderbuffers, buffers); } m_pRenderer->SetBufferSize(m_QueueSize); m_pRenderer->Update(); m_queued.clear(); m_discard.clear(); m_free.clear(); m_presentsource = 0; for (int i=1; i < m_QueueSize; i++) m_free.push_back(i); m_bIsStarted = true; m_bReconfigured = true; m_presentstep = PRESENT_IDLE; m_presentpts = DVD_NOPTS_VALUE; m_sleeptime = 1.0; m_presentevent.notifyAll(); m_firstFlipPage = false; // tempfix CLog::Log(LOGDEBUG, "CXBMCRenderManager::Configure - %d", m_QueueSize); } return result; }
QString Robot::handleTrainSchedule_step2(const QString& info, QString& icon, QString& detailurl) { QString traininfo; int pos = info.indexOf(QStringLiteral("trainnum")); QString trainnum(""); for(int i = pos + 11; i < info.size(); i++) { if(info.at(i) == QChar('"')) { break; } trainnum += info.at(i); } pos = info.indexOf(QStringLiteral("start")); QString start(""); for(int i = pos + 8; i < info.size(); i++) { if(info.at(i) == QChar('"')) { break; } start += info.at(i); } pos = info.indexOf(QStringLiteral("terminal")); QString terminal(""); for(int i = pos + 11; i < info.size(); i++) { if(info.at(i) == QChar('"')) { break; } terminal += info.at(i); } pos = info.indexOf(QStringLiteral("starttime")); QString starttime(""); for(int i = pos + 12; i < info.size(); i++) { if(info.at(i) == QChar('"')) { break; } starttime += info.at(i); } pos = info.indexOf(QStringLiteral("endtime")); QString endtime(""); for(int i = pos + 10; i < info.size(); i++) { if(info.at(i) == QChar('"')) { break; } endtime += info.at(i); } //icon图标的地址 pos = info.indexOf(QStringLiteral("icon")); for(int i = pos + 7; i < info.size(); i++) { if(info.at(i) == QChar('"')) { break; } icon += info.at(i); } //detailurl pos = info.indexOf(QStringLiteral("detailurl")); for(int i = pos + 12; i < info.size(); i++) { if(info.at(i) == QChar('"')) { break; } detailurl += info.at(i); } traininfo.append(QStringLiteral("列车车次:") + trainnum + "\n"); traininfo.append(QStringLiteral("起点:") + start + "\n"); traininfo.append(QStringLiteral("终点:") + terminal + "\n"); traininfo.append(QStringLiteral("开始时间:") + starttime + "\n"); traininfo.append(QStringLiteral("到达时间:") + endtime); return traininfo; }
int main(int argc, char *argv[]) { int files; /* number of files in each dir */ int totfiles = 0; int dirs; /* directories in each dir */ int totdirs = 0; int levels; /* levels deep */ char *fname; char *dname; struct timeval time; char *opts; struct testparam *param; struct btest *b; char *config_file; char *test_dir; char *log_file; FILE *log; setbuf(stdout, NULL); Myname = *argv++; argc--; while(argc && **argv == '-') { for(opts = &argv[0][1]; *opts; opts++) { switch (*opts) { case 'h': /* help */ usage(); exit(1); break; case 's': /* silent */ Sflag++; break; case 't': /* time */ Tflag++; break; case 'f': /* funtionality */ Fflag++; break; case 'n': /* No Test Directory create */ Nflag++; break; default: error("unknown option '%c'", *opts); usage(); exit(1); } } argc--; argv++; } if(argc) { config_file = *argv; argc--; argv++; } else { fprintf(stderr, "Missing config_file"); exit(1); } if(argc != 0) { fprintf(stderr, "too many parameters"); usage(); exit(1); } param = readin_config(config_file); if(param == NULL) { fprintf(stderr, "Nothing built\n"); exit(1); } b = get_btest_args(param, ONE); if(b == NULL) { fprintf(stderr, "Missing basic test number 1 in the config file '%s'\n", config_file); free_testparam(param); exit(1); } if(b->levels == -1) { fprintf(stderr, "Missing 'levels' parameter in the config file '%s' for the basic test number 1\n", config_file); free_testparam(param); exit(1); } if(b->files == -1) { fprintf(stderr, "Missing 'files' parameter in the config file '%s' for the basic test number 1\n", config_file); free_testparam(param); exit(1); } if(b->dirs == -1) { fprintf(stderr, "Missing 'dirs' parameter in the config file '%s' for the basic test number 1\n", config_file); free_testparam(param); exit(1); } levels = b->levels; files = b->files; dirs = b->dirs; fname = b->fname; dname = b->dname; test_dir = get_test_directory(param); log_file = get_log_file(param); free_testparam(param); if(!Fflag) { Tflag = 0; levels = 2; files = 2; dirs = 2; } if(!Sflag) { fprintf(stdout, "%s: File and directory creation test\n", Myname); } if(!Nflag) testdir(test_dir); else mtestdir(test_dir); starttime(); dirtree(levels, files, dirs, fname, dname, &totfiles, &totdirs); endtime(&time); if(!Sflag) { fprintf(stdout, "\tcreated %d files %d directories %d levels deep", totfiles, totdirs, levels); } if(Tflag && !Sflag) { fprintf(stdout, " in %ld.%02ld seconds", (long)time.tv_sec, (long)time.tv_usec / 10000); } if(!Sflag) { fprintf(stdout, "\n"); } if((log = fopen(log_file, "a")) == NULL) { printf("Enable to open the file '%s'\n", log_file); complete(); } fprintf(log, "b1\t%d\t%d\t%d\t%ld.%02ld\n", totfiles, totdirs, levels, (long)time.tv_sec, (long)time.tv_usec / 10000); fclose(log); complete(); }
int main(int argc, char *argv[]) { int files = 10; /* number of files in each dir */ int fi; int count = 50; /* times to do each file */ int ct; int totfiles = 0; int totdirs = 0; char *fname = FNAME; struct timeval time; char str[MAXPATHLEN]; struct stat statb; char *opts; umask(0); setbuf(stdout, NULL); Myname = *argv++; argc--; while (argc && **argv == '-') { for (opts = &argv[0][1]; *opts; opts++) { switch (*opts) { case 'h': /* help */ usage(); exit(1); break; case 't': /* time */ Tflag++; break; case 'f': /* funtionality */ Fflag++; break; case 'n': /* suppress initial directory */ Nflag++; break; default: error("unknown option '%c'", *opts); usage(); exit(1); } } argc--; argv++; } if (argc) { files = getparm(*argv, 1, "files"); argv++; argc--; } if (argc) { count = getparm(*argv, 1, "count"); argv++; argc--; } if (argc) { fname = *argv; argc--; argv++; } if (argc) { usage(); exit(1); } if (Fflag) { Tflag = 0; count = 1; } if (!Nflag) testdir(NULL); else mtestdir(NULL); dirtree(1, files, 0, fname, DNAME, &totfiles, &totdirs); fprintf(stdout, "%s: getattr and lookup\n", Myname); if (Tflag) { starttime(); } for (ct = 0; ct < count; ct++) { for (fi = 0; fi < files; fi++) { sprintf(str, "%s%d", fname, fi); if (stat(str, &statb) < 0) { error("can't stat %s", str); exit(1); } } } if (Tflag) { endtime(&time); } fprintf(stdout, "\t%d stats on %d files", files * count * 2, files); if (Tflag) { fprintf(stdout, " in %ld.%-2ld seconds", (long)time.tv_sec, (long)time.tv_usec / 10000); } fprintf(stdout, "\n"); /* XXX REMOVE DIRECTORY TREE? */ complete(); return 0; }
int main(int argc, char *argv[]) { int count = DCOUNT; /* times to do each file */ int ct; off_t size = DSIZE; off_t si; int fd; off_t bytes = 0; int roflags; /* open read-only flags */ char *bigfile = "bigfile"; struct timeval time; char *opts; char buf[BUFSZ]; double etime; #ifdef MMAP caddr_t maddr; #endif umask(0); setbuf(stdout, NULL); Myname = *argv++; argc--; while (argc && **argv == '-') { for (opts = &argv[0][1]; *opts; opts++) { switch (*opts) { case 'h': /* help */ usage(); exit(1); break; case 't': /* time */ Tflag++; break; case 'f': /* funtionality */ Fflag++; break; case 'n': /* No Test Directory create */ Nflag++; break; default: error("unknown option '%c'", *opts); usage(); exit(1); } } argc--; argv++; } if (argc) { size = getparm(*argv, 1, "size"); if (size <= 0) { usage(); exit(1); } argv++; argc--; } if (argc) { count = getparm(*argv, 1, "count"); if (count <= 0) { usage(); exit(1); } argv++; argc--; } if (argc) { bigfile = *argv; argv++; argc--; } if (argc) { usage(); exit(1); } if (Fflag) { Tflag = 0; count = 1; } roflags = O_RDONLY; #ifdef DOSorWIN32 roflags |= O_BINARY; #endif fprintf(stdout, "%s: read\n", Myname); mtestdir(NULL); if (Tflag) { starttime(); } for (ct = 0; ct < count; ct++) { if ((fd = open(bigfile, roflags)) < 0) { error("can't open '%s'", bigfile); exit(1); } #ifdef MMAP maddr = mmap((caddr_t)0, (size_t)size, PROT_READ, MAP_PRIVATE, fd, (off_t)0); if (maddr == MAP_FAILED) { error("can't mmap '%s'", bigfile); exit(1); } if (msync(maddr, (size_t)size, MS_INVALIDATE) < 0) { error("can't invalidate pages for '%s'", bigfile); exit(1); } if (munmap(maddr, (size_t)size) < 0) { error("can't munmap '%s'", bigfile); exit(1); } #endif for (si = size; si > 0; si -= bytes) { bytes = MIN(BUFSZ, si); if (read(fd, buf, bytes) != bytes) { error("'%s' read failed", bigfile); exit(1); } } close(fd); } if (Tflag) { endtime(&time); } fprintf(stdout, "\tread %ld byte file %d times", (long)size, count); if (Tflag) { etime = (double)time.tv_sec + (double)time.tv_usec / 1000000.0; if (etime != 0.0) { fprintf(stdout, " in %ld.%-2ld seconds (%ld bytes/sec)", (long)time.tv_sec, (long)time.tv_usec / 10000, (long)((double)size * ((double)count / etime))); } else { fprintf(stdout, " in %ld.%-2ld seconds (> %ld bytes/sec)", (long)time.tv_sec, (long)time.tv_usec / 10000, (long)size * count); } } fprintf(stdout, "\n"); if (unlink(bigfile) < 0) { error("can't unlink '%s'", bigfile); exit(1); } complete(); return 0; }