| 151 | |
| 152 | |
| 153 | void VGLTrans::run(void) |
| 154 | { |
| 155 | Frame *lastf = NULL, *f = NULL; |
| 156 | long bytes = 0; |
| 157 | Timer timer, sleepTimer; double err = 0.; bool first = true; |
| 158 | int i; |
| 159 | |
| 160 | try |
| 161 | { |
| 162 | VGLTrans::Compressor *comp[MAXPROCS]; Thread *cthread[MAXPROCS]; |
| 163 | if(fconfig.verbose) |
| 164 | vglout.println("[VGL] Using %d compression threads on %d CPU cores", |
| 165 | nprocs, NumProcs()); |
| 166 | for(i = 0; i < nprocs; i++) |
| 167 | comp[i] = new VGLTrans::Compressor(i, this); |
| 168 | if(nprocs > 1) for(i = 1; i < nprocs; i++) |
| 169 | { |
| 170 | cthread[i] = new Thread(comp[i]); |
| 171 | cthread[i]->start(); |
| 172 | } |
| 173 | |
| 174 | while(!deadYet) |
| 175 | { |
| 176 | int np; |
| 177 | void *ftemp = NULL; |
| 178 | |
| 179 | q.get(&ftemp); f = (Frame *)ftemp; if(deadYet) break; |
| 180 | if(!f) THROW("Queue has been shut down"); |
| 181 | ready.signal(); |
| 182 | np = nprocs; if(f->hdr.compress == RRCOMP_YUV) np = 1; |
| 183 | if(np > 1) |
| 184 | { |
| 185 | for(i = 1; i < np; i++) |
| 186 | { |
| 187 | cthread[i]->checkError(); comp[i]->go(f, lastf); |
| 188 | } |
| 189 | } |
| 190 | comp[0]->compressSend(f, lastf); |
| 191 | bytes += comp[0]->bytes; |
| 192 | if(np > 1) |
| 193 | { |
| 194 | for(i = 1; i < np; i++) |
| 195 | { |
| 196 | comp[i]->stop(); cthread[i]->checkError(); comp[i]->send(); |
| 197 | bytes += comp[i]->bytes; |
| 198 | } |
| 199 | } |
| 200 | sendHeader(f->hdr, true); |
| 201 | |
| 202 | profTotal.endFrame(f->hdr.width * f->hdr.height, bytes, 1); |
| 203 | bytes = 0; |
| 204 | profTotal.startFrame(); |
| 205 | |
| 206 | if(fconfig.flushdelay > 0.) |
| 207 | { |
| 208 | long usec = (long)(fconfig.flushdelay * 1000000.); |
| 209 | if(usec > 0) usleep(usec); |
| 210 | } |
nothing calls this directly
no test coverage detected