fix: Load audio listener properly

This commit is contained in:
Fabio Lenherr / DashieTM 2023-11-19 02:31:41 +01:00
parent 9108ab0d74
commit b28b736697
14 changed files with 440 additions and 143 deletions

View file

@ -1,5 +1,8 @@
use std::{
sync::{atomic::{AtomicBool, Ordering}, Arc},
sync::{
atomic::{AtomicBool, Ordering},
Arc,
},
thread,
time::Duration,
};
@ -15,7 +18,10 @@ use ReSet_Lib::{
signals::GetVal,
};
use crate::components::{input::sourceBox::{SourceBox, start_input_box_listener}, output::sinkBox::{SinkBox, start_output_box_listener}};
use crate::components::{
input::sourceBox::{start_input_box_listener, SourceBox},
output::sinkBox::{start_output_box_listener, SinkBox},
};
#[derive(Default)]
pub struct Listeners {
@ -41,6 +47,14 @@ impl Listeners {
proxy.method_call("org.xetibo.ReSet", "StopNetworkListener", ());
});
}
pub fn stop_audio_listener(&self) {
self.pulse_listener.store(false, Ordering::SeqCst);
}
pub fn stop_bluetooth_listener(&self) {
self.bluetooth_listener.store(false, Ordering::SeqCst);
}
}
#[derive(Debug)]
@ -367,20 +381,29 @@ impl GetVal<(u32,)> for OutputStreamRemoved {
}
}
pub fn start_event_listener(listeners: Arc<Listeners>, sink_box: Option<Arc<SinkBox>>,source_box: Option<Arc<SourceBox>>) {
pub fn start_audio_listener(
listeners: Arc<Listeners>,
sink_box: Option<Arc<SinkBox>>,
source_box: Option<Arc<SourceBox>>,
) {
gio::spawn_blocking(move || {
let mut conn = Connection::new_session().unwrap();
if listeners.pulse_listener.load(Ordering::SeqCst) {
return;
}
if sink_box.is_some() {
conn = start_output_box_listener(conn, listeners.clone(), sink_box.unwrap());
conn = start_output_box_listener(conn, sink_box.unwrap());
}
if source_box.is_some() {
conn = start_input_box_listener(conn, listeners.clone(), source_box.unwrap());
conn = start_input_box_listener(conn, source_box.unwrap());
}
listeners.pulse_listener.store(true, Ordering::SeqCst);
println!("starting audio listener");
loop {
let _ = conn.process(Duration::from_millis(1000));
if !listeners.network_listener.load(Ordering::SeqCst) {
if !listeners.pulse_listener.load(Ordering::SeqCst) {
println!("stopping audio listener");
break;
}

View file

@ -1,7 +1,7 @@
use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::thread;
use std::time::Duration;
use std::time::{Duration, SystemTime};
use adw::glib;
use adw::glib::Object;
@ -49,45 +49,47 @@ impl BluetoothBox {
}
pub fn scanForDevices(&self) {
let selfImp = self.imp();
let mut wifiEntries = selfImp.availableDevices.borrow_mut();
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
DeviceTypes::Mouse,
"ina mouse",
)));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
DeviceTypes::Keyboard,
"inaboard",
)));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
DeviceTypes::Controller,
"ina controller",
)));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
DeviceTypes::Controller,
"ina best waifu",
)));
for wifiEntry in wifiEntries.iter() {
selfImp.resetBluetoothAvailableDevices.append(wifiEntry);
}
// let selfImp = self.imp();
// let mut wifiEntries = selfImp.availableDevices.borrow_mut();
// wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
// DeviceTypes::Mouse,
// "ina mouse",
// )));
// wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
// DeviceTypes::Keyboard,
// "inaboard",
// )));
// wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
// DeviceTypes::Controller,
// "ina controller",
// )));
// wifiEntries.push(
// ListEntry::new(&BluetoothEntry::new(
// DeviceTypes::Controller,
// "ina best waifu",
// ))
// );
//
// for wifiEntry in wifiEntries.iter() {
// selfImp.resetBluetoothAvailableDevices.append(wifiEntry);
// }
}
pub fn addConnectedDevices(&self) {
let selfImp = self.imp();
let mut wifiEntries = selfImp.connectedDevices.borrow_mut();
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
DeviceTypes::Mouse,
"why are we still here?",
)));
wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
DeviceTypes::Keyboard,
"just to suffer?",
)));
for wifiEntry in wifiEntries.iter() {
selfImp.resetBluetoothConnectedDevices.append(wifiEntry);
}
// let selfImp = self.imp();
// let mut wifiEntries = selfImp.connectedDevices.borrow_mut();
// wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
// DeviceTypes::Mouse,
// "why are we still here?",
// )));
// wifiEntries.push(ListEntry::new(&BluetoothEntry::new(
// DeviceTypes::Keyboard,
// "just to suffer?",
// )));
//
// for wifiEntry in wifiEntries.iter() {
// selfImp.resetBluetoothConnectedDevices.append(wifiEntry);
// }
}
}
@ -104,7 +106,7 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
Duration::from_millis(1000),
);
let _: Result<(), Error> =
proxy.method_call("org.xetibo.ReSet", "StartBluetoothSearch", (5000,));
proxy.method_call("org.xetibo.ReSet", "StartBluetoothSearch", (10000,));
let device_added = BluetoothDeviceAdded::match_rule(
Some(&"org.xetibo.ReSet".into()),
Some(&Path::from("/org/xetibo/ReSet")),
@ -117,14 +119,21 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
.static_clone();
let device_added_box = bluetooth_box.clone();
let device_removed_box = bluetooth_box.clone();
let loop_box = bluetooth_box.clone();
let res = conn.add_match(device_added, move |ir: BluetoothDeviceAdded, _, _| {
let bluetooth_box = device_added_box.clone();
println!("added");
glib::spawn_future(async move {
glib::idle_add_once(move || {
//
//
let imp = bluetooth_box.imp();
let path = ir.bluetooth_device.path.clone();
let bluetooth_entry = Arc::new(BluetoothEntry::new(ir.bluetooth_device));
let entry = Arc::new(ListEntry::new(&*bluetooth_entry));
imp.availableDevices
.borrow_mut()
.insert(path, (bluetooth_entry.clone(), entry.clone()));
imp.resetBluetoothAvailableDevices.append(&*entry);
});
});
true
@ -139,8 +148,13 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
println!("removed");
glib::spawn_future(async move {
glib::idle_add_once(move || {
//
//
let imp = bluetooth_box.imp();
let map = imp.availableDevices.borrow_mut();
let list_entry = map.get(&ir.bluetooth_device);
if list_entry.is_some() {
imp.resetBluetoothAvailableDevices
.remove(&*list_entry.unwrap().0);
}
});
});
true
@ -151,10 +165,19 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
}
listeners.bluetooth_listener.store(true, Ordering::SeqCst);
let time = SystemTime::now();
loop {
let _ = conn.process(Duration::from_millis(1000));
if !listeners.bluetooth_listener.load(Ordering::SeqCst) {
if !listeners.bluetooth_listener.load(Ordering::SeqCst)
// || time.elapsed().unwrap() > Duration::from_millis(5000)
{
glib::spawn_future(async move {
glib::idle_add_once(move || {
let imp = loop_box.imp();
imp.resetBluetoothConnectedDevices.remove_all();
});
});
println!("stopping bluetooth listener");
break;
}
@ -162,4 +185,3 @@ pub fn start_bluetooth_listener(listeners: Arc<Listeners>, bluetooth_box: Arc<Bl
}
});
}

View file

@ -1,11 +1,14 @@
use std::cell::RefCell;
use gtk::{CompositeTemplate, glib, ListBox, Switch};
use dbus::Path;
use gtk::prelude::*;
use gtk::subclass::prelude::*;
use gtk::{glib, CompositeTemplate, ListBox, Switch};
use std::cell::RefCell;
use std::collections::HashMap;
use std::sync::Arc;
use crate::components::base::listEntry::ListEntry;
use crate::components::bluetooth::bluetoothBox;
use crate::components::bluetooth::bluetoothEntry::BluetoothEntry;
use crate::components::base::listEntry::ListEntry;
#[allow(non_snake_case)]
#[derive(Default, CompositeTemplate)]
@ -21,8 +24,8 @@ pub struct BluetoothBox {
pub resetVisibility: TemplateChild<ListEntry>,
#[template_child]
pub resetBluetoothMainTab: TemplateChild<ListEntry>,
pub availableDevices: RefCell<Vec<ListEntry>>,
pub connectedDevices: RefCell<Vec<ListEntry>>,
pub availableDevices: RefCell<HashMap<Path<'static>, (Arc<BluetoothEntry>, Arc<ListEntry>)>>,
pub connectedDevices: RefCell<HashMap<Path<'static>, (Arc<BluetoothEntry>, Arc<ListEntry>)>>,
}
#[glib::object_subclass]

View file

@ -1,8 +1,16 @@
use std::time::Duration;
use crate::components::bluetooth::bluetoothEntryImpl;
use crate::components::bluetooth::bluetoothEntryImpl::DeviceTypes;
use adw::glib;
use adw::glib::Object;
use adw::subclass::prelude::ObjectSubclassIsExt;
use crate::components::bluetooth::bluetoothEntryImpl;
use crate::components::bluetooth::bluetoothEntryImpl::DeviceTypes;
use dbus::blocking::Connection;
use dbus::{Error, Path};
use glib::clone;
use gtk::prelude::WidgetExt;
use gtk::{gio, GestureClick};
use ReSet_Lib::bluetooth::bluetooth::BluetoothDevice;
glib::wrapper! {
pub struct BluetoothEntry(ObjectSubclass<bluetoothEntryImpl::BluetoothEntry>)
@ -11,21 +19,75 @@ glib::wrapper! {
}
impl BluetoothEntry {
pub fn new(deviceType: DeviceTypes, name: &str) -> Self {
pub fn new(device: BluetoothDevice) -> Self {
let entry: BluetoothEntry = Object::builder().build();
let entryImp = entry.imp();
entryImp.resetBluetoothLabel.get().set_text(name);
entryImp.resetBluetoothDeviceType.get().set_from_icon_name(match deviceType {
DeviceTypes::Mouse => Some("input-mouse-symbolic"),
DeviceTypes::Keyboard => Some("input-keyboard-symbolic"),
DeviceTypes::Headset => Some("output-headset-symbolic"),
DeviceTypes::Controller => Some("input-gaming-symbolic"),
DeviceTypes::None => Some("text-x-generic-symbolic") // no generic bluetooth device icon found
});
{
let mut wifiName = entryImp.deviceName.borrow_mut();
*wifiName = String::from(name);
}
entryImp.resetBluetoothLabel.get().set_text(&device.name);
entryImp.resetBluetoothAddress.get().set_text(&device.address);
// entryImp
// .resetBluetoothDeviceType
// .get()
// .set_from_icon_name(match deviceType {
// DeviceTypes::Mouse => Some("input-mouse-symbolic"),
// DeviceTypes::Keyboard => Some("input-keyboard-symbolic"),
// DeviceTypes::Headset => Some("output-headset-symbolic"),
// DeviceTypes::Controller => Some("input-gaming-symbolic"),
// DeviceTypes::None => Some("text-x-generic-symbolic"), // no generic bluetooth device icon found
// });
let gesture = GestureClick::new();
let connected = false;
// TODO implement this connected
entryImp.device.replace(device);
gesture.connect_released(clone!(@weak entryImp => move |_, _, _, _| {
let device = entryImp.device.borrow_mut();
if connected {
disconnect_from_device(device.path.clone());
} else if device.paired {
connect_to_device(device.path.clone());
} else {
pair_with_device(device.path.clone());
}
}));
entry.add_controller(gesture);
entry
}
}
}
fn connect_to_device(path: Path<'static>) {
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<(bool,), Error> =
proxy.method_call("org.xetibo.ReSet", "ConnectToBluetoothDevice", (path,));
});
}
fn pair_with_device(path: Path<'static>) {
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<(bool,), Error> =
proxy.method_call("org.xetibo.ReSet", "PairWithBluetoothDevice", (path,));
});
}
fn disconnect_from_device(path: Path<'static>) {
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<(bool,), Error> =
proxy.method_call("org.xetibo.ReSet", "DisconnectFromBluetoothDevice", (path,));
});
}

