]> code.delx.au - pulseaudio/blob - src/polyp/mainloop.c
Cleaned up the includes after the restructuring. Indicate which headers are
[pulseaudio] / src / polyp / mainloop.c
1 /* $Id$ */
2
3 /***
4 This file is part of polypaudio.
5
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
10
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 USA.
20 ***/
21
22 #ifdef HAVE_CONFIG_H
23 #include <config.h>
24 #endif
25
26 #include <stdio.h>
27 #include <signal.h>
28 #include <unistd.h>
29 #include <stdlib.h>
30 #include <string.h>
31 #include <assert.h>
32 #include <fcntl.h>
33 #include <errno.h>
34
35 #ifdef HAVE_SYS_POLL_H
36 #include <sys/poll.h>
37 #else
38 #include "poll.h"
39 #endif
40
41 #include "../polypcore/winsock.h"
42
43 #include <polypcore/util.h>
44 #include <polypcore/idxset.h>
45 #include <polypcore/xmalloc.h>
46 #include <polypcore/log.h>
47
48 #include "mainloop.h"
49
50 struct pa_io_event {
51 pa_mainloop *mainloop;
52 int dead;
53 int fd;
54 pa_io_event_flags_t events;
55 void (*callback) (pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags_t f, void *userdata);
56 struct pollfd *pollfd;
57 void *userdata;
58 void (*destroy_callback) (pa_mainloop_api*a, pa_io_event *e, void *userdata);
59 };
60
61 struct pa_time_event {
62 pa_mainloop *mainloop;
63 int dead;
64 int enabled;
65 struct timeval timeval;
66 void (*callback)(pa_mainloop_api*a, pa_time_event *e, const struct timeval*tv, void *userdata);
67 void *userdata;
68 void (*destroy_callback) (pa_mainloop_api*a, pa_time_event *e, void *userdata);
69 };
70
71 struct pa_defer_event {
72 pa_mainloop *mainloop;
73 int dead;
74 int enabled;
75 void (*callback)(pa_mainloop_api*a, pa_defer_event*e, void *userdata);
76 void *userdata;
77 void (*destroy_callback) (pa_mainloop_api*a, pa_defer_event *e, void *userdata);
78 };
79
80 struct pa_mainloop {
81 pa_idxset *io_events, *time_events, *defer_events;
82 int io_events_scan_dead, defer_events_scan_dead, time_events_scan_dead;
83
84 struct pollfd *pollfds;
85 unsigned max_pollfds, n_pollfds;
86 int rebuild_pollfds;
87
88 int prepared_timeout;
89
90 int quit, retval;
91 pa_mainloop_api api;
92
93 int deferred_pending;
94
95 int wakeup_pipe[2];
96
97 enum {
98 STATE_PASSIVE,
99 STATE_PREPARED,
100 STATE_POLLING,
101 STATE_POLLED,
102 STATE_QUIT
103 } state;
104 };
105
106 /* IO events */
107 static pa_io_event* mainloop_io_new(
108 pa_mainloop_api*a,
109 int fd,
110 pa_io_event_flags_t events,
111 void (*callback) (pa_mainloop_api*a, pa_io_event *e, int fd, pa_io_event_flags_t events, void *userdata),
112 void *userdata) {
113
114 pa_mainloop *m;
115 pa_io_event *e;
116
117 assert(a && a->userdata && fd >= 0 && callback);
118 m = a->userdata;
119 assert(a == &m->api);
120
121 pa_mainloop_wakeup(m);
122
123 e = pa_xmalloc(sizeof(pa_io_event));
124 e->mainloop = m;
125 e->dead = 0;
126
127 e->fd = fd;
128 e->events = events;
129 e->callback = callback;
130 e->userdata = userdata;
131 e->destroy_callback = NULL;
132 e->pollfd = NULL;
133
134 #ifdef OS_IS_WIN32
135 {
136 fd_set xset;
137 struct timeval tv;
138
139 tv.tv_sec = 0;
140 tv.tv_usec = 0;
141
142 FD_ZERO (&xset);
143 FD_SET (fd, &xset);
144
145 if ((select((SELECT_TYPE_ARG1) fd, NULL, NULL, SELECT_TYPE_ARG234 &xset,
146 SELECT_TYPE_ARG5 &tv) == -1) &&
147 (WSAGetLastError() == WSAENOTSOCK)) {
148 pa_log_warn(__FILE__": WARNING: cannot monitor non-socket file descriptors.\n");
149 e->dead = 1;
150 }
151 }
152 #endif
153
154 pa_idxset_put(m->io_events, e, NULL);
155 m->rebuild_pollfds = 1;
156 return e;
157 }
158
159 static void mainloop_io_enable(pa_io_event *e, pa_io_event_flags_t events) {
160 assert(e && e->mainloop);
161
162 pa_mainloop_wakeup(e->mainloop);
163
164 e->events = events;
165 e->mainloop->rebuild_pollfds = 1;
166 }
167
168 static void mainloop_io_free(pa_io_event *e) {
169 assert(e && e->mainloop);
170
171 pa_mainloop_wakeup(e->mainloop);
172
173 e->dead = e->mainloop->io_events_scan_dead = e->mainloop->rebuild_pollfds = 1;
174 }
175
176 static void mainloop_io_set_destroy(pa_io_event *e, void (*callback)(pa_mainloop_api*a, pa_io_event *e, void *userdata)) {
177 assert(e);
178 e->destroy_callback = callback;
179 }
180
181 /* Defer events */
182 static pa_defer_event* mainloop_defer_new(pa_mainloop_api*a, void (*callback) (pa_mainloop_api*a, pa_defer_event *e, void *userdata), void *userdata) {
183 pa_mainloop *m;
184 pa_defer_event *e;
185
186 assert(a && a->userdata && callback);
187 m = a->userdata;
188 assert(a == &m->api);
189
190 e = pa_xmalloc(sizeof(pa_defer_event));
191 e->mainloop = m;
192 e->dead = 0;
193
194 e->enabled = 1;
195 e->callback = callback;
196 e->userdata = userdata;
197 e->destroy_callback = NULL;
198
199 pa_idxset_put(m->defer_events, e, NULL);
200
201 m->deferred_pending++;
202 return e;
203 }
204
205 static void mainloop_defer_enable(pa_defer_event *e, int b) {
206 assert(e);
207
208 if (e->enabled && !b) {
209 assert(e->mainloop->deferred_pending > 0);
210 e->mainloop->deferred_pending--;
211 } else if (!e->enabled && b)
212 e->mainloop->deferred_pending++;
213
214 e->enabled = b;
215 }
216
217 static void mainloop_defer_free(pa_defer_event *e) {
218 assert(e);
219 e->dead = e->mainloop->defer_events_scan_dead = 1;
220
221 if (e->enabled) {
222 e->enabled = 0;
223 assert(e->mainloop->deferred_pending > 0);
224 e->mainloop->deferred_pending--;
225 }
226 }
227
228 static void mainloop_defer_set_destroy(pa_defer_event *e, void (*callback)(pa_mainloop_api*a, pa_defer_event *e, void *userdata)) {
229 assert(e);
230 e->destroy_callback = callback;
231 }
232
233 /* Time events */
234 static pa_time_event* mainloop_time_new(pa_mainloop_api*a, const struct timeval *tv, void (*callback) (pa_mainloop_api*a, pa_time_event*e, const struct timeval *tv, void *userdata), void *userdata) {
235 pa_mainloop *m;
236 pa_time_event *e;
237
238 assert(a && a->userdata && callback);
239 m = a->userdata;
240 assert(a == &m->api);
241
242 pa_mainloop_wakeup(m);
243
244 e = pa_xmalloc(sizeof(pa_time_event));
245 e->mainloop = m;
246 e->dead = 0;
247
248 e->enabled = !!tv;
249 if (tv)
250 e->timeval = *tv;
251
252 e->callback = callback;
253 e->userdata = userdata;
254 e->destroy_callback = NULL;
255
256 pa_idxset_put(m->time_events, e, NULL);
257
258 return e;
259 }
260
261 static void mainloop_time_restart(pa_time_event *e, const struct timeval *tv) {
262 assert(e);
263
264 pa_mainloop_wakeup(e->mainloop);
265
266 if (tv) {
267 e->enabled = 1;
268 e->timeval = *tv;
269 } else
270 e->enabled = 0;
271 }
272
273 static void mainloop_time_free(pa_time_event *e) {
274 assert(e);
275
276 pa_mainloop_wakeup(e->mainloop);
277
278 e->dead = e->mainloop->time_events_scan_dead = 1;
279 }
280
281 static void mainloop_time_set_destroy(pa_time_event *e, void (*callback)(pa_mainloop_api*a, pa_time_event *e, void *userdata)) {
282 assert(e);
283 e->destroy_callback = callback;
284 }
285
286 /* quit() */
287
288 static void mainloop_quit(pa_mainloop_api*a, int retval) {
289 pa_mainloop *m;
290 assert(a && a->userdata);
291 m = a->userdata;
292 assert(a == &m->api);
293
294 pa_mainloop_wakeup(m);
295
296 m->quit = 1;
297 m->retval = retval;
298 }
299
300 static const pa_mainloop_api vtable = {
301 .userdata = NULL,
302
303 .io_new= mainloop_io_new,
304 .io_enable= mainloop_io_enable,
305 .io_free= mainloop_io_free,
306 .io_set_destroy= mainloop_io_set_destroy,
307
308 .time_new = mainloop_time_new,
309 .time_restart = mainloop_time_restart,
310 .time_free = mainloop_time_free,
311 .time_set_destroy = mainloop_time_set_destroy,
312
313 .defer_new = mainloop_defer_new,
314 .defer_enable = mainloop_defer_enable,
315 .defer_free = mainloop_defer_free,
316 .defer_set_destroy = mainloop_defer_set_destroy,
317
318 .quit = mainloop_quit,
319 };
320
321 pa_mainloop *pa_mainloop_new(void) {
322 pa_mainloop *m;
323
324 m = pa_xmalloc(sizeof(pa_mainloop));
325
326 #ifndef OS_ISWIN32
327 if (pipe(m->wakeup_pipe) < 0) {
328 pa_xfree(m);
329 return NULL;
330 }
331
332 pa_make_nonblock_fd(m->wakeup_pipe[0]);
333 pa_make_nonblock_fd(m->wakeup_pipe[1]);
334 #else
335 m->wakeup_pipe[0] = -1;
336 m->wakeup_pipe[1] = -1;
337 #endif
338
339 m->io_events = pa_idxset_new(NULL, NULL);
340 m->defer_events = pa_idxset_new(NULL, NULL);
341 m->time_events = pa_idxset_new(NULL, NULL);
342
343 assert(m->io_events && m->defer_events && m->time_events);
344
345 m->io_events_scan_dead = m->defer_events_scan_dead = m->time_events_scan_dead = 0;
346
347 m->pollfds = NULL;
348 m->max_pollfds = m->n_pollfds = m->rebuild_pollfds = 0;
349
350 m->quit = m->retval = 0;
351
352 m->api = vtable;
353 m->api.userdata = m;
354
355 m->deferred_pending = 0;
356
357 m->state = STATE_PASSIVE;
358
359 return m;
360 }
361
362 static int io_foreach(void *p, uint32_t PA_GCC_UNUSED idx, int *del, void*userdata) {
363 pa_io_event *e = p;
364 int *all = userdata;
365 assert(e && del && all);
366
367 if (!*all && !e->dead)
368 return 0;
369
370 if (e->destroy_callback)
371 e->destroy_callback(&e->mainloop->api, e, e->userdata);
372 pa_xfree(e);
373 *del = 1;
374 return 0;
375 }
376
377 static int time_foreach(void *p, uint32_t PA_GCC_UNUSED idx, int *del, void*userdata) {
378 pa_time_event *e = p;
379 int *all = userdata;
380 assert(e && del && all);
381
382 if (!*all && !e->dead)
383 return 0;
384
385 if (e->destroy_callback)
386 e->destroy_callback(&e->mainloop->api, e, e->userdata);
387 pa_xfree(e);
388 *del = 1;
389 return 0;
390 }
391
392 static int defer_foreach(void *p, PA_GCC_UNUSED uint32_t idx, int *del, void*userdata) {
393 pa_defer_event *e = p;
394 int *all = userdata;
395 assert(e && del && all);
396
397 if (!*all && !e->dead)
398 return 0;
399
400 if (e->destroy_callback)
401 e->destroy_callback(&e->mainloop->api, e, e->userdata);
402 pa_xfree(e);
403 *del = 1;
404 return 0;
405 }
406
407 void pa_mainloop_free(pa_mainloop* m) {
408 int all = 1;
409 assert(m && (m->state != STATE_POLLING));
410
411 pa_idxset_foreach(m->io_events, io_foreach, &all);
412 pa_idxset_foreach(m->time_events, time_foreach, &all);
413 pa_idxset_foreach(m->defer_events, defer_foreach, &all);
414
415 pa_idxset_free(m->io_events, NULL, NULL);
416 pa_idxset_free(m->time_events, NULL, NULL);
417 pa_idxset_free(m->defer_events, NULL, NULL);
418
419 pa_xfree(m->pollfds);
420
421 if (m->wakeup_pipe[0] >= 0)
422 close(m->wakeup_pipe[0]);
423 if (m->wakeup_pipe[1] >= 0)
424 close(m->wakeup_pipe[1]);
425
426 pa_xfree(m);
427 }
428
429 static void scan_dead(pa_mainloop *m) {
430 int all = 0;
431 assert(m);
432
433 if (m->io_events_scan_dead)
434 pa_idxset_foreach(m->io_events, io_foreach, &all);
435 if (m->time_events_scan_dead)
436 pa_idxset_foreach(m->time_events, time_foreach, &all);
437 if (m->defer_events_scan_dead)
438 pa_idxset_foreach(m->defer_events, defer_foreach, &all);
439
440 m->io_events_scan_dead = m->time_events_scan_dead = m->defer_events_scan_dead = 0;
441 }
442
443 static void rebuild_pollfds(pa_mainloop *m) {
444 pa_io_event*e;
445 struct pollfd *p;
446 uint32_t idx = PA_IDXSET_INVALID;
447 unsigned l;
448
449 l = pa_idxset_size(m->io_events) + 1;
450 if (m->max_pollfds < l) {
451 m->pollfds = pa_xrealloc(m->pollfds, sizeof(struct pollfd)*l);
452 m->max_pollfds = l;
453 }
454
455 m->n_pollfds = 0;
456 p = m->pollfds;
457
458 if (m->wakeup_pipe[0] >= 0) {
459 m->pollfds[0].fd = m->wakeup_pipe[0];
460 m->pollfds[0].events = POLLIN;
461 m->pollfds[0].revents = 0;
462 p++;
463 m->n_pollfds++;
464 }
465
466 for (e = pa_idxset_first(m->io_events, &idx); e; e = pa_idxset_next(m->io_events, &idx)) {
467 if (e->dead) {
468 e->pollfd = NULL;
469 continue;
470 }
471
472 e->pollfd = p;
473 p->fd = e->fd;
474 p->events =
475 ((e->events & PA_IO_EVENT_INPUT) ? POLLIN : 0) |
476 ((e->events & PA_IO_EVENT_OUTPUT) ? POLLOUT : 0) |
477 POLLHUP |
478 POLLERR;
479 p->revents = 0;
480
481 p++;
482 m->n_pollfds++;
483 }
484
485 m->rebuild_pollfds = 0;
486 }
487
488 static int dispatch_pollfds(pa_mainloop *m) {
489 uint32_t idx = PA_IDXSET_INVALID;
490 pa_io_event *e;
491 int r = 0;
492
493 for (e = pa_idxset_first(m->io_events, &idx); e && !m->quit; e = pa_idxset_next(m->io_events, &idx)) {
494 if (e->dead || !e->pollfd || !e->pollfd->revents)
495 continue;
496
497 assert(e->pollfd->fd == e->fd && e->callback);
498 e->callback(&m->api, e, e->fd,
499 (e->pollfd->revents & POLLHUP ? PA_IO_EVENT_HANGUP : 0) |
500 (e->pollfd->revents & POLLIN ? PA_IO_EVENT_INPUT : 0) |
501 (e->pollfd->revents & POLLOUT ? PA_IO_EVENT_OUTPUT : 0) |
502 (e->pollfd->revents & POLLERR ? PA_IO_EVENT_ERROR : 0),
503 e->userdata);
504 e->pollfd->revents = 0;
505 r++;
506 }
507
508 return r;
509 }
510
511 static int dispatch_defer(pa_mainloop *m) {
512 uint32_t idx;
513 pa_defer_event *e;
514 int r = 0;
515
516 if (!m->deferred_pending)
517 return 0;
518
519 for (e = pa_idxset_first(m->defer_events, &idx); e && !m->quit; e = pa_idxset_next(m->defer_events, &idx)) {
520 if (e->dead || !e->enabled)
521 continue;
522
523 assert(e->callback);
524 e->callback(&m->api, e, e->userdata);
525 r++;
526 }
527
528 return r;
529 }
530
531 static int calc_next_timeout(pa_mainloop *m) {
532 uint32_t idx;
533 pa_time_event *e;
534 struct timeval now;
535 int t = -1;
536 int got_time = 0;
537
538 if (pa_idxset_isempty(m->time_events))
539 return -1;
540
541 for (e = pa_idxset_first(m->time_events, &idx); e; e = pa_idxset_next(m->time_events, &idx)) {
542 int tmp;
543
544 if (e->dead || !e->enabled)
545 continue;
546
547 /* Let's save a system call */
548 if (!got_time) {
549 pa_gettimeofday(&now);
550 got_time = 1;
551 }
552
553 if (e->timeval.tv_sec < now.tv_sec || (e->timeval.tv_sec == now.tv_sec && e->timeval.tv_usec <= now.tv_usec))
554 return 0;
555
556 tmp = (e->timeval.tv_sec - now.tv_sec)*1000;
557
558 if (e->timeval.tv_usec > now.tv_usec)
559 tmp += (e->timeval.tv_usec - now.tv_usec)/1000;
560 else
561 tmp -= (now.tv_usec - e->timeval.tv_usec)/1000;
562
563 if (tmp == 0)
564 return 0;
565 else if (t == -1 || tmp < t)
566 t = tmp;
567 }
568
569 return t;
570 }
571
572 static int dispatch_timeout(pa_mainloop *m) {
573 uint32_t idx;
574 pa_time_event *e;
575 struct timeval now;
576 int got_time = 0;
577 int r = 0;
578 assert(m);
579
580 if (pa_idxset_isempty(m->time_events))
581 return 0;
582
583 for (e = pa_idxset_first(m->time_events, &idx); e && !m->quit; e = pa_idxset_next(m->time_events, &idx)) {
584
585 if (e->dead || !e->enabled)
586 continue;
587
588 /* Let's save a system call */
589 if (!got_time) {
590 pa_gettimeofday(&now);
591 got_time = 1;
592 }
593
594 if (e->timeval.tv_sec < now.tv_sec || (e->timeval.tv_sec == now.tv_sec && e->timeval.tv_usec <= now.tv_usec)) {
595 assert(e->callback);
596
597 e->enabled = 0;
598 e->callback(&m->api, e, &e->timeval, e->userdata);
599
600 r++;
601 }
602 }
603
604 return r;
605 }
606
607 void pa_mainloop_wakeup(pa_mainloop *m) {
608 char c = 'W';
609 assert(m);
610
611 if (m->wakeup_pipe[1] >= 0)
612 write(m->wakeup_pipe[1], &c, sizeof(c));
613 }
614
615 static void clear_wakeup(pa_mainloop *m) {
616 char c[10];
617
618 assert(m);
619
620 if (m->wakeup_pipe[0] < 0)
621 return;
622
623 while (read(m->wakeup_pipe[0], &c, sizeof(c)) == sizeof(c));
624 }
625
626 int pa_mainloop_prepare(pa_mainloop *m, int timeout) {
627 int dispatched = 0;
628
629 assert(m && (m->state == STATE_PASSIVE));
630
631 clear_wakeup(m);
632
633 scan_dead(m);
634
635 if (m->quit)
636 goto quit;
637
638 dispatched += dispatch_defer(m);
639
640 if (m->quit)
641 goto quit;
642
643 if (m->rebuild_pollfds)
644 rebuild_pollfds(m);
645
646 m->prepared_timeout = calc_next_timeout(m);
647 if ((timeout >= 0) && (m->prepared_timeout > timeout))
648 m->prepared_timeout = timeout;
649
650 m->state = STATE_PREPARED;
651
652 return dispatched;
653
654 quit:
655
656 m->state = STATE_QUIT;
657
658 return -2;
659 }
660
661 int pa_mainloop_poll(pa_mainloop *m) {
662 int r;
663
664 assert(m && (m->state == STATE_PREPARED));
665
666 m->state = STATE_POLLING;
667
668 r = poll(m->pollfds, m->n_pollfds, m->prepared_timeout);
669
670 if ((r < 0) && (errno == EINTR))
671 r = 0;
672
673 if (r < 0)
674 m->state = STATE_PASSIVE;
675 else
676 m->state = STATE_POLLED;
677
678 return r;
679 }
680
681 int pa_mainloop_dispatch(pa_mainloop *m) {
682 int dispatched = 0;
683
684 assert(m && (m->state == STATE_POLLED));
685
686 dispatched += dispatch_timeout(m);
687
688 if (m->quit)
689 goto quit;
690
691 dispatched += dispatch_pollfds(m);
692
693 if (m->quit)
694 goto quit;
695
696 m->state = STATE_PASSIVE;
697
698 return dispatched;
699
700 quit:
701
702 m->state = STATE_QUIT;
703
704 return -2;
705 }
706
707 int pa_mainloop_get_retval(pa_mainloop *m) {
708 assert(m);
709 return m->retval;
710 }
711
712 int pa_mainloop_iterate(pa_mainloop *m, int block, int *retval) {
713 int r, dispatched = 0;
714
715 assert(m);
716
717 r = pa_mainloop_prepare(m, block ? -1 : 0);
718 if (r < 0) {
719 if ((r == -2) && retval)
720 *retval = pa_mainloop_get_retval(m);
721 return r;
722 }
723
724 dispatched += r;
725
726 r = pa_mainloop_poll(m);
727 if (r < 0) {
728 pa_log(__FILE__": poll(): %s\n", strerror(errno));
729 return r;
730 }
731
732 r = pa_mainloop_dispatch(m);
733 if (r < 0) {
734 if ((r == -2) && retval)
735 *retval = pa_mainloop_get_retval(m);
736 return r;
737 }
738
739 dispatched += r;
740
741 return dispatched;
742 }
743
744 int pa_mainloop_run(pa_mainloop *m, int *retval) {
745 int r;
746 while ((r = pa_mainloop_iterate(m, 1, retval)) >= 0);
747
748 if (r == -2)
749 return 1;
750 else if (r < 0)
751 return -1;
752 else
753 return 0;
754 }
755
756 void pa_mainloop_quit(pa_mainloop *m, int r) {
757 assert(m);
758 pa_mainloop_wakeup(m);
759 m->quit = r;
760 }
761
762 pa_mainloop_api* pa_mainloop_get_api(pa_mainloop*m) {
763 assert(m);
764 return &m->api;
765 }
766
767 int pa_mainloop_deferred_pending(pa_mainloop *m) {
768 assert(m);
769 return m->deferred_pending > 0;
770 }
771
772
773 #if 0
774 void pa_mainloop_dump(pa_mainloop *m) {
775 assert(m);
776
777 pa_log(__FILE__": Dumping mainloop sources START\n");
778
779 {
780 uint32_t idx = PA_IDXSET_INVALID;
781 pa_io_event *e;
782 for (e = pa_idxset_first(m->io_events, &idx); e; e = pa_idxset_next(m->io_events, &idx)) {
783 if (e->dead)
784 continue;
785
786 pa_log(__FILE__": kind=io fd=%i events=%i callback=%p userdata=%p\n", e->fd, (int) e->events, (void*) e->callback, (void*) e->userdata);
787 }
788 }
789 {
790 uint32_t idx = PA_IDXSET_INVALID;
791 pa_defer_event *e;
792 for (e = pa_idxset_first(m->defer_events, &idx); e; e = pa_idxset_next(m->defer_events, &idx)) {
793 if (e->dead)
794 continue;
795
796 pa_log(__FILE__": kind=defer enabled=%i callback=%p userdata=%p\n", e->enabled, (void*) e->callback, (void*) e->userdata);
797 }
798 }
799 {
800 uint32_t idx = PA_IDXSET_INVALID;
801 pa_time_event *e;
802 for (e = pa_idxset_first(m->time_events, &idx); e; e = pa_idxset_next(m->time_events, &idx)) {
803 if (e->dead)
804 continue;
805
806 pa_log(__FILE__": kind=time enabled=%i time=%lu.%lu callback=%p userdata=%p\n", e->enabled, (unsigned long) e->timeval.tv_sec, (unsigned long) e->timeval.tv_usec, (void*) e->callback, (void*) e->userdata);
807 }
808 }
809
810 pa_log(__FILE__": Dumping mainloop sources STOP\n");
811
812 }
813 #endif