mirror of
https://gitlab.freedesktop.org/pipewire/helvum
synced 2026-03-15 11:36:11 +08:00
Toggle links on and off when ports are connected by the user.
This extends the `Application` struct to keep more advanced state. This state is then used to determine the needed information to create or delete a link between the two connected ports. A message to create/delete the link is then send to the pipewire thread, which executed the request.
This commit is contained in:
12
src/main.rs
12
src/main.rs
@@ -10,14 +10,18 @@ use gtk::{
|
||||
use pipewire::spa::Direction;
|
||||
|
||||
/// Messages used GTK thread to command the pipewire thread.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
enum GtkMessage {
|
||||
/// Create a new link.
|
||||
CreateLink(PipewireLink),
|
||||
/// Destroy the global with the specified id.
|
||||
DestroyGlobal(u32),
|
||||
/// Quit the event loop and let the thread finish.
|
||||
Terminate,
|
||||
}
|
||||
|
||||
/// Messages used pipewire thread to notify the GTK thread.
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
enum PipewireMessage {
|
||||
/// A new node has appeared.
|
||||
NodeAdded {
|
||||
@@ -38,7 +42,7 @@ enum PipewireMessage {
|
||||
ObjectRemoved { id: u32 },
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct PipewireLink {
|
||||
pub node_from: u32,
|
||||
pub port_from: u32,
|
||||
@@ -56,7 +60,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
let pw_thread =
|
||||
std::thread::spawn(move || pipewire_connection::thread_main(gtk_sender, pw_receiver));
|
||||
|
||||
let app = application::Application::new(gtk_receiver);
|
||||
let app = application::Application::new(gtk_receiver, pw_sender.clone());
|
||||
|
||||
app.run(&std::env::args().collect::<Vec<_>>());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user