path: root/src/pulsecore/sink.h
diff options
authorLennart Poettering <>2009-08-13 02:14:19 +0200
committerLennart Poettering <>2009-08-13 02:14:19 +0200
commit9a95fe49c848d2711dcdcf4c407e626e41e4657f (patch)
treee2a535e8713aa93a0fbab8486ddf45c4214395db /src/pulsecore/sink.h
parent17d57415f5abad5b7c30301227054b4c899bc705 (diff)
core: add assert macros for verifying calling context
This adds pa_assert_io_context() and pa_assert_ctl_context() in addition to a few related macros. When called they will fail when the current execution context is not IO resp. not control context. (aka 'thread' context vs. 'main' context)
Diffstat (limited to 'src/pulsecore/sink.h')
1 files changed, 7 insertions, 0 deletions
diff --git a/src/pulsecore/sink.h b/src/pulsecore/sink.h
index 7a8cdaf1..13033960 100644
--- a/src/pulsecore/sink.h
+++ b/src/pulsecore/sink.h
@@ -42,6 +42,7 @@ typedef struct pa_device_port pa_device_port;
#include <pulsecore/rtpoll.h>
#include <pulsecore/card.h>
#include <pulsecore/queue.h>
+#include <pulsecore/thread-mq.h>
@@ -343,4 +344,10 @@ pa_usec_t pa_sink_get_latency_within_thread(pa_sink *s);
pa_device_port *pa_device_port_new(const char *name, const char *description, size_t extra);
void pa_device_port_free(pa_device_port *p);
+/* Verify that we called in IO context (aka 'thread context), or that
+ * the sink is not yet set up, i.e. the thread not set up yet. See
+ * pa_assert_io_context() in thread-mq.h for more information. */
+#define pa_sink_assert_io_context(s) \
+ pa_assert(pa_thread_mq_get() || !PA_SINK_IS_LINKED((s)->state))