Esempio n. 1
0
Boolean OSCInitReceive(struct OSCReceiveMemoryTuner *t) {
    globals.recvBufSize = t->receiveBufferSize;
    globals.InitTimeMalloc = t->InitTimeMemoryAllocator;
    globals.RealTimeMemoryAllocator = t->RealTimeMemoryAllocator;

    globals.TheQueue = OSCNewQueue(t->numQueuedObjects, t->InitTimeMemoryAllocator);
    if (globals.TheQueue == 0) return FALSE;

    globals.lastTimeTag = OSCTT_Immediately();
    globals.timePassed = TRUE;

    if (InitPackets(t->receiveBufferSize, SizeOfNetworkReturnAddress(),
		    t->numReceiveBuffers) == FALSE) return FALSE;
    if (InitQueuedData(t->numQueuedObjects) == FALSE) return FALSE;
    if (InitCallbackListNodes(t->numCallbackListNodes, t->InitTimeMemoryAllocator)
	 == FALSE) return FALSE;
    
    return TRUE;
}
Esempio n. 2
0
void main (void) {
    OSCQueue q;
    myObj *item;

    q = OSCNewQueue(100, Allocator);
    if (q == 0) {
	printf("OSCNewQueue() returned 0!\n");
	return;
    }

    printf("Made an empty queue:  ");
    OSCQueuePrint(q);

    printf("Inserting three objects.\n");
    objects[0].timetag = 5;
    objects[0].data = "five";
    objects[1].timetag = 2;
    objects[1].data = "two";
    objects[2].timetag = 7;
    objects[2].data = "seven";

    if (OSCQueueInsert(q, (OSCSchedulableObject) &(objects[0])) == FALSE) {
	printf("OSCQueueInsert() returned FALSE!\n");
        return;
    }

    if (OSCQueueInsert(q, (OSCSchedulableObject) &(objects[1])) == FALSE) {
	printf("OSCQueueInsert() returned FALSE!\n");
        return;
    }

    if (OSCQueueInsert(q, (OSCSchedulableObject) &(objects[2])) == FALSE) {
	printf("OSCQueueInsert() returned FALSE!\n");
        return;
    }

    printf("Queue with three objects:   ");
    OSCQueuePrint(q);

    printf("Earliest time tag is %llu.\n", OSCQueueEarliestTimeTag(q));

    printf("Remove front item:\n");
    
    item = (myObj *) OSCQueueRemoveEarliest(q);
    printf("Time tag %llu, data %s\n", item->timetag, item->data);

    printf("Queue with two objects:   ");
    OSCQueuePrint(q);

    printf("Inserting three more objects.\n");
    objects[3].timetag = 11;
    objects[3].data = "eleven";
    objects[4].timetag = 6;
    objects[4].data = "six";
    objects[5].timetag = 3;
    objects[5].data = "three";
    
    if (OSCQueueInsert(q, (OSCSchedulableObject) &(objects[3])) == FALSE) {
        printf("OSCQueueInsert() returned FALSE!\n");
        return;
    }

    if (OSCQueueInsert(q, (OSCSchedulableObject) &(objects[4])) == FALSE) {
        printf("OSCQueueInsert() returned FALSE!\n");
        return;
    }

    if (OSCQueueInsert(q, (OSCSchedulableObject) &(objects[5])) == FALSE) {
        printf("OSCQueueInsert() returned FALSE!\n");
        return;
    }


    printf("Queue with five objects:   ");
    OSCQueuePrint(q);


    ScanTest(q);
    StressTest(q);

    printf("Done!\n");

}