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