Branch data Line data Source code
1 : : /***
2 : : This file is part of PulseAudio.
3 : :
4 : : PulseAudio is free software; you can redistribute it and/or modify
5 : : it under the terms of the GNU Lesser General Public License as published
6 : : by the Free Software Foundation; either version 2.1 of the License,
7 : : or (at your option) any later version.
8 : :
9 : : PulseAudio is distributed in the hope that it will be useful, but
10 : : WITHOUT ANY WARRANTY; without even the implied warranty of
11 : : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 : : General Public License for more details.
13 : :
14 : : You should have received a copy of the GNU Lesser General Public License
15 : : along with PulseAudio; if not, write to the Free Software
16 : : Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17 : : USA.
18 : : ***/
19 : :
20 : : #ifdef HAVE_CONFIG_H
21 : : #include <config.h>
22 : : #endif
23 : :
24 : : #include <signal.h>
25 : :
26 : : #include <pulsecore/poll.h>
27 : : #include <pulsecore/log.h>
28 : : #include <pulsecore/rtpoll.h>
29 : :
30 : 2 : static int before(pa_rtpoll_item *i) {
31 : 2 : pa_log("before");
32 : 2 : return 0;
33 : : }
34 : :
35 : 2 : static void after(pa_rtpoll_item *i) {
36 : 2 : pa_log("after");
37 : 2 : }
38 : :
39 : 2 : static int worker(pa_rtpoll_item *w) {
40 : 2 : pa_log("worker");
41 : 2 : return 0;
42 : : }
43 : :
44 : 1 : int main(int argc, char *argv[]) {
45 : : pa_rtpoll *p;
46 : : pa_rtpoll_item *i, *w;
47 : : struct pollfd *pollfd;
48 : :
49 : 1 : p = pa_rtpoll_new();
50 : :
51 : 1 : i = pa_rtpoll_item_new(p, PA_RTPOLL_EARLY, 1);
52 : 1 : pa_rtpoll_item_set_before_callback(i, before);
53 : 1 : pa_rtpoll_item_set_after_callback(i, after);
54 : :
55 : 1 : pollfd = pa_rtpoll_item_get_pollfd(i, NULL);
56 : 1 : pollfd->fd = 0;
57 : 1 : pollfd->events = POLLIN;
58 : :
59 : 1 : w = pa_rtpoll_item_new(p, PA_RTPOLL_NORMAL, 0);
60 : 1 : pa_rtpoll_item_set_before_callback(w, worker);
61 : :
62 : 1 : pa_rtpoll_set_timer_relative(p, 10000000); /* 10 s */
63 : :
64 : 1 : pa_rtpoll_run(p, 1);
65 : :
66 : 1 : pa_rtpoll_item_free(i);
67 : :
68 : 1 : i = pa_rtpoll_item_new(p, PA_RTPOLL_EARLY, 1);
69 : 1 : pa_rtpoll_item_set_before_callback(i, before);
70 : 1 : pa_rtpoll_item_set_after_callback(i, after);
71 : :
72 : 1 : pollfd = pa_rtpoll_item_get_pollfd(i, NULL);
73 : 1 : pollfd->fd = 0;
74 : 1 : pollfd->events = POLLIN;
75 : :
76 : 1 : pa_rtpoll_run(p, 1);
77 : :
78 : 1 : pa_rtpoll_item_free(i);
79 : :
80 : 1 : pa_rtpoll_item_free(w);
81 : :
82 : 1 : pa_rtpoll_free(p);
83 : :
84 : : return 0;
85 : : }
|