/* process_pending_events -- Process currently pending events by calling event-hook and event-idle until no events are left. */ void process_pending_events(void) { at *hndl; at *event; int timer_fired = 0; call_spoll(); hndl = ev_peek(); for(;;) { while (hndl) { /* Call the handler method <handle> */ LOCK(hndl); event = event_get(hndl, TRUE); if (CONSP(event)) { at *cl = classof(hndl); if (EXTERNP(cl, &class_class)) { at *m = checksend(cl->Object, at_handle); if (m) { at *args = new_cons(event,NIL); UNLOCK(m); argeval_ptr = eval_nothing; m = send_message(NIL,hndl,at_handle,args); argeval_ptr = eval_std; UNLOCK(args); } UNLOCK(m); } UNLOCK(cl); } UNLOCK(event); UNLOCK(hndl); /* Check for more events */ call_spoll(); hndl = ev_peek(); } /* Check for timer events */ if (timer_fired) break; timer_fire(); timer_fired = 1; hndl = ev_peek(); } }
void* thread0(void *arg) { short buf[N]; int fd = open("/dev/dsp", O_RDONLY, 0644); if( !dsp_setup(fd) ) return NULL; int sc = *(int *) arg; int x; while( 1 ){ x = read(fd, buf, N); if(x == -1) die("read"); if(checksend(buf,x)) send(sc, buf, x, 0); //is that ok? } close(fd); return NULL; }