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 <stdlib.h>
25 : : #include <unistd.h>
26 : : #include <stdio.h>
27 : :
28 : : #include <pulse/rtclock.h>
29 : : #include <pulse/timeval.h>
30 : : #include <pulse/util.h>
31 : : #include <pulse/thread-mainloop.h>
32 : :
33 : : #include <pulsecore/macro.h>
34 : : #include <pulsecore/core-rtclock.h>
35 : :
36 : 1 : static void tcb(pa_mainloop_api *a, pa_time_event *e, const struct timeval *tv, void *userdata) {
37 [ - + ]: 1 : pa_assert_se(pa_threaded_mainloop_in_thread(userdata));
38 : 1 : fprintf(stderr, "TIME EVENT START\n");
39 : 1 : pa_threaded_mainloop_signal(userdata, 1);
40 : 1 : fprintf(stderr, "TIME EVENT END\n");
41 : 1 : }
42 : :
43 : 1 : int main(int argc, char *argv[]) {
44 : : pa_mainloop_api *a;
45 : : pa_threaded_mainloop *m;
46 : : struct timeval tv;
47 : :
48 [ - + ]: 1 : pa_assert_se(m = pa_threaded_mainloop_new());
49 [ - + ]: 1 : pa_assert_se(a = pa_threaded_mainloop_get_api(m));
50 : :
51 [ - + ]: 1 : pa_assert_se(pa_threaded_mainloop_start(m) >= 0);
52 : :
53 : 1 : pa_threaded_mainloop_lock(m);
54 : :
55 [ - + ]: 1 : pa_assert_se(!pa_threaded_mainloop_in_thread(m));
56 : :
57 : 1 : a->time_new(a, pa_timeval_rtstore(&tv, pa_rtclock_now() + 5 * PA_USEC_PER_SEC, TRUE), tcb, m);
58 : :
59 : 1 : fprintf(stderr, "waiting 5s (signal)\n");
60 : 1 : pa_threaded_mainloop_wait(m);
61 : 1 : fprintf(stderr, "wait completed\n");
62 : 1 : pa_threaded_mainloop_accept(m);
63 : 1 : fprintf(stderr, "signal accepted\n");
64 : :
65 : 1 : pa_threaded_mainloop_unlock(m);
66 : :
67 : 1 : fprintf(stderr, "waiting 5s (sleep)\n");
68 : 1 : pa_msleep(5000);
69 : :
70 : 1 : pa_threaded_mainloop_stop(m);
71 : :
72 : 1 : pa_threaded_mainloop_free(m);
73 : : return 0;
74 : : }
|