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):

Be careful when using this code, it's not being tested!
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:

Be careful when using this code, it's not being tested!
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 EventType. You can extract the facility portion of the EventType value using get_facility.

Operation

Operation variants for an EventType. You can extract the operation portion of the EventType value using get_operation.

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 EventType value

get_operation

Extract operation from EventType value

make_eventtype

Combine facility and operation to form an EventType value.

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 Context::subscribe. Convert a Facility to a mask with facility_to_mask.