mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-15 09:28:33 +02:00
feat: Allow audio listener to be deactivated
This commit is contained in:
parent
1080a03b8b
commit
4e9d98fddb
|
@ -6,7 +6,7 @@ description = "A wip universal Linux settings application."
|
|||
|
||||
[dependencies]
|
||||
reset_daemon = "0.1.9"
|
||||
ReSet-Lib = "0.3.5"
|
||||
ReSet-Lib = "0.4.0"
|
||||
adw = { version = "0.5.3", package = "libadwaita", features = ["v1_4"] }
|
||||
dbus = "0.9.7"
|
||||
gtk = { version = "0.7.3", package = "gtk4", features = ["v4_12"] }
|
||||
|
|
|
@ -392,6 +392,8 @@ pub fn start_audio_listener(
|
|||
return;
|
||||
}
|
||||
|
||||
let mut conn = start_dbus_audio_listener(conn);
|
||||
|
||||
if sink_box.is_some() {
|
||||
conn = start_output_box_listener(conn, sink_box.unwrap());
|
||||
}
|
||||
|
@ -405,6 +407,7 @@ pub fn start_audio_listener(
|
|||
let _ = conn.process(Duration::from_millis(1000));
|
||||
if !listeners.pulse_listener.load(Ordering::SeqCst) {
|
||||
println!("stopping audio listener");
|
||||
stop_dbus_audio_listener(conn);
|
||||
break;
|
||||
}
|
||||
// thread::sleep(Duration::from_millis(1000));
|
||||
|
@ -412,3 +415,22 @@ pub fn start_audio_listener(
|
|||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn start_dbus_audio_listener(conn: Connection) -> Connection {
|
||||
let proxy = conn.with_proxy(
|
||||
"org.xetibo.ReSet",
|
||||
"/org/xetibo/ReSet",
|
||||
Duration::from_millis(1000),
|
||||
);
|
||||
let _: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "StartAudioListener", ());
|
||||
conn
|
||||
}
|
||||
|
||||
fn stop_dbus_audio_listener(conn: Connection) {
|
||||
let proxy = conn.with_proxy(
|
||||
"org.xetibo.ReSet",
|
||||
"/org/xetibo/ReSet",
|
||||
Duration::from_millis(1000),
|
||||
);
|
||||
let _: Result<(), Error> = proxy.method_call("org.xetibo.ReSet", "StopAudioListener", ());
|
||||
}
|
||||
|
|
|
@ -67,15 +67,15 @@ pub const HANDLE_AUDIO_CLICK: fn(Arc<Listeners>, FlowBox) =
|
|||
listeners.stop_network_listener();
|
||||
listeners.stop_bluetooth_listener();
|
||||
let audioOutput = Arc::new(SinkBox::new());
|
||||
populate_sinks(audioOutput.clone());
|
||||
let audioFrame = wrapInFrame(SettingBox::new(&*audioOutput));
|
||||
let audioInput = Arc::new(SourceBox::new());
|
||||
populate_sources(audioInput.clone());
|
||||
start_audio_listener(
|
||||
listeners.clone(),
|
||||
Some(audioOutput.clone()),
|
||||
Some(audioInput.clone()),
|
||||
);
|
||||
populate_sinks(audioOutput.clone());
|
||||
let audioFrame = wrapInFrame(SettingBox::new(&*audioOutput));
|
||||
populate_sources(audioInput.clone());
|
||||
let sourceFrame = wrapInFrame(SettingBox::new(&*audioInput));
|
||||
resetMain.remove_all();
|
||||
resetMain.insert(&audioFrame, -1);
|
||||
|
|
Loading…
Reference in a new issue