[pulseaudio-commits] r1231 - in /trunk/src: Makefile.am pulsecore/llist.h tests/hook-list-test.c

svnmailer-noreply at 0pointer.de svnmailer-noreply at 0pointer.de
Sat Aug 12 16:35:45 PDT 2006


Author: lennart
Date: Sun Aug 13 01:35:44 2006
New Revision: 1231

URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1231&root=pulseaudio&view=rev
Log:
implement typeafe hook chain

Added:
    trunk/src/tests/hook-list-test.c   (with props)
Modified:
    trunk/src/Makefile.am
    trunk/src/pulsecore/llist.h

Modified: trunk/src/Makefile.am
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/Makefile.am?rev=1231&root=pulseaudio&r1=1230&r2=1231&view=diff
==============================================================================
--- trunk/src/Makefile.am (original)
+++ trunk/src/Makefile.am Sun Aug 13 01:35:44 2006
@@ -196,7 +196,8 @@
 		thread-mainloop-test \
 		utf8-test \
 		get-binary-name-test \
-		ipacl-test
+		ipacl-test \
+		hook-list-test
 
 if HAVE_SIGXCPU
 noinst_PROGRAMS += \
@@ -235,6 +236,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)

Modified: trunk/src/pulsecore/llist.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/pulsecore/llist.h?rev=1231&root=pulseaudio&r1=1230&r2=1231&view=diff
==============================================================================
--- trunk/src/pulsecore/llist.h (original)
+++ trunk/src/pulsecore/llist.h Sun Aug 13 01:35:44 2006
@@ -21,6 +21,8 @@
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
   USA.
 ***/
+
+#include <assert.h>
 
 /* Some macros for maintaining doubly linked lists */
 

Added: trunk/src/tests/hook-list-test.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/trunk/src/tests/hook-list-test.c?rev=1231&root=pulseaudio&view=auto
==============================================================================
--- trunk/src/tests/hook-list-test.c (added)
+++ trunk/src/tests/hook-list-test.c Sun Aug 13 01:35:44 2006
@@ -1,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;
+}

Propchange: trunk/src/tests/hook-list-test.c
------------------------------------------------------------------------------
    svn:keywords = Id




More information about the pulseaudio-commits mailing list