mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-12 08:28:32 +02:00
fix: Use threading for every single dbus call on audio
This commit is contained in:
parent
ed905cd075
commit
af06f8da32
|
@ -1042,14 +1042,14 @@
|
||||||
{
|
{
|
||||||
"type": "archive",
|
"type": "archive",
|
||||||
"archive-type": "tar-gzip",
|
"archive-type": "tar-gzip",
|
||||||
"url": "https://static.crates.io/crates/reset_daemon/reset_daemon-0.1.3.crate",
|
"url": "https://static.crates.io/crates/reset_daemon/reset_daemon-0.1.4.crate",
|
||||||
"sha256": "1d7b1c575b773eadd0fc8991de8abb883cfb7bce9c5e8c4f9e10b85cb142efee",
|
"sha256": "2978104d24796489f84a2636a8797730bfeac5693a5550751b1fd638dd7bea58",
|
||||||
"dest": "cargo/vendor/reset_daemon-0.1.3"
|
"dest": "cargo/vendor/reset_daemon-0.1.4"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "inline",
|
"type": "inline",
|
||||||
"contents": "{\"package\": \"1d7b1c575b773eadd0fc8991de8abb883cfb7bce9c5e8c4f9e10b85cb142efee\", \"files\": {}}",
|
"contents": "{\"package\": \"2978104d24796489f84a2636a8797730bfeac5693a5550751b1fd638dd7bea58\", \"files\": {}}",
|
||||||
"dest": "cargo/vendor/reset_daemon-0.1.3",
|
"dest": "cargo/vendor/reset_daemon-0.1.4",
|
||||||
"dest-filename": ".cargo-checksum.json"
|
"dest-filename": ".cargo-checksum.json"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dbus::blocking::Connection;
|
||||||
use dbus::Error;
|
use dbus::Error;
|
||||||
use glib::subclass::types::ObjectSubclassIsExt;
|
use glib::subclass::types::ObjectSubclassIsExt;
|
||||||
use glib::{clone, Cast, Propagation};
|
use glib::{clone, Cast, Propagation};
|
||||||
use gtk::StringObject;
|
use gtk::{gio, StringObject};
|
||||||
use ReSet_Lib::audio::audio::OutputStream;
|
use ReSet_Lib::audio::audio::OutputStream;
|
||||||
|
|
||||||
use super::outputStreamEntryImpl;
|
use super::outputStreamEntryImpl;
|
||||||
|
@ -125,52 +125,63 @@ impl OutputStreamEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_outputstream_volume(value: f64, index: u32, channels: u16) -> bool {
|
fn set_outputstream_volume(value: f64, index: u32, channels: u16) -> bool {
|
||||||
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.xetibo.ReSet",
|
||||||
"/org/xetibo/ReSet",
|
"/org/xetibo/ReSet",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(bool,), Error> = proxy.method_call(
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.xetibo.ReSet",
|
||||||
"SetOutputStreamVolume",
|
"SetOutputStreamVolume",
|
||||||
(index, channels, value as u32),
|
(index, channels, value as u32),
|
||||||
);
|
);
|
||||||
if res.is_err() {
|
// if res.is_err() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
res.unwrap().0
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_output_stream_mute(index: u32, muted: bool) -> bool {
|
fn toggle_output_stream_mute(index: u32, muted: bool) -> bool {
|
||||||
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.xetibo.ReSet",
|
||||||
"/org/xetibo/ReSet",
|
"/org/xetibo/ReSet",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(bool,), Error> =
|
let _: Result<(), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "SetOutputStreamMute", (index, muted));
|
proxy.method_call("org.xetibo.ReSet", "SetOutputStreamMute", (index, muted));
|
||||||
if res.is_err() {
|
// if res.is_err() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
res.unwrap().0
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_source_of_output_stream(stream: u32, source: u32) -> bool {
|
fn set_source_of_output_stream(stream: u32, source: u32) -> bool {
|
||||||
let conn = Connection::new_session().unwrap();
|
gio::spawn_blocking(move || {
|
||||||
let proxy = conn.with_proxy(
|
let conn = Connection::new_session().unwrap();
|
||||||
"org.xetibo.ReSet",
|
let proxy = conn.with_proxy(
|
||||||
"/org/xetibo/ReSet",
|
"org.xetibo.ReSet",
|
||||||
Duration::from_millis(1000),
|
"/org/xetibo/ReSet",
|
||||||
);
|
Duration::from_millis(1000),
|
||||||
let res: Result<(bool,), Error> = proxy.method_call(
|
);
|
||||||
"org.xetibo.ReSet",
|
let _: Result<(bool,), Error> = proxy.method_call(
|
||||||
"SetSourceOfOutputStream",
|
"org.xetibo.ReSet",
|
||||||
(stream, source),
|
"SetSourceOfOutputStream",
|
||||||
);
|
(stream, source),
|
||||||
if res.is_err() {
|
);
|
||||||
return false;
|
// if res.is_err() {
|
||||||
}
|
// return false;
|
||||||
res.unwrap().0
|
// }
|
||||||
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO propagate error from dbus
|
||||||
|
|
|
@ -4,13 +4,13 @@ use std::time::Duration;
|
||||||
|
|
||||||
use adw::glib;
|
use adw::glib;
|
||||||
use adw::glib::Object;
|
use adw::glib::Object;
|
||||||
use adw::prelude::{ButtonExt, RangeExt, CheckButtonExt};
|
use adw::prelude::{ButtonExt, CheckButtonExt, RangeExt};
|
||||||
use dbus::blocking::Connection;
|
use dbus::blocking::Connection;
|
||||||
use dbus::Error;
|
use dbus::Error;
|
||||||
use glib::subclass::types::ObjectSubclassIsExt;
|
use glib::subclass::types::ObjectSubclassIsExt;
|
||||||
use glib::{clone, Propagation};
|
use glib::{clone, Propagation};
|
||||||
|
use gtk::{gio, CheckButton};
|
||||||
use ReSet_Lib::audio::audio::Source;
|
use ReSet_Lib::audio::audio::Source;
|
||||||
use gtk::CheckButton;
|
|
||||||
|
|
||||||
use super::sourceEntryImpl;
|
use super::sourceEntryImpl;
|
||||||
|
|
||||||
|
@ -80,51 +80,60 @@ impl SourceEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_source_volume(value: f64, index: u32, channels: u16) -> bool {
|
pub fn set_source_volume(value: f64, index: u32, channels: u16) -> bool {
|
||||||
|
gio::spawn_blocking(move || {
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.xetibo.ReSet",
|
||||||
"/org/xetibo/ReSet",
|
"/org/xetibo/ReSet",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(bool,), Error> = proxy.method_call(
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
"org.xetibo.ReSet",
|
"org.xetibo.ReSet",
|
||||||
"SetSourceVolume",
|
"SetSourceVolume",
|
||||||
(index, channels, value as u32),
|
(index, channels, value as u32),
|
||||||
);
|
);
|
||||||
if res.is_err() {
|
// if res.is_err() {
|
||||||
return false;
|
// return false;
|
||||||
}
|
// }
|
||||||
res.unwrap().0
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn toggle_source_mute(index: u32, muted: bool) -> bool {
|
pub fn toggle_source_mute(index: u32, muted: bool) -> bool {
|
||||||
let conn = Connection::new_session().unwrap();
|
gio::spawn_blocking(move || {
|
||||||
let proxy = conn.with_proxy(
|
|
||||||
"org.xetibo.ReSet",
|
|
||||||
"/org/xetibo/ReSet",
|
|
||||||
Duration::from_millis(1000),
|
|
||||||
);
|
|
||||||
let res: Result<(bool,), Error> =
|
|
||||||
proxy.method_call("org.xetibo.ReSet", "SetSourceMute", (index, muted));
|
|
||||||
if res.is_err() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res.unwrap().0
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_default_source(name: Arc<String>) {
|
|
||||||
thread::spawn(move || {
|
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.xetibo.ReSet",
|
||||||
"/org/xetibo/ReSet",
|
"/org/xetibo/ReSet",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(bool,), Error> =
|
let _: Result<(), Error> =
|
||||||
|
proxy.method_call("org.xetibo.ReSet", "SetSourceMute", (index, muted));
|
||||||
|
// if res.is_err() {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_default_source(name: Arc<String>) -> bool {
|
||||||
|
gio::spawn_blocking(move || {
|
||||||
|
let conn = Connection::new_session().unwrap();
|
||||||
|
let proxy = conn.with_proxy(
|
||||||
|
"org.xetibo.ReSet",
|
||||||
|
"/org/xetibo/ReSet",
|
||||||
|
Duration::from_millis(1000),
|
||||||
|
);
|
||||||
|
let _: Result<(), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "SetDefaultSink", (name.as_str(),));
|
proxy.method_call("org.xetibo.ReSet", "SetDefaultSink", (name.as_str(),));
|
||||||
if res.is_err() {
|
// if res.is_err() {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
// handle change
|
// handle change
|
||||||
});
|
});
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO propagate error from dbus
|
||||||
|
|
|
@ -8,7 +8,7 @@ use dbus::blocking::Connection;
|
||||||
use dbus::Error;
|
use dbus::Error;
|
||||||
use glib::subclass::types::ObjectSubclassIsExt;
|
use glib::subclass::types::ObjectSubclassIsExt;
|
||||||
use glib::{clone, Cast, Propagation};
|
use glib::{clone, Cast, Propagation};
|
||||||
use gtk::StringObject;
|
use gtk::{gio, StringObject};
|
||||||
use ReSet_Lib::audio::audio::InputStream;
|
use ReSet_Lib::audio::audio::InputStream;
|
||||||
|
|
||||||
use super::inputStreamEntryImpl;
|
use super::inputStreamEntryImpl;
|
||||||
|
@ -24,7 +24,6 @@ impl InputStreamEntry {
|
||||||
pub fn new(sink_box: Arc<SinkBox>, stream: InputStream) -> Self {
|
pub fn new(sink_box: Arc<SinkBox>, stream: InputStream) -> Self {
|
||||||
let obj: Self = Object::builder().build();
|
let obj: Self = Object::builder().build();
|
||||||
// TODO use event callback for progress bar -> this is the "im speaking" indicator
|
// TODO use event callback for progress bar -> this is the "im speaking" indicator
|
||||||
// TODO handle events
|
|
||||||
{
|
{
|
||||||
let index = stream.sink_index;
|
let index = stream.sink_index;
|
||||||
let box_imp = sink_box.imp();
|
let box_imp = sink_box.imp();
|
||||||
|
@ -145,49 +144,60 @@ impl InputStreamEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_inputstream_volume(value: f64, index: u32, channels: u16) -> bool {
|
fn set_inputstream_volume(value: f64, index: u32, channels: u16) -> bool {
|
||||||
let conn = Connection::new_session().unwrap();
|
gio::spawn_blocking(move || {
|
||||||
let proxy = conn.with_proxy(
|
let conn = Connection::new_session().unwrap();
|
||||||
"org.xetibo.ReSet",
|
let proxy = conn.with_proxy(
|
||||||
"/org/xetibo/ReSet",
|
"org.xetibo.ReSet",
|
||||||
Duration::from_millis(1000),
|
"/org/xetibo/ReSet",
|
||||||
);
|
Duration::from_millis(1000),
|
||||||
let res: Result<(bool,), Error> = proxy.method_call(
|
);
|
||||||
"org.xetibo.ReSet",
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
"SetInputStreamVolume",
|
"org.xetibo.ReSet",
|
||||||
(index, channels, value as u32),
|
"SetInputStreamVolume",
|
||||||
);
|
(index, channels, value as u32),
|
||||||
if res.is_err() {
|
);
|
||||||
return false;
|
// if res.is_err() {
|
||||||
}
|
// return false;
|
||||||
res.unwrap().0
|
// }
|
||||||
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn toggle_input_stream_mute(index: u32, muted: bool) -> bool {
|
fn toggle_input_stream_mute(index: u32, muted: bool) -> bool {
|
||||||
let conn = Connection::new_session().unwrap();
|
gio::spawn_blocking(move || {
|
||||||
let proxy = conn.with_proxy(
|
let conn = Connection::new_session().unwrap();
|
||||||
"org.xetibo.ReSet",
|
let proxy = conn.with_proxy(
|
||||||
"/org/xetibo/ReSet",
|
"org.xetibo.ReSet",
|
||||||
Duration::from_millis(1000),
|
"/org/xetibo/ReSet",
|
||||||
);
|
Duration::from_millis(1000),
|
||||||
let res: Result<(bool,), Error> =
|
);
|
||||||
proxy.method_call("org.xetibo.ReSet", "SetInputStreamMute", (index, muted));
|
let _: Result<(), Error> =
|
||||||
if res.is_err() {
|
proxy.method_call("org.xetibo.ReSet", "SetInputStreamMute", (index, muted));
|
||||||
return false;
|
// if res.is_err() {
|
||||||
}
|
// return false;
|
||||||
res.unwrap().0
|
// }
|
||||||
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_sink_of_input_stream(stream: u32, sink: u32) -> bool {
|
fn set_sink_of_input_stream(stream: u32, sink: u32) -> bool {
|
||||||
let conn = Connection::new_session().unwrap();
|
gio::spawn_blocking(move || {
|
||||||
let proxy = conn.with_proxy(
|
let conn = Connection::new_session().unwrap();
|
||||||
"org.xetibo.ReSet",
|
let proxy = conn.with_proxy(
|
||||||
"/org/xetibo/ReSet",
|
"org.xetibo.ReSet",
|
||||||
Duration::from_millis(1000),
|
"/org/xetibo/ReSet",
|
||||||
);
|
Duration::from_millis(1000),
|
||||||
let res: Result<(bool,), Error> =
|
);
|
||||||
proxy.method_call("org.xetibo.ReSet", "SetSinkOfInputStream", (stream, sink));
|
let _: Result<(), Error> =
|
||||||
if res.is_err() {
|
proxy.method_call("org.xetibo.ReSet", "SetSinkOfInputStream", (stream, sink));
|
||||||
return false;
|
// if res.is_err() {
|
||||||
}
|
// return false;
|
||||||
res.unwrap().0
|
// }
|
||||||
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO propagate error from dbus
|
||||||
|
|
|
@ -9,7 +9,7 @@ use dbus::blocking::Connection;
|
||||||
use dbus::Error;
|
use dbus::Error;
|
||||||
use glib::subclass::types::ObjectSubclassIsExt;
|
use glib::subclass::types::ObjectSubclassIsExt;
|
||||||
use glib::{clone, Propagation};
|
use glib::{clone, Propagation};
|
||||||
use gtk::CheckButton;
|
use gtk::{gio, CheckButton};
|
||||||
use ReSet_Lib::audio::audio::Sink;
|
use ReSet_Lib::audio::audio::Sink;
|
||||||
|
|
||||||
use super::sinkEntryImpl;
|
use super::sinkEntryImpl;
|
||||||
|
@ -80,51 +80,59 @@ impl SinkEntry {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_sink_volume(value: f64, index: u32, channels: u16) -> bool {
|
pub fn set_sink_volume(value: f64, index: u32, channels: u16) -> bool {
|
||||||
let conn = Connection::new_session().unwrap();
|
gio::spawn_blocking(move || {
|
||||||
let proxy = conn.with_proxy(
|
|
||||||
"org.xetibo.ReSet",
|
|
||||||
"/org/xetibo/ReSet",
|
|
||||||
Duration::from_millis(1000),
|
|
||||||
);
|
|
||||||
let res: Result<(bool,), Error> = proxy.method_call(
|
|
||||||
"org.xetibo.ReSet",
|
|
||||||
"SetSinkVolume",
|
|
||||||
(index, channels, value as u32),
|
|
||||||
);
|
|
||||||
if res.is_err() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res.unwrap().0
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn toggle_sink_mute(index: u32, muted: bool) -> bool {
|
|
||||||
let conn = Connection::new_session().unwrap();
|
|
||||||
let proxy = conn.with_proxy(
|
|
||||||
"org.xetibo.ReSet",
|
|
||||||
"/org/xetibo/ReSet",
|
|
||||||
Duration::from_millis(1000),
|
|
||||||
);
|
|
||||||
let res: Result<(bool,), Error> =
|
|
||||||
proxy.method_call("org.xetibo.ReSet", "SetSinkMute", (index, muted));
|
|
||||||
if res.is_err() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
res.unwrap().0
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn set_default_sink(name: Arc<String>) {
|
|
||||||
thread::spawn(move || {
|
|
||||||
let conn = Connection::new_session().unwrap();
|
let conn = Connection::new_session().unwrap();
|
||||||
let proxy = conn.with_proxy(
|
let proxy = conn.with_proxy(
|
||||||
"org.xetibo.ReSet",
|
"org.xetibo.ReSet",
|
||||||
"/org/xetibo/ReSet",
|
"/org/xetibo/ReSet",
|
||||||
Duration::from_millis(1000),
|
Duration::from_millis(1000),
|
||||||
);
|
);
|
||||||
let res: Result<(bool,), Error> =
|
let _: Result<(), Error> = proxy.method_call(
|
||||||
|
"org.xetibo.ReSet",
|
||||||
|
"SetSinkVolume",
|
||||||
|
(index, channels, value as u32),
|
||||||
|
);
|
||||||
|
// if res.is_err() {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn toggle_sink_mute(index: u32, muted: bool) -> bool {
|
||||||
|
gio::spawn_blocking(move || {
|
||||||
|
let conn = Connection::new_session().unwrap();
|
||||||
|
let proxy = conn.with_proxy(
|
||||||
|
"org.xetibo.ReSet",
|
||||||
|
"/org/xetibo/ReSet",
|
||||||
|
Duration::from_millis(1000),
|
||||||
|
);
|
||||||
|
let _: Result<(), Error> =
|
||||||
|
proxy.method_call("org.xetibo.ReSet", "SetSinkMute", (index, muted));
|
||||||
|
// if res.is_err() {
|
||||||
|
// return false;
|
||||||
|
// }
|
||||||
|
// res.unwrap().0
|
||||||
|
});
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_default_sink(name: Arc<String>) {
|
||||||
|
gio::spawn_blocking(move || {
|
||||||
|
let conn = Connection::new_session().unwrap();
|
||||||
|
let proxy = conn.with_proxy(
|
||||||
|
"org.xetibo.ReSet",
|
||||||
|
"/org/xetibo/ReSet",
|
||||||
|
Duration::from_millis(1000),
|
||||||
|
);
|
||||||
|
let _: Result<(), Error> =
|
||||||
proxy.method_call("org.xetibo.ReSet", "SetDefaultSink", (name.as_str(),));
|
proxy.method_call("org.xetibo.ReSet", "SetDefaultSink", (name.as_str(),));
|
||||||
if res.is_err() {
|
// if res.is_err() {
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
// handle change
|
// handle change
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO propagate error from dbus
|
||||||
|
|
Loading…
Reference in a new issue