mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-31 22:25:33 -04:00
implement typeafe hook chain
git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@1231 fefdeb5f-60dc-0310-8127-8f9354f1896f
This commit is contained in:
parent
7f70ca31a1
commit
80d73dd21b
3 changed files with 47 additions and 1 deletions
|
|
@ -196,7 +196,8 @@ noinst_PROGRAMS = \
|
|||
thread-mainloop-test \
|
||||
utf8-test \
|
||||
get-binary-name-test \
|
||||
ipacl-test
|
||||
ipacl-test \
|
||||
hook-list-test
|
||||
|
||||
if HAVE_SIGXCPU
|
||||
noinst_PROGRAMS += \
|
||||
|
|
@ -236,6 +237,11 @@ ipacl_test_CFLAGS = $(AM_CFLAGS)
|
|||
ipacl_test_LDADD = $(AM_LDADD) libpulsecore.la
|
||||
ipacl_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
|
||||
|
||||
hook_list_test_SOURCES = tests/hook-list-test.c
|
||||
hook_list_test_CFLAGS = $(AM_CFLAGS)
|
||||
hook_list_test_LDADD = $(AM_LDADD) libpulsecore.la
|
||||
hook_list_test_LDFLAGS = $(AM_LDFLAGS) $(BINLDFLAGS)
|
||||
|
||||
mcalign_test_SOURCES = tests/mcalign-test.c
|
||||
mcalign_test_CFLAGS = $(AM_CFLAGS)
|
||||
mcalign_test_LDADD = $(AM_LDADD) $(WINSOCK_LIBS) libpulsecore.la
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
USA.
|
||||
***/
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/* Some macros for maintaining doubly linked lists */
|
||||
|
||||
/* The head of the linked list. Use this in the structure that shall
|
||||
|
|
|
|||
38
src/tests/hook-list-test.c
Normal file
38
src/tests/hook-list-test.c
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/* $Id$ */
|
||||
|
||||
#include <pulsecore/hook-list.h>
|
||||
#include <pulsecore/log.h>
|
||||
|
||||
PA_HOOK_DECLARE(test, const char *, const char*);
|
||||
PA_HOOK_IMPLEMENT(test, const char *, const char *);
|
||||
|
||||
static pa_hook_result_t func1(const char*a, const char*b, void *userdata) {
|
||||
pa_log("#1 a=%s b=%s userdata=%s", a, b, (char*) userdata);
|
||||
return PA_HOOK_OK;
|
||||
}
|
||||
|
||||
static pa_hook_result_t func2(const char*a, const char*b, void *userdata) {
|
||||
pa_log("#2 a=%s b=%s userdata=%s", a, b, (char*) userdata);
|
||||
return PA_HOOK_OK;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
void *u;
|
||||
|
||||
PA_HOOK_HEAD(test, test);
|
||||
|
||||
PA_HOOK_HEAD_INIT(test, test);
|
||||
|
||||
PA_HOOK_APPEND(test, test, func1, (void*) "1-1");
|
||||
PA_HOOK_APPEND(test, test, func2, u = (void*) "2");
|
||||
PA_HOOK_APPEND(test, test, func1, (void*) "1-2");
|
||||
|
||||
|
||||
PA_HOOK_EXECUTE(test, test, "arg1", "arg2");
|
||||
|
||||
PA_HOOK_REMOVE(test, test, func2, u);
|
||||
|
||||
PA_HOOK_FREE(test, test);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue