mirror of
https://gitlab.freedesktop.org/pipewire/helvum
synced 2026-03-15 11:36:11 +08:00
Modify architecture to run pipewire loop in second thread.
The pipewire loop now runs without interruption in a second thread and communicates with the GTK thread via a channel in each direction, instead of checking for events once a second and using callbacks. This allows changes to appear instantly in the view, instead of having to wait.
This commit is contained in:
@@ -13,7 +13,7 @@ use gtk::{
|
||||
glib::{self, clone},
|
||||
prelude::*,
|
||||
};
|
||||
use pipewire::port::Direction;
|
||||
use pipewire::spa::Direction;
|
||||
|
||||
use crate::controller::MediaType;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::graph_view::GraphView;
|
||||
|
||||
use gtk::{glib, prelude::*, subclass::prelude::*, WidgetExt};
|
||||
use pipewire::port::Direction;
|
||||
use pipewire::spa::Direction;
|
||||
|
||||
use std::{collections::HashMap, rc::Rc};
|
||||
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
use gtk::{glib, prelude::*, subclass::prelude::*};
|
||||
use pipewire::spa::Direction;
|
||||
|
||||
use crate::controller::MediaType;
|
||||
|
||||
mod imp {
|
||||
use once_cell::unsync::OnceCell;
|
||||
use pipewire::spa::Direction;
|
||||
|
||||
use super::*;
|
||||
|
||||
@@ -11,7 +13,7 @@ mod imp {
|
||||
#[derive(Default)]
|
||||
pub struct Port {
|
||||
pub(super) id: OnceCell<u32>,
|
||||
pub(super) direction: OnceCell<pipewire::port::Direction>,
|
||||
pub(super) direction: OnceCell<Direction>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
@@ -32,12 +34,7 @@ glib::wrapper! {
|
||||
}
|
||||
|
||||
impl Port {
|
||||
pub fn new(
|
||||
id: u32,
|
||||
name: &str,
|
||||
direction: pipewire::port::Direction,
|
||||
media_type: Option<MediaType>,
|
||||
) -> Self {
|
||||
pub fn new(id: u32, name: &str, direction: Direction, media_type: Option<MediaType>) -> Self {
|
||||
// Create the widget and initialize needed fields
|
||||
let res: Self = glib::Object::new(&[]).expect("Failed to create Port");
|
||||
let private = imp::Port::from_instance(&res);
|
||||
@@ -60,7 +57,7 @@ impl Port {
|
||||
res
|
||||
}
|
||||
|
||||
pub fn direction(&self) -> &pipewire::port::Direction {
|
||||
pub fn direction(&self) -> &Direction {
|
||||
let private = imp::Port::from_instance(self);
|
||||
private.direction.get().expect("Port direction is not set")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user