-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchannel.cpp
More file actions
60 lines (48 loc) · 1.06 KB
/
channel.cpp
File metadata and controls
60 lines (48 loc) · 1.06 KB
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
53
54
55
56
57
58
59
//channel.cpp
#include "channel.h"
Channel::Channel(int p) {
port=p;
tick=0;
closed=false;
waiting=false;
seq.owner=this;
}
void Channel::processEvent(Event *event, snd_seq_event_t *ev){
printf("Error, evento %d desconocido\n",event->type);
}
void Channel::addWait(string label, Channel *channel){
seq.addWait(label,channel);
}
void Channel::wakeUp(snd_seq_tick_time_t t){
tick=t;
waiting=false;
}
void Channel::jump(string label){
seq.jump(label);
}
Event *Channel::peekNextEvent(){
Event *ev=seq.peekNextEvent();
if (ev) {
return ev;
} else {
closed=true;
return 0;
}
}
Event *Channel::nextEvent() {
Event *ev=seq.nextEvent();
while(ev && (ev->type==Event::JUMP || ev->type==Event::WAIT)) {
if(ev->type==Event::JUMP) {
ev->Wait.channel->jump(ev->Wait.label);
} else if(ev->type==Event::WAIT) {
ev->Wait.channel->addWait(ev->Wait.label,this);
waiting=true;
return (Event *)1;
}
ev=seq.nextEvent();
}
if(!ev) {
closed=true; //
}
return ev;
}