Module libpulse_binding::context::subscribe
[−]
[src]
Daemon introspection event subscription subsystem.
Overview
The application can be notified, asynchronously, whenever the internal layout of the server
changes. The set of facilities and operations for which notifications are generated are
enumerated in Facility
and Operation
.
The application sets the notification mask using ::context::Context::subscribe
and the
callback function that will be called whenever a notification occurs using
::context::Context::set_subscribe_callback
.
The mask provided to ::context::Context::subscribe
can be created by binary ORing a set of
values produced with facility_to_mask
.
The callback will be called with an EventType
representing the event that caused the
callback. Clients can examine what type of object (facility) changed using get_facility
. The
actual event type can then be extracted with get_operation
.
Example
Subscribe (declare interest):
use pulse::context::subscribe::subscription_masks; let interest = subscription_masks::SINK | subscription_masks::SOURCE; let op = my_context.subscribe( interest, // Our interest mask None // We won't bother with a success callback in this example );
A callback:
use std::os::raw::c_void; use pulse::context::ContextInternal; use pulse::context::subscribe::*; extern "C" fn my_subscription_callback( _: *mut ContextInternal, // Ignoring context pointer t: EventType, // The combined facility and operation _: u32, // Ignoring index _: *mut c_void) // Ignoring userdata pointer { if get_facility(t).unwrap() == Facility::Source && get_operation(t).unwrap() == Operation::New { //... a source was added, let's do stuff! ... } }
Modules
subscription_masks |
A set of masks used for expressing which facilities you are interested in when subscribing. |
Enums
Facility |
Facility variants for an |
Operation |
Operation variants for an |
Constants
FACILITY_MASK |
Mask to extract facility value from the event type passed to the user callback. |
OPERATION_MASK |
Mask to extract operation value from the event type passed to the user callback. |
Functions
facility_to_mask |
Convert facility to mask |
get_facility |
Extract facility from |
get_operation |
Extract operation from |
make_eventtype |
Combine facility and operation to form an |
Type Definitions
Callback |
Subscription event callback prototype |
EventType |
The base integer type passed to the callback, from which the facility and operation components can be extracted. |
InterestMaskSet |
A set of facility masks, passed to
|