MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / run

Method run

server/XVTrans.cpp:46–99  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

44
45
46void 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
102XVFrame *XVTrans::getFrame(Display *dpy, Window win, int width, int height)

Callers

nothing calls this directly

Calls 9

signalMethod · 0.80
startFrameMethod · 0.80
endFrameMethod · 0.80
elapsedMethod · 0.80
signalCompleteMethod · 0.80
setErrorMethod · 0.80
getMethod · 0.45
redrawMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected