diff options
author | Paul W. Frields <stickster@gmail.com> | 2009-05-25 00:41:27 -0400 |
---|---|---|
committer | Paul W. Frields <stickster@gmail.com> | 2009-05-25 00:41:27 -0400 |
commit | 7a964786c3ca2d3618af00f58c23dcb417f4a638 (patch) | |
tree | aae2efce214257af4c0162a2e9d2a12a8257bd0f | |
parent | 4ad365f6a4504c59df84a31fe6b63476111406da (diff) | |
download | pulsecaster-7a964786c3ca2d3618af00f58c23dcb417f4a638.tar.gz pulsecaster-7a964786c3ca2d3618af00f58c23dcb417f4a638.tar.xz pulsecaster-7a964786c3ca2d3618af00f58c23dcb417f4a638.zip |
Add some additional functionality for event subscription
-rw-r--r-- | pulseaudio/PulseObj.py | 22 | ||||
-rw-r--r-- | pulseaudio/lib_pulseaudio.py | 53 |
2 files changed, 75 insertions, 0 deletions
diff --git a/pulseaudio/PulseObj.py b/pulseaudio/PulseObj.py index 71be183..ea3af22 100644 --- a/pulseaudio/PulseObj.py +++ b/pulseaudio/PulseObj.py @@ -269,6 +269,13 @@ class PulseObj: ### + def py_context_set_subscribe_cb(self, c, cb, userdata): + "Set subscribe callback" + #print "py_context_set_subscribe_cb:", c, cb, userdata + return + + ### + def py_context_success(self, c, success, userdata): if success == 0: None @@ -542,6 +549,21 @@ class PulseObj: ### + def pulse_context_subscribe(self, c, mask, success, userdata): + "Subscribe to event" + self.start_action() + #print "pulse_context_subscribe:", c, mask, success, userdata + PA_CONTEXT_SUBSCRIBE_CB = PA_CONTEXT_SUBSCRIBE_CB_T(self.py_context_set_subscribe_cb) + + self.operation = pa_context_subscribe(self.context, + mask, + PA_CONTEXT_SUCCESS_CB, + None) + self.pulse_iterate() + return + + ### + def reconnect(self): self.context = pa_context_new(self.mainloop_api, clientName) diff --git a/pulseaudio/lib_pulseaudio.py b/pulseaudio/lib_pulseaudio.py index 9892374..ace301f 100644 --- a/pulseaudio/lib_pulseaudio.py +++ b/pulseaudio/lib_pulseaudio.py @@ -258,6 +258,40 @@ PA_CONTEXT_SUCCESS_CB_T = CFUNCTYPE(c_void_p, c_int, c_void_p) +# Subscriptions +(PA_SUBSCRIPTION_EVENT_SINK, + PA_SUBSCRIPTION_EVENT_SOURCE, + PA_SUBSCRIPTION_EVENT_SINK_INPUT, + PA_SUBSCRIPTION_EVENT_SOURCE_OUTPUT, + PA_SUBSCRIPTION_EVENT_MODULE, + PA_SUBSCRIPTION_EVENT_CLIENT, + PA_SUBSCRIPTION_EVENT_SAMPLE_CACHE, + PA_SUBSCRIPTION_EVENT_SERVER, + PA_SUBSCRIPTION_EVENT_CARD, + PA_SUBSCRIPTION_EVENT_FACILITY_MASK, + PA_SUBSCRIPTION_EVENT_NEW, + PA_SUBSCRIPTION_EVENT_CHANGE, + PA_SUBSCRIPTION_EVENT_REMOVE, + PA_SUBSCRIPTION_EVENT_TYPE_MASK) = map(c_int, xrange(14)) + +(PA_SUBSCRIPTION_MASK_NULL, + PA_SUBSCRIPTION_MASK_SINK, + PA_SUBSCRIPTION_MASK_SOURCE, + PA_SUBSCRIPTION_MASK_SINK_INPUT, + PA_SUBSCRIPTION_MASK_SOURCE_OUTPUT, + PA_SUBSCRIPTION_MASK_MODULE, + PA_SUBSCRIPTION_MASK_CLIENT, + PA_SUBSCRIPTION_MASK_SAMPLE_CACHE, + PA_SUBSCRIPTION_MASK_SERVER, + PA_SUBSCRIPTION_MASK_CARD, + PA_SUBSCRIPTION_MASK_ALL) = map(c_int, xrange(11)) + +PA_CONTEXT_SUBSCRIBE_CB_T = CFUNCTYPE(c_void_p, + POINTER(PA_CONTEXT), + c_int, + c_void_p) + + ################################################################################ # # Functions @@ -504,6 +538,25 @@ pa_context_get_client_info.argtypes = [ ] # +# pa_context_*_subscribe* +pa_context_set_subscribe_callback = pulse.pa_context_set_subscribe_callback +pa_context_set_subscribe_callback.restype = c_int +pa_context_set_subscribe_callback.argtypes = [ + POINTER(PA_CONTEXT), + c_int, + c_uint32, + c_void_p +] + +pa_context_subscribe = pulse.pa_context_subscribe +pa_context_subscribe.restype = c_int +pa_context_subscribe.argtypes = [ + POINTER(PA_CONTEXT), + c_int, + c_void_p +] + +# # pa_operation_* pa_operation_unref = pulse.pa_operation_unref pa_operation_unref.restype = c_int |