~pbatch/patchwerk

patchwerk/examples/evn_test.c -rw-r--r-- 1.1 KiB
9c265356 — paul plan9 additions from Sigrid 4 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* TODO: make this program work again */

#include <stdlib.h>
#include <stdio.h>
#include "patchwerk.h"
#define NEVENTS 6

static int counter = 0;
int durs[] = {
2, 3, 0, 1, 1, 10000 /* last value is arbitrary */
};


static pw_evnode * callback(pw_evnode *node, int pos)
{
    printf("counter is %d\n", counter);
    return pw_evnode_next(node);
}

int main(int argc, char *argv[])
{
    pw_evnode *node[NEVENTS];
    pw_evwalker walker;
    pw_patch *patch;

    patch = calloc(1, pw_patch_size());
    pw_patch_init(patch, BLKSIZE);

    for(counter = 0; counter < NEVENTS; counter++) {
        pw_evnode_new(patch, &node[counter]);
        pw_evnode_init(node[counter]);
        pw_evnode_callback(node[counter], callback);
        pw_evnode_dur(node[counter], durs[counter]);
        if(counter > 0) {
            pw_evnode_set_next(node[counter - 1], node[counter]);
        }
    }

    pw_evwalker_init(&walker, node[0], 0);

    for(counter = 0; counter < 16; counter++) {
        pw_evwalker_walk(&walker, 0);
    }

    for(counter = 0; counter < NEVENTS; counter++) {
        pw_evnode_bye(patch, &node[counter]);
    }

    free(patch);

    return 0;
}