[pulseaudio-commits] r1795 - in /branches/lennart/src: pulse/thread-mainloop.c pulse/thread-mainloop.h tests/thread-mainloop-test.c
svnmailer-noreply at 0pointer.de
svnmailer-noreply at 0pointer.de
Mon Sep 10 14:58:01 PDT 2007
Author: lennart
Date: Mon Sep 10 23:58:01 2007
New Revision: 1795
URL: http://0pointer.de/cgi-bin/viewcvs.cgi?rev=1795&root=pulseaudio&view=rev
Log:
add new API pa_threaded_mainloop_in_thread(), update test case for it
Modified:
branches/lennart/src/pulse/thread-mainloop.c
branches/lennart/src/pulse/thread-mainloop.h
branches/lennart/src/tests/thread-mainloop-test.c
Modified: branches/lennart/src/pulse/thread-mainloop.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/thread-mainloop.c?rev=1795&root=pulseaudio&r1=1794&r2=1795&view=diff
==============================================================================
--- branches/lennart/src/pulse/thread-mainloop.c (original)
+++ branches/lennart/src/pulse/thread-mainloop.c Mon Sep 10 23:58:01 2007
@@ -223,3 +223,9 @@
return pa_mainloop_get_api(m->real_mainloop);
}
+
+int pa_threaded_mainloop_in_thread(pa_threaded_mainloop *m) {
+ pa_assert(m);
+
+ return m->thread && pa_thread_self() == m->thread;
+}
Modified: branches/lennart/src/pulse/thread-mainloop.h
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/pulse/thread-mainloop.h?rev=1795&root=pulseaudio&r1=1794&r2=1795&view=diff
==============================================================================
--- branches/lennart/src/pulse/thread-mainloop.h (original)
+++ branches/lennart/src/pulse/thread-mainloop.h Mon Sep 10 23:58:01 2007
@@ -297,6 +297,9 @@
/** Return the abstract main loop abstraction layer vtable for this main loop. */
pa_mainloop_api* pa_threaded_mainloop_get_api(pa_threaded_mainloop*m);
+/** Returns non-zero when called from withing the event loop thread. \since 0.9.7 */
+int pa_threaded_mainloop_in_thread(pa_threaded_mainloop *m);
+
PA_C_DECL_END
#endif
Modified: branches/lennart/src/tests/thread-mainloop-test.c
URL: http://0pointer.de/cgi-bin/viewcvs.cgi/branches/lennart/src/tests/thread-mainloop-test.c?rev=1795&root=pulseaudio&r1=1794&r2=1795&view=diff
==============================================================================
--- branches/lennart/src/tests/thread-mainloop-test.c (original)
+++ branches/lennart/src/tests/thread-mainloop-test.c Mon Sep 10 23:58:01 2007
@@ -23,18 +23,19 @@
#include <config.h>
#endif
-#include <assert.h>
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <pulse/timeval.h>
#include <pulse/util.h>
+#include <pulse/thread-mainloop.h>
#include <pulsecore/gccmacro.h>
-#include <pulse/thread-mainloop.h>
+#include <pulsecore/macro.h>
static void tcb(pa_mainloop_api*a, pa_time_event *e, const struct timeval *tv, void *userdata) {
+ pa_assert_se(pa_threaded_mainloop_in_thread(userdata));
fprintf(stderr, "TIME EVENT START\n");
pa_threaded_mainloop_signal(userdata, 1);
fprintf(stderr, "TIME EVENT END\n");
@@ -45,15 +46,15 @@
pa_threaded_mainloop *m;
struct timeval tv;
- m = pa_threaded_mainloop_new();
- assert(m);
- a = pa_threaded_mainloop_get_api(m);
- assert(a);
+ pa_assert_se(m = pa_threaded_mainloop_new());
+ pa_assert_se(a = pa_threaded_mainloop_get_api(m));
pa_threaded_mainloop_start(m);
pa_threaded_mainloop_lock(m);
+ pa_assert_se(!pa_threaded_mainloop_in_thread(m));
+
pa_gettimeofday(&tv);
tv.tv_sec += 5;
a->time_new(a, &tv, tcb, m);
More information about the pulseaudio-commits
mailing list