| 44 | |
| 45 | |
| 46 | void XVTrans::run(void) |
| 47 | { |
| 48 | Timer timer, sleepTimer; double err = 0.; bool first = true; |
| 49 | |
| 50 | try |
| 51 | { |
| 52 | while(!deadYet) |
| 53 | { |
| 54 | XVFrame *f; void *ftemp = NULL; |
| 55 | |
| 56 | q.get(&ftemp); f = (XVFrame *)ftemp; if(deadYet) return; |
| 57 | if(!f) throw("Queue has been shut down"); |
| 58 | ready.signal(); |
| 59 | profXV.startFrame(); |
| 60 | f->redraw(); |
| 61 | profXV.endFrame(f->hdr.width * f->hdr.height, 0, 1); |
| 62 | |
| 63 | profTotal.endFrame(f->hdr.width * f->hdr.height, 0, 1); |
| 64 | profTotal.startFrame(); |
| 65 | |
| 66 | if(fconfig.flushdelay > 0.) |
| 67 | { |
| 68 | long usec = (long)(fconfig.flushdelay * 1000000.); |
| 69 | if(usec > 0) usleep(usec); |
| 70 | } |
| 71 | if(fconfig.fps > 0.) |
| 72 | { |
| 73 | double elapsed = timer.elapsed(); |
| 74 | if(first) first = false; |
| 75 | else |
| 76 | { |
| 77 | if(elapsed < 1. / fconfig.fps) |
| 78 | { |
| 79 | sleepTimer.start(); |
| 80 | long usec = (long)((1. / fconfig.fps - elapsed - err) * 1000000.); |
| 81 | if(usec > 0) usleep(usec); |
| 82 | double sleepTime = sleepTimer.elapsed(); |
| 83 | err = sleepTime - (1. / fconfig.fps - elapsed - err); |
| 84 | if(err < 0.) err = 0.; |
| 85 | } |
| 86 | } |
| 87 | timer.start(); |
| 88 | } |
| 89 | |
| 90 | f->signalComplete(); |
| 91 | } |
| 92 | |
| 93 | } |
| 94 | catch(std::exception &e) |
| 95 | { |
| 96 | if(thread) thread->setError(e); |
| 97 | ready.signal(); throw; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | |
| 102 | XVFrame *XVTrans::getFrame(Display *dpy, Window win, int width, int height) |
nothing calls this directly
no test coverage detected