]>
code.delx.au - pulseaudio/blob - src/tests/asyncmsgq-test.c
2 This file is part of PulseAudio.
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 of the License,
7 or (at your option) any later version.
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.
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
28 #include <pulse/util.h>
29 #include <pulse/xmalloc.h>
30 #include <pulsecore/asyncmsgq.h>
31 #include <pulsecore/thread.h>
32 #include <pulsecore/log.h>
33 #include <pulsecore/core-util.h>
34 #include <pulsecore/macro.h>
43 static void the_thread(void *_q
) {
50 pa_assert_se(pa_asyncmsgq_get(q
, NULL
, &code
, NULL
, NULL
, NULL
, 1) == 0);
55 printf("Operation A\n");
59 printf("Operation B\n");
63 printf("Operation C\n");
72 pa_asyncmsgq_done(q
, 0);
77 int main(int argc
, char *argv
[]) {
81 pa_assert_se(q
= pa_asyncmsgq_new(0));
83 pa_assert_se(t
= pa_thread_new(the_thread
, q
));
85 printf("Operation A post\n");
86 pa_asyncmsgq_post(q
, NULL
, OPERATION_A
, NULL
, 0, NULL
, NULL
);
90 printf("Operation B post\n");
91 pa_asyncmsgq_post(q
, NULL
, OPERATION_B
, NULL
, 0, NULL
, NULL
);
95 printf("Operation C send\n");
96 pa_asyncmsgq_send(q
, NULL
, OPERATION_C
, NULL
, 0, NULL
);
100 printf("Quit post\n");
101 pa_asyncmsgq_post(q
, NULL
, QUIT
, NULL
, 0, NULL
, NULL
);
105 pa_asyncmsgq_unref(q
);