1 /* $Id: thread-test.c 1621 2007-08-10 22:00:22Z lennart $ */
4 This file is part of PulseAudio.
6 PulseAudio 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.
11 PulseAudio 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.
16 You should have received a copy of the GNU Lesser General Public License
17 along with PulseAudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 #include <pulsecore/log.h>
30 #include <pulsecore/rtpoll.h>
31 #include <pulsecore/rtsig.h>
33 static int before(pa_rtpoll_item *i) {
38 static void after(pa_rtpoll_item *i) {
42 static int worker(pa_rtpoll_item *w) {
47 int main(int argc, char *argv[]) {
49 pa_rtpoll_item *i, *w;
50 struct pollfd *pollfd;
53 pa_rtsig_configure(SIGRTMIN+10, SIGRTMAX);
58 i = pa_rtpoll_item_new(p, PA_RTPOLL_EARLY, 1);
59 pa_rtpoll_item_set_before_callback(i, before);
60 pa_rtpoll_item_set_after_callback(i, after);
62 pollfd = pa_rtpoll_item_get_pollfd(i, NULL);
64 pollfd->events = POLLIN;
66 w = pa_rtpoll_item_new(p, PA_RTPOLL_NORMAL, 0);
67 pa_rtpoll_item_set_before_callback(w, worker);
70 pa_rtpoll_set_timer_relative(p, 10000000); /* 10 s */
74 pa_rtpoll_item_free(i);
76 i = pa_rtpoll_item_new(p, PA_RTPOLL_EARLY, 1);
77 pa_rtpoll_item_set_before_callback(i, before);
78 pa_rtpoll_item_set_after_callback(i, after);
80 pollfd = pa_rtpoll_item_get_pollfd(i, NULL);
82 pollfd->events = POLLIN;
86 pa_rtpoll_item_free(i);
88 pa_rtpoll_item_free(w);