View file

@ -1,4 +1,5 @@
use std::cell::RefCell;
use ReSet_Lib::bluetooth::bluetooth::BluetoothDevice;
use gtk::{Button, CompositeTemplate, glib, Image, Label};
use gtk::subclass::prelude::*;
use crate::components::bluetooth::bluetoothEntry;
@ -21,8 +22,11 @@ pub struct BluetoothEntry {
#[template_child]
pub resetBluetoothLabel: TemplateChild<Label>,
#[template_child]
pub resetBluetoothAddress: TemplateChild<Label>,
#[template_child]
pub resetBluetoothButton: TemplateChild<Button>,
pub deviceName: RefCell<String>,
pub device: RefCell<BluetoothDevice>
}
#[glib::object_subclass]

View file

@ -2,6 +2,7 @@ use std::sync::atomic::Ordering;
use std::sync::Arc;
use std::time::{Duration, SystemTime};
use crate::components::base::cardEntry::CardEntry;
use crate::components::base::listEntry::ListEntry;
use crate::components::base::utils::{
Listeners, OutputStreamAdded, OutputStreamChanged, OutputStreamRemoved, SourceAdded,
@ -19,7 +20,7 @@ use glib::subclass::prelude::ObjectSubclassIsExt;
use glib::{clone, Cast, Propagation, Variant};
use gtk::prelude::ActionableExt;
use gtk::{gio, StringObject};
use ReSet_Lib::audio::audio::{OutputStream, Source};
use ReSet_Lib::audio::audio::{Card, OutputStream, Source};
use super::outputStreamEntry::OutputStreamEntry;
use super::sourceEntry::{set_default_source, toggle_source_mute, SourceEntry};
@ -46,10 +47,18 @@ impl SourceBox {
selfImp
.resetSourceRow
.set_action_target_value(Some(&Variant::from("sources")));
selfImp
.resetCardsRow
.set_action_name(Some("navigation.push"));
selfImp
.resetCardsRow
.set_action_target_value(Some(&Variant::from("profileConfiguration")));
selfImp
.resetOutputStreamButton
.set_action_name(Some("navigation.pop"));
selfImp
.resetInputCardsBackButton
.set_action_name(Some("navigation.pop"));
}
}
@ -74,6 +83,7 @@ pub fn populate_sources(input_box: Arc<SourceBox>) {
.replace(get_default_source());
populate_outputstreams(input_box.clone());
populate_cards(input_box.clone());
glib::spawn_future(async move {
glib::idle_add_once(move || {
// TODO handle events
@ -212,6 +222,22 @@ pub fn populate_outputstreams(input_box: Arc<SourceBox>) {
});
}
pub fn populate_cards(input_box: Arc<SourceBox>) {
gio::spawn_blocking(move || {
let output_box_ref = input_box.clone();
let cards = get_cards();
glib::spawn_future(async move {
glib::idle_add_once(move || {
let imp = output_box_ref.imp();
for card in cards {
imp.resetCards
.append(&ListEntry::new(&CardEntry::new(card)));
}
});
});
});
}
fn get_output_streams() -> Vec<OutputStream> {
let conn = Connection::new_session().unwrap();
let proxy = conn.with_proxy(
@ -242,6 +268,20 @@ fn get_sources() -> Vec<Source> {
res.unwrap().0
}
fn get_cards() -> Vec<Card> {
let conn = Connection::new_session().unwrap();
let proxy = conn.with_proxy(
"org.xetibo.ReSet",
"/org/xetibo/ReSet",
Duration::from_millis(1000),
);
let res: Result<(Vec<Card>,), Error> = proxy.method_call("org.xetibo.ReSet", "ListCards", ());
if res.is_err() {
return Vec::new();
}
res.unwrap().0
}
fn get_default_source() -> Source {
let conn = Connection::new_session().unwrap();
let proxy = conn.with_proxy(
@ -257,16 +297,7 @@ fn get_default_source() -> Source {
res.unwrap().0
}
pub fn start_input_box_listener(
conn: Connection,
listeners: Arc<Listeners>,
source_box: Arc<SourceBox>,
) -> Connection {
if listeners.network_listener.load(Ordering::SeqCst) {
return conn;
}
listeners.network_listener.store(true, Ordering::SeqCst);
pub fn start_input_box_listener(conn: Connection, source_box: Arc<SourceBox>) -> Connection {
let source_added = SourceAdded::match_rule(
Some(&"org.xetibo.ReSet".into()),
Some(&Path::from("/org/xetibo/ReSet")),
@ -344,6 +375,7 @@ pub fn start_input_box_listener(
let res = conn.add_match(source_removed, move |ir: SourceRemoved, _, _| {
let source_box = source_removed_box.clone();
println!("removed {}", ir.index);
glib::spawn_future(async move {
glib::idle_add_once(move || {
let output_box = source_box.clone();
@ -515,6 +547,5 @@ pub fn start_input_box_listener(
return conn;
}
listeners.network_listener.store(true, Ordering::SeqCst);
conn
}

View file

@ -20,6 +20,8 @@ pub struct SourceBox {
#[template_child]
pub resetSourceRow: TemplateChild<ListEntry>,
#[template_child]
pub resetCardsRow: TemplateChild<ListEntry>,
#[template_child]
pub resetSourceDropdown: TemplateChild<DropDown>,
#[template_child]
pub resetSourceMute: TemplateChild<Button>,
@ -35,6 +37,10 @@ pub struct SourceBox {
pub resetOutputStreamButton: TemplateChild<ListEntry>,
#[template_child]
pub resetOutputStreams: TemplateChild<gtk::Box>,
#[template_child]
pub resetInputCardsBackButton: TemplateChild<ListEntry>,
#[template_child]
pub resetCards: TemplateChild<gtk::Box>,
pub resetDefaultCheckButton: Arc<CheckButton>,
pub resetDefaultSource: Arc<RefCell<Source>>,
pub resetSourceList: Arc<RwLock<HashMap<u32, (Arc<ListEntry>, Arc<SourceEntry>, String)>>>,

View file

@ -302,16 +302,7 @@ fn get_cards() -> Vec<Card> {
res.unwrap().0
}
pub fn start_output_box_listener(
conn: Connection,
listeners: Arc<Listeners>,
sink_box: Arc<SinkBox>,
) -> Connection {
if listeners.network_listener.load(Ordering::SeqCst) {
return conn;
}
listeners.network_listener.store(true, Ordering::SeqCst);
pub fn start_output_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Connection {
let sink_added = SinkAdded::match_rule(
Some(&"org.xetibo.ReSet".into()),
Some(&Path::from("/org/xetibo/ReSet")),
@ -551,6 +542,5 @@ pub fn start_output_box_listener(
return conn;
}
listeners.network_listener.store(true, Ordering::SeqCst);
conn
}

View file

@ -1,9 +1,8 @@
use gtk::prelude::FrameExt;
use std::sync::atomic::Ordering;
use std::sync::Arc;
use crate::components::base::settingBox::SettingBox;
use crate::components::base::utils::{start_event_listener, Listeners};
use crate::components::base::utils::{start_audio_listener, Listeners};
use crate::components::bluetooth::bluetoothBox::{start_bluetooth_listener, BluetoothBox};
use crate::components::input::sourceBox::{populate_sources, SourceBox};
use crate::components::output::sinkBox::{populate_sinks, SinkBox};
@ -13,7 +12,7 @@ use gtk::{FlowBox, Frame, Label};
pub const HANDLE_CONNECTIVITY_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_audio_listener();
let wifiBox = Arc::new(WifiBox::new());
show_stored_connections(wifiBox.clone());
scanForWifi(listeners.clone(), wifiBox.clone());
@ -29,8 +28,8 @@ pub const HANDLE_CONNECTIVITY_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_WIFI_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_audio_listener();
listeners.stop_bluetooth_listener();
let wifiBox = Arc::new(WifiBox::new());
scanForWifi(listeners.clone(), wifiBox.clone());
let wifiFrame = wrapInFrame(SettingBox::new(&*wifiBox));
@ -42,7 +41,7 @@ pub const HANDLE_WIFI_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_BLUETOOTH_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_audio_listener();
let bluetooth_box = Arc::new(BluetoothBox::new());
start_bluetooth_listener(listeners.clone(), bluetooth_box.clone());
let bluetoothFrame = wrapInFrame(SettingBox::new(&*bluetooth_box));
@ -54,8 +53,8 @@ pub const HANDLE_BLUETOOTH_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_VPN_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_bluetooth_listener();
listeners.stop_audio_listener();
let label = Label::new(Some("not implemented yet"));
resetMain.remove_all();
resetMain.insert(&label, -1);
@ -65,14 +64,13 @@ pub const HANDLE_VPN_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_AUDIO_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(true, Ordering::SeqCst);
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_event_listener(
start_audio_listener(
listeners.clone(),
Some(audioOutput.clone()),
Some(audioInput.clone()),
@ -87,11 +85,10 @@ pub const HANDLE_AUDIO_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_VOLUME_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_bluetooth_listener();
let audioOutput = Arc::new(SinkBox::new());
populate_sinks(audioOutput.clone());
start_event_listener(listeners.clone(), Some(audioOutput.clone()), None);
start_audio_listener(listeners.clone(), Some(audioOutput.clone()), None);
let audioFrame = wrapInFrame(SettingBox::new(&*audioOutput));
resetMain.remove_all();
resetMain.insert(&audioFrame, -1);
@ -101,11 +98,10 @@ pub const HANDLE_VOLUME_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_MICROPHONE_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_bluetooth_listener();
let audioInput = Arc::new(SourceBox::new());
populate_sources(audioInput.clone());
start_event_listener(listeners.clone(), None, Some(audioInput.clone()));
start_audio_listener(listeners.clone(), None, Some(audioInput.clone()));
let sourceFrame = wrapInFrame(SettingBox::new(&*audioInput));
resetMain.remove_all();
resetMain.insert(&sourceFrame, -1);
@ -115,8 +111,8 @@ pub const HANDLE_MICROPHONE_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_PERIPHERALS_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_audio_listener();
listeners.stop_bluetooth_listener();
let label = Label::new(Some("not implemented yet"));
resetMain.remove_all();
resetMain.insert(&label, -1);
@ -126,8 +122,8 @@ pub const HANDLE_PERIPHERALS_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_MONITOR_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_audio_listener();
listeners.stop_bluetooth_listener();
let label = Label::new(Some("not implemented yet"));
resetMain.remove_all();
resetMain.insert(&label, -1);
@ -137,8 +133,8 @@ pub const HANDLE_MONITOR_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_MOUSE_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_audio_listener();
listeners.stop_bluetooth_listener();
let label = Label::new(Some("not implemented yet"));
resetMain.remove_all();
resetMain.insert(&label, -1);
@ -148,8 +144,8 @@ pub const HANDLE_MOUSE_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_KEYBOARD_CLICK: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_audio_listener();
listeners.stop_bluetooth_listener();
let label = Label::new(Some("not implemented yet"));
resetMain.remove_all();
resetMain.insert(&label, -1);
@ -159,9 +155,8 @@ pub const HANDLE_KEYBOARD_CLICK: fn(Arc<Listeners>, FlowBox) =
pub const HANDLE_HOME: fn(Arc<Listeners>, FlowBox) =
|listeners: Arc<Listeners>, resetMain: FlowBox| {
listeners.stop_network_listener();
listeners.network_listener.store(false, Ordering::SeqCst);
listeners.bluetooth_listener.store(false, Ordering::SeqCst);
listeners.pulse_listener.store(false, Ordering::SeqCst);
listeners.stop_audio_listener();
listeners.stop_bluetooth_listener();
resetMain.remove_all();
};