summaryrefslogtreecommitdiffstats
path: root/src/polyp/subscribe.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2006-02-20 22:41:02 +0000
committerLennart Poettering <lennart@poettering.net>2006-02-20 22:41:02 +0000
commit71b3bff6816b857a6a9613cc45b06f0b9e5a65e1 (patch)
treea9a7ed11a43b0069a04234b481a2466ccd7fc198 /src/polyp/subscribe.c
parent98cb6aa4a30a993ddf2c15f0a03cb4d94383d4d9 (diff)
* modify pa_context_exit_daemon() to return a pa_operation object
* add callback prototypes to all introspection functions in client lib * add proper validity checking and error handling to all functions in the client lib * other minor cleanups * todo update git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@531 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'src/polyp/subscribe.c')
-rw-r--r--src/polyp/subscribe.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/polyp/subscribe.c b/src/polyp/subscribe.c
index 97f76cb7..65849b6d 100644
--- a/src/polyp/subscribe.c
+++ b/src/polyp/subscribe.c
@@ -37,7 +37,11 @@ void pa_command_subscribe_event(pa_pdispatch *pd, uint32_t command, PA_GCC_UNUSE
pa_context *c = userdata;
pa_subscription_event_type_t e;
uint32_t index;
- assert(pd && command == PA_COMMAND_SUBSCRIBE_EVENT && t && c);
+
+ assert(pd);
+ assert(command == PA_COMMAND_SUBSCRIBE_EVENT);
+ assert(t);
+ assert(c);
pa_context_ref(c);
@@ -60,24 +64,28 @@ pa_operation* pa_context_subscribe(pa_context *c, pa_subscription_mask_t m, pa_c
pa_operation *o;
pa_tagstruct *t;
uint32_t tag;
+
assert(c);
+ assert(c->ref >= 1);
- o = pa_operation_new(c, NULL);
- o->callback = (pa_operation_callback_t) cb;
- o->userdata = userdata;
+ PA_CHECK_VALIDITY_RETURN_NULL(c, c->state == PA_CONTEXT_READY, PA_ERR_BADSTATE);
+
+ o = pa_operation_new(c, NULL, (pa_operation_cb_t) cb, userdata);
t = pa_tagstruct_new(NULL, 0);
pa_tagstruct_putu32(t, PA_COMMAND_SUBSCRIBE);
pa_tagstruct_putu32(t, tag = c->ctag++);
pa_tagstruct_putu32(t, m);
pa_pstream_send_tagstruct(c->pstream, t);
- pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, o);
+ pa_pdispatch_register_reply(c->pdispatch, tag, DEFAULT_TIMEOUT, pa_context_simple_ack_callback, pa_operation_ref(o));
- return pa_operation_ref(o);
+ return o;
}
void pa_context_set_subscribe_callback(pa_context *c, pa_context_subscribe_cb_t cb, void *userdata) {
assert(c);
+ assert(c->ref >= 1);
+
c->subscribe_callback = cb;
c->subscribe_userdata = userdata;
}