update Helvum to track the latest pipewire0.8.0

update Helvum to track the latest pipewire0.8.0
This commit is contained in:
Dorinda Bassey
2024-03-19 14:06:57 +01:00
parent 4549ba6ff5
commit d1b9b0f11f
9 changed files with 108 additions and 76 deletions

104
Cargo.lock generated
View File

@@ -11,6 +11,16 @@ dependencies = [
"memchr",
]
[[package]]
name = "annotate-snippets"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ccaf7e9dfbb6ab22c82e473cd1a8a7bd313c19a5b7e40970f3d89ef5a5c9e81e"
dependencies = [
"unicode-width",
"yansi-term",
]
[[package]]
name = "anyhow"
version = "1.0.75"
@@ -25,16 +35,17 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa"
[[package]]
name = "bindgen"
version = "0.66.1"
version = "0.69.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0"
dependencies = [
"bitflags 2.4.0",
"annotate-snippets",
"bitflags",
"cexpr",
"clang-sys",
"itertools",
"lazy_static",
"lazycell",
"peeking_take_while",
"proc-macro2",
"quote",
"regex",
@@ -43,12 +54,6 @@ dependencies = [
"syn 2.0.37",
]
[[package]]
name = "bitflags"
version = "1.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
[[package]]
name = "bitflags"
version = "2.4.0"
@@ -61,7 +66,7 @@ version = "0.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c0466dfa8c0ee78deef390c274ad756801e0a6dbb86c5ef0924a298c5761c4d"
dependencies = [
"bitflags 2.4.0",
"bitflags",
"cairo-sys-rs",
"glib",
"libc",
@@ -140,6 +145,12 @@ version = "0.3.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "396de984970346b0d9e93d1415082923c679e5ae5c3ee3dcbd104f5610af126b"
[[package]]
name = "either"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a"
[[package]]
name = "equivalent"
version = "1.0.1"
@@ -152,7 +163,7 @@ version = "0.3.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
dependencies = [
"memoffset 0.9.0",
"memoffset",
"rustc_version",
]
@@ -315,7 +326,7 @@ version = "0.18.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1c316afb01ce8067c5eaab1fc4f2cd47dc21ce7b6296358605e2ffab23ccbd19"
dependencies = [
"bitflags 2.4.0",
"bitflags",
"futures-channel",
"futures-core",
"futures-executor",
@@ -516,6 +527,15 @@ dependencies = [
"hashbrown",
]
[[package]]
name = "itertools"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569"
dependencies = [
"either",
]
[[package]]
name = "lazy_static"
version = "1.4.0"
@@ -578,11 +598,11 @@ dependencies = [
[[package]]
name = "libspa"
version = "0.7.2"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0434617020ddca18b86067912970c55410ca654cdafd775480322f50b857a8c4"
checksum = "65f3a4b81b2a2d8c7f300643676202debd1b7c929dbf5c9bb89402ea11d19810"
dependencies = [
"bitflags 2.4.0",
"bitflags",
"cc",
"convert_case",
"cookie-factory",
@@ -595,9 +615,9 @@ dependencies = [
[[package]]
name = "libspa-sys"
version = "0.7.2"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b3e70ca3f3e70f858ef363046d06178c427b4e0b63d210c95fd87d752679d345"
checksum = "bf0d9716420364790e85cbb9d3ac2c950bde16a7dd36f3209b7dfdfc4a24d01f"
dependencies = [
"bindgen",
"cc",
@@ -616,15 +636,6 @@ version = "2.6.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c"
[[package]]
name = "memoffset"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4"
dependencies = [
"autocfg",
]
[[package]]
name = "memoffset"
version = "0.9.0"
@@ -642,15 +653,13 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
[[package]]
name = "nix"
version = "0.26.4"
version = "0.27.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b"
checksum = "2eb04e9c688eff1c89d72b407f168cf79bb9e867a9d3323ed6c01519eb9cc053"
dependencies = [
"bitflags 1.3.2",
"bitflags",
"cfg-if",
"libc",
"memoffset 0.7.1",
"pin-utils",
]
[[package]]
@@ -694,12 +703,6 @@ dependencies = [
"system-deps",
]
[[package]]
name = "peeking_take_while"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
[[package]]
name = "pin-project-lite"
version = "0.2.13"
@@ -714,12 +717,12 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
[[package]]
name = "pipewire"
version = "0.7.2"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2d009c8dd65e890b515a71950f7e4c801523b8894ff33863a40830bf762e9e9"
checksum = "08e645ba5c45109106d56610b3ee60eb13a6f2beb8b74f8dc8186cf261788dda"
dependencies = [
"anyhow",
"bitflags 2.4.0",
"bitflags",
"libc",
"libspa",
"libspa-sys",
@@ -731,9 +734,9 @@ dependencies = [
[[package]]
name = "pipewire-sys"
version = "0.7.2"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "890c084e7b737246cb4799c86b71a0e4da536031ff7473dd639eba9f95039f64"
checksum = "849e188f90b1dda88fe2bfe1ad31fe5f158af2c98f80fb5d13726c44f3f01112"
dependencies = [
"bindgen",
"libspa-sys",
@@ -1005,6 +1008,12 @@ version = "1.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36"
[[package]]
name = "unicode-width"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e51733f11c9c4f72aa0c160008246859e340b00807569a0da0e7a1079b27ba85"
[[package]]
name = "version-compare"
version = "0.1.1"
@@ -1047,3 +1056,12 @@ checksum = "7c2e3184b9c4e92ad5167ca73039d0c42476302ab603e2fec4487511f38ccefc"
dependencies = [
"memchr",
]
[[package]]
name = "yansi-term"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fe5c30ade05e61656247b2e334a031dfd0cc466fadef865bdcdea8d537951bf1"
dependencies = [
"winapi",
]

View File

@@ -14,7 +14,7 @@ categories = ["gui", "multimedia"]
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
pipewire = "0.7.1"
pipewire = "0.8.0"
adw = { version = "0.5", package = "libadwaita", features = ["v1_4"] }
glib = { version = "0.18", features = ["log"] }

View File

@@ -130,7 +130,13 @@ mod imp {
}
/// Add a new port to the view.
fn add_port(&self, id: u32, name: &str, node_id: u32, direction: pipewire::spa::Direction) {
fn add_port(
&self,
id: u32,
name: &str,
node_id: u32,
direction: pipewire::spa::utils::Direction,
) {
log::info!("Adding port to graph: id {}", id);
let mut items = self.items.borrow_mut();
@@ -273,7 +279,11 @@ mod imp {
link.set_active(active);
}
fn link_format_changed(&self, id: u32, media_type: pipewire::spa::format::MediaType) {
fn link_format_changed(
&self,
id: u32,
media_type: pipewire::spa::param::format::MediaType,
) {
let items = self.items.borrow();
let Some(link) = items.get(&id) else {

View File

@@ -20,7 +20,7 @@ mod pipewire_connection;
mod ui;
use adw::{gtk, prelude::*};
use pipewire::spa::{format::MediaType, Direction};
use pipewire::spa::{param::format::MediaType, utils::Direction};
/// Messages sent by the GTK thread to notify the pipewire thread.
#[derive(Debug, Clone)]

View File

@@ -26,19 +26,21 @@ use std::{
use adw::glib::{self, clone};
use log::{debug, error, info, warn};
use pipewire::{
context::Context,
core::{Core, PW_ID_CORE},
keys,
link::{Link, LinkChangeMask, LinkInfo, LinkListener, LinkState},
node::{Node, NodeInfo, NodeListener},
port::{Port, PortChangeMask, PortInfo, PortListener},
prelude::*,
properties,
link::{Link, LinkChangeMask, LinkInfoRef, LinkListener, LinkState},
main_loop::MainLoop,
node::{Node, NodeInfoRef, NodeListener},
port::{Port, PortChangeMask, PortInfoRef, PortListener},
properties::properties,
registry::{GlobalObject, Registry},
spa::{
param::{ParamInfoFlags, ParamType},
ForeignDict, SpaResult,
utils::dict::DictRef,
utils::result::SpaResult,
},
types::ObjectType,
Context, Core, MainLoop,
};
use crate::{GtkMessage, MediaType, NodeType, PipewireMessage};
@@ -64,7 +66,7 @@ pub(super) fn thread_main(
gtk_sender: glib::Sender<PipewireMessage>,
mut pw_receiver: pipewire::channel::Receiver<GtkMessage>,
) {
let mainloop = MainLoop::new().expect("Failed to create mainloop");
let mainloop = MainLoop::new(None).expect("Failed to create mainloop");
let context = Rc::new(Context::new(&mainloop).expect("Failed to create context"));
let is_stopped = Rc::new(Cell::new(false));
let mut is_connecting = false;
@@ -86,13 +88,15 @@ pub(super) fn thread_main(
// If connection is failed, try to connect again in 200ms
let interval = Some(Duration::from_millis(200));
let timer = mainloop.add_timer(clone!(@strong mainloop => move |_| {
let timer = mainloop
.loop_()
.add_timer(clone!(@strong mainloop => move |_| {
mainloop.quit();
}));
timer.update_timer(interval, None).into_result().unwrap();
let receiver = pw_receiver.attach(&mainloop, {
let receiver = pw_receiver.attach(mainloop.loop_(), {
clone!(@strong mainloop, @strong is_stopped => move |msg|
if let GtkMessage::Terminate = msg {
// main thread requested stop
@@ -122,7 +126,7 @@ pub(super) fn thread_main(
let proxies = Rc::new(RefCell::new(HashMap::new()));
let state = Rc::new(RefCell::new(State::new()));
let receiver = pw_receiver.attach(&mainloop, {
let receiver = pw_receiver.attach(mainloop.loop_(), {
clone!(@strong mainloop, @weak core, @weak registry, @strong state, @strong is_stopped => move |msg| match msg {
GtkMessage::ToggleLink { port_from, port_to } => toggle_link(port_from, port_to, &core, &registry, &state),
GtkMessage::Terminate => {
@@ -136,7 +140,7 @@ pub(super) fn thread_main(
let gtk_sender = gtk_sender.clone();
let _listener = core.add_listener_local()
.error(clone!(@strong mainloop, @strong gtk_sender, @strong is_stopped => move |id, _seq, res, message| {
if id != pipewire::PW_ID_CORE {
if id != PW_ID_CORE {
return;
}
@@ -187,7 +191,7 @@ pub(super) fn thread_main(
}
/// Get the nicest possible name for the node, using a fallback chain of possible name attributes
fn get_node_name(props: &ForeignDict) -> &str {
fn get_node_name(props: &DictRef) -> &str {
props
.get(&keys::NODE_DESCRIPTION)
.or_else(|| props.get(&keys::NODE_NICK))
@@ -197,7 +201,7 @@ fn get_node_name(props: &ForeignDict) -> &str {
/// Handle a new node being added
fn handle_node(
node: &GlobalObject<ForeignDict>,
node: &GlobalObject<&DictRef>,
sender: &glib::Sender<PipewireMessage>,
registry: &Rc<Registry>,
proxies: &Rc<RefCell<HashMap<u32, ProxyItem>>>,
@@ -258,7 +262,7 @@ fn handle_node(
}
fn handle_node_info(
info: &NodeInfo,
info: &NodeInfoRef,
sender: &glib::Sender<PipewireMessage>,
proxies: &Rc<RefCell<HashMap<u32, ProxyItem>>>,
) {
@@ -287,7 +291,7 @@ fn handle_node_info(
/// Handle a new port being added
fn handle_port(
port: &GlobalObject<ForeignDict>,
port: &GlobalObject<&DictRef>,
sender: &glib::Sender<PipewireMessage>,
registry: &Rc<Registry>,
proxies: &Rc<RefCell<HashMap<u32, ProxyItem>>>,
@@ -319,7 +323,7 @@ fn handle_port(
}
fn handle_port_info(
info: &PortInfo,
info: &PortInfoRef,
proxies: &Rc<RefCell<HashMap<u32, ProxyItem>>>,
state: &Rc<RefCell<State>>,
sender: &glib::Sender<PipewireMessage>,
@@ -393,7 +397,7 @@ fn handle_port_enum_format(
/// Handle a new link being added
fn handle_link(
link: &GlobalObject<ForeignDict>,
link: &GlobalObject<&DictRef>,
sender: &glib::Sender<PipewireMessage>,
registry: &Rc<Registry>,
proxies: &Rc<RefCell<HashMap<u32, ProxyItem>>>,
@@ -422,7 +426,7 @@ fn handle_link(
}
fn handle_link_info(
info: &LinkInfo,
info: &LinkInfoRef,
state: &Rc<RefCell<State>>,
sender: &glib::Sender<PipewireMessage>,
) {
@@ -495,7 +499,7 @@ fn toggle_link(
.get_node_of_port(port_to)
.expect("Requested port not in state");
if let Err(e) = core.create_object::<Link, _>(
if let Err(e) = core.create_object::<Link>(
"link-factory",
&properties! {
"link.output.node" => node_from.to_string(),
@@ -510,7 +514,7 @@ fn toggle_link(
}
}
fn get_link_media_type(link_info: &LinkInfo) -> MediaType {
fn get_link_media_type(link_info: &LinkInfoRef) -> MediaType {
let media_type = link_info
.format()
.and_then(|format| pipewire::spa::param::format_utils::parse_format(format).ok())

View File

@@ -42,8 +42,8 @@ mod imp {
use adw::gtk::gdk::{self};
use log::warn;
use once_cell::sync::Lazy;
use pipewire::spa::format::MediaType;
use pipewire::spa::Direction;
use pipewire::spa::param::format::MediaType;
use pipewire::spa::utils::Direction;
pub struct Colors {
audio: gdk::RGBA,

View File

@@ -15,7 +15,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use adw::{glib, prelude::*, subclass::prelude::*};
use pipewire::spa::format::MediaType;
use pipewire::spa::param::format::MediaType;
use super::Port;

View File

@@ -15,7 +15,7 @@
// SPDX-License-Identifier: GPL-3.0-only
use adw::{glib, gtk, prelude::*, subclass::prelude::*};
use pipewire::spa::Direction;
use pipewire::spa::utils::Direction;
use super::Port;

View File

@@ -21,7 +21,7 @@ use adw::{
prelude::*,
subclass::prelude::*,
};
use pipewire::spa::Direction;
use pipewire::spa::utils::Direction;
use super::PortHandle;
@@ -31,7 +31,7 @@ mod imp {
use std::cell::Cell;
use once_cell::{sync::Lazy, unsync::OnceCell};
use pipewire::spa::{format::MediaType, Direction};
use pipewire::spa::{param::format::MediaType, utils::Direction};
/// Graphical representation of a pipewire port.
#[derive(gtk::CompositeTemplate, glib::Properties)]