Module wireplumber::signals

source ·
Available on crate feature glib-signal only.
Expand description

glib_signal types

These should not need to be used directly. Instead, use an associated const:

use futures_util::StreamExt;
use wireplumber::{
  prelude::*,
  registry::{ObjectManager, Interest},
  core::{Core, Object, ObjectFeatures},
  pw::Node,
};

async fn watch_nodes(core: &Core) {
  let om = ObjectManager::new();
  om.add_interest(Interest::<Node>::new());

  // register a callback for a signal...
  om.handle(ObjectManager::SIGNAL_INSTALLED, |om, ()| {
    println!("{om:?} installed");
  });
  // ... or receive events as an async Stream:
  let mut objects = om.signal_stream(ObjectManager::SIGNAL_OBJECT_ADDED);

  om.request_object_features(Node::static_type(), ObjectFeatures::ALL);
  core.install_object_manager(&om);

  while let Some((obj,)) = objects.next().await {
    let node = obj.dynamic_cast_ref::<Node>()
      .expect("we're only interested in nodes");
    println!("new object: {node:?}");
  }
}

Structs§