Ejemplo n.º 1
0
Boolean OSCBeProductiveWhileWaiting(void) {
    /* Here's where we could be clever if an allocation fails. 
       (I.e., if we're out of QD objects, we should avoid
       parsing bundles.) The code isn't that smart yet. */

    queuedData *qd;

    if (globals.timePassed) {
	OSCQueueScanStart(globals.TheQueue);
    }

    while (1) {
	qd = (queuedData *) OSCQueueScanNext(globals.TheQueue);
	if (qd == 0) return FALSE;

	if (qd->type == BUNDLE) {
            ParseBundle(qd);
	    OSCQueueRemoveCurrentScanItem(globals.TheQueue);
	    return TRUE;
	} else {
	    if (qd->data.message.callbacks == NOT_DISPATCHED_YET) {
                if (ParseMessage(qd) == FALSE) {
                    /* Problem with this message - flush it. */
		    DropMessage(qd->data.message.messageName,
				qd->data.message.length,
				qd->myPacket);
		    OSCQueueRemoveCurrentScanItem(globals.TheQueue);
		    PacketRemoveRef(qd->myPacket);
                    FreeQD(qd);
		}
		return TRUE;
	    }
	    /* The item we found was an already-dispatched message,
	       so continue the while loop. */
	}
    }
}
Ejemplo n.º 2
0
void ScanTest(OSCQueue q) {
    myObj *item;

    printf("Start scan.\n");
    OSCQueueScanStart(q);

    while(1) {
	item = (myObj *) OSCQueueScanNext(q);
	if (item == 0) {
	    printf("End of scan.\n");
	    break;
	}
	printf("  Next scan object:  time tag %llu, data %s\n",
	       item->timetag, item->data);
    }

    printf("Queue should be unchanged after scan:   ");
    OSCQueuePrint(q);

    printf("Another scan, this time removing data that begins with 's'.\n");
    OSCQueueScanStart(q);

    while(1) {
        item = (myObj *) OSCQueueScanNext(q);
        if (item == 0) {
            printf("End of scan.\n");
            break;
	}
	if (item->data[0] == 's') {
	    printf("  Scan object data begins with 's':  time tag %llu, data %s\n",
               item->timetag, item->data);
	    printf("How the queue looks before removal:   ");
	    OSCQueuePrint(q);
	    OSCQueueRemoveCurrentScanItem(q);
	    printf("How the queue looks after removal:   ");
	    OSCQueuePrint(q);
	}
    }
}