void takeScreenShot(const QString filename) { q_lock(); QImage image = QImage(( uchar *) q_frameBuffer(), q_screenWidth(), q_screenHeight(), q_screenWidth() * q_screenDepth() / 8, QImage::Format_RGB16); image.save(filename, "PNG"); q_unlock(); }
bool my_queue_insert(struct my_queue *q, void *item, unsigned *pspace) { q_lock(q); bool res = false; unsigned head = q->head; unsigned tail = q->tail; unsigned space = q_space(head, tail, q->size); if (space >= 1) { q->elems[head] = item; q->head = (head + 1) & (q->size - 1); res = true; space--; } q_unlock(q); if (pspace) *pspace = space; return (res); }
bool my_queue_remove(struct my_queue *q, void **pitem, unsigned *pcount) { q_lock(q); bool res = false; unsigned head = q->head; unsigned tail = q->tail; unsigned count = q_count(head, tail, q->size); if (count >= 1) { *pitem = q->elems[tail]; q->tail = (tail + 1) & (q->size - 1); res = true; count--; } q_unlock(q); if (pcount) *pcount = count; return (res); }
void q_initDD() { if (initialized) return; DirectDrawCreate(NULL, &g_pDD, NULL); HRESULT h; h = g_pDD->SetCooperativeLevel(0, DDSCL_NORMAL); if (h != DD_OK) qDebug() << "cooperation level failed"; h = g_pDD->TestCooperativeLevel(); if (h != DD_OK) qDebug() << "cooperation level failed test"; DDSURFACEDESC ddsd; memset(&ddsd, 0, sizeof(ddsd)); ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS; ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE; h = g_pDD->CreateSurface(&ddsd, &g_pDDSSurface, NULL); if (h != DD_OK) qDebug() << "CreateSurface failed!"; if (g_pDDSSurface->GetCaps(&ddsCaps) != DD_OK) qDebug() << "GetCaps failed"; q_lock(); q_unlock(); initialized = true; }
void runqueue(void) { struct queuent *q; char **termlist; struct terminal term; int t = 0, i = 0, s = 0, r = 0; conf.udb.dbinit(); conf.tdb.dbinit(); resetdelivertraps(); termlist = conf.tdb.list(); /* two minutes to complete delivery */ alarm(120); for (t = 0; termlist[t] != NULL; t++) { _ndebug(0, ("Queue for %s:\n", termlist[t])); q = listqueue(termlist[t]); for (i = 0; q[i].to[0] != NULL; i++); if (i > 0) { del_log("starting to process queue %d", i); term = conf.tdb.get(termlist[t]); if ((s = any_openterm(term)) >= 0) { /* Inside this if is executed if I got the port */ if (s_tap_init(s, term.flags) < 0) { any_closeterm(s, term); sleep(5); /* sleep it off */ break; } /* Keep looping through queue stuff until there are no more * requests, in case any where queued while we're already * delivering. */ while (q[0].to[0] != NULL) { /* too debuggy */ /* del_log("start of while loop"); */ for (i = 0; q[i].to[0] != NULL; i++) { getqueueinfo(&q[i]); /* Too debuggy */ /* del_log("attempt s_tap_send mess: %s", * q[i].message); */ r = s_tap_send(s, q[i].u.pageid, q[i].message); if (r == 0) { _ndebug(0, ("Delivery of %s successful\n", q[i].qid)); del_log("delivered %s to %s: %d bytes", q[i].qid, q[i].to, strlen(q[i].message)); dequeue(q[i].qid); usleep(2600); } else if (r == 'X' && i == 0) { _ndebug(0, ("Delivery of %s probably successful\n", q[i].qid)); del_log("probably delivered %s to %s: %d bytes", q[i].qid, q[i].to, strlen(q[i].message)); dequeue(q[i].qid); usleep(2600); /* Must re-connect before sending any more. */ break; } else if (r == C_RS) { dq_notify(q[i], "Unsuccessful", NOTIFY_FAIL); del_log("failed %s to %s, got RS (fatal)", q[i].qid, q[i].to); dequeue(q[i].qid); } else { del_log("deferred %s to %s, " "will keep trying until it expires", q[i].qid, q[i].to); q_unlock(q[i]); /* Must re-connect. */ if (r == 'X') { break; }; } _ndebug(2, ("\t%d to %s ``%s''\n", i, q[i].to, q[i].message)); } /* for loop */ cleanqueuelist(q); /* Must re-connect. */ if (r == 'X') { break; }; q = listqueue(termlist[t]); } /* while loop */ /* Too debuggy */ /* del_log("attempting s_tap_end"); */ s_tap_end(s); any_closeterm(s, term); sleep(5); /* sleep it off */ } else { del_log("Failed to get a port"); _ndebug(2, ("Didn't get the port\n")); } } cleanqueuelist(q); } cleantermlist(termlist); cleanmylocks(); /* Too debuggy */ /* del_log("end of runqueue"); */ }