mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-17 10:18:32 +02:00
wip: Attempt to solve audio bug
This commit is contained in:
parent
f8f23faece
commit
5c7bdd6889
|
@ -6,7 +6,8 @@ use std::{
|
||||||
use adw::prelude::{ComboRowExt, PreferencesRowExt};
|
use adw::prelude::{ComboRowExt, PreferencesRowExt};
|
||||||
use dbus::arg::{Arg, Get};
|
use dbus::arg::{Arg, Get};
|
||||||
use glib::{
|
use glib::{
|
||||||
object::{Cast, IsA},
|
object::{Cast, IsA, ObjectExt},
|
||||||
|
property::PropertyGet,
|
||||||
ControlFlow, Propagation,
|
ControlFlow, Propagation,
|
||||||
};
|
};
|
||||||
use gtk::{
|
use gtk::{
|
||||||
|
@ -264,6 +265,7 @@ pub fn object_added_handler<
|
||||||
>(
|
>(
|
||||||
audio_box: Arc<AudioBox>,
|
audio_box: Arc<AudioBox>,
|
||||||
ir: Event,
|
ir: Event,
|
||||||
|
dummy_name: &'static str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
|
@ -305,8 +307,7 @@ pub fn object_added_handler<
|
||||||
let mut index = index.write().unwrap();
|
let mut index = index.write().unwrap();
|
||||||
let model_list = source_box_imp.model_list();
|
let model_list = source_box_imp.model_list();
|
||||||
let model_list = model_list.write().unwrap();
|
let model_list = model_list.write().unwrap();
|
||||||
// TODO: make this work generic!
|
if model_list.string(*index - 1) == Some(dummy_name.into()) {
|
||||||
if model_list.string(*index - 1) == Some("Monitor of Dummy Output".into()) {
|
|
||||||
model_list.append(&alias);
|
model_list.append(&alias);
|
||||||
model_list.remove(*index - 1);
|
model_list.remove(*index - 1);
|
||||||
map.insert(alias, (object_index, name));
|
map.insert(alias, (object_index, name));
|
||||||
|
@ -314,8 +315,7 @@ pub fn object_added_handler<
|
||||||
} else {
|
} else {
|
||||||
model_list.append(&alias);
|
model_list.append(&alias);
|
||||||
map.insert(alias.clone(), (object_index, name));
|
map.insert(alias.clone(), (object_index, name));
|
||||||
// TODO: make this work generic!
|
if alias == dummy_name {
|
||||||
if alias == "Monitor of Dummy Output" {
|
|
||||||
source_box_imp.audio_object_dropdown().set_selected(0);
|
source_box_imp.audio_object_dropdown().set_selected(0);
|
||||||
}
|
}
|
||||||
*index += 1;
|
*index += 1;
|
||||||
|
@ -406,6 +406,7 @@ pub fn object_removed_handler<
|
||||||
>(
|
>(
|
||||||
audio_box: Arc<AudioBox>,
|
audio_box: Arc<AudioBox>,
|
||||||
ir: Event,
|
ir: Event,
|
||||||
|
dummy_name: &'static str,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
glib::spawn_future(async move {
|
glib::spawn_future(async move {
|
||||||
glib::idle_add_once(move || {
|
glib::idle_add_once(move || {
|
||||||
|
@ -431,8 +432,7 @@ pub fn object_removed_handler<
|
||||||
let model_list = model_list.write().unwrap();
|
let model_list = model_list.write().unwrap();
|
||||||
|
|
||||||
if *index == 1 {
|
if *index == 1 {
|
||||||
// TODO: ensure dummy output and input are mentioned
|
model_list.append(dummy_name);
|
||||||
model_list.append("Dummy");
|
|
||||||
}
|
}
|
||||||
for entry in 0..*index {
|
for entry in 0..*index {
|
||||||
if model_list.string(entry) == Some(alias.clone().into()) {
|
if model_list.string(entry) == Some(alias.clone().into()) {
|
||||||
|
|
|
@ -328,6 +328,7 @@ pub fn start_audio_box_listener<
|
||||||
conn: Connection,
|
conn: Connection,
|
||||||
source_box: Arc<AudioBox>,
|
source_box: Arc<AudioBox>,
|
||||||
get_default_name_function: &'static DBusFunction,
|
get_default_name_function: &'static DBusFunction,
|
||||||
|
dummy_name: &'static str,
|
||||||
) -> Connection {
|
) -> Connection {
|
||||||
// TODO: make the failed logs generically sound -> deynamic output for both
|
// TODO: make the failed logs generically sound -> deynamic output for both
|
||||||
let object_added =
|
let object_added =
|
||||||
|
@ -361,7 +362,7 @@ pub fn start_audio_box_listener<
|
||||||
AudioBox,
|
AudioBox,
|
||||||
AudioBoxImpl,
|
AudioBoxImpl,
|
||||||
ObjectAdded,
|
ObjectAdded,
|
||||||
>(object_added_box.clone(), ir)
|
>(object_added_box.clone(), ir, dummy_name)
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
// TODO: handle this with the log/error macro
|
// TODO: handle this with the log/error macro
|
||||||
|
@ -370,7 +371,6 @@ pub fn start_audio_box_listener<
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = conn.add_match(object_changed, move |ir: ObjectChanged, _, _| {
|
let res = conn.add_match(object_changed, move |ir: ObjectChanged, _, _| {
|
||||||
// source_changed_handler(source_changed_box.clone(), ir)
|
|
||||||
object_changed_handler::<
|
object_changed_handler::<
|
||||||
AudioObject,
|
AudioObject,
|
||||||
StreamObject,
|
StreamObject,
|
||||||
|
@ -389,7 +389,6 @@ pub fn start_audio_box_listener<
|
||||||
}
|
}
|
||||||
|
|
||||||
let res = conn.add_match(object_removed, move |ir: ObjectRemoved, _, _| {
|
let res = conn.add_match(object_removed, move |ir: ObjectRemoved, _, _| {
|
||||||
// source_removed_handler(source_removed_box.clone(), ir)
|
|
||||||
object_removed_handler::<
|
object_removed_handler::<
|
||||||
AudioObject,
|
AudioObject,
|
||||||
StreamObject,
|
StreamObject,
|
||||||
|
@ -400,7 +399,7 @@ pub fn start_audio_box_listener<
|
||||||
AudioBox,
|
AudioBox,
|
||||||
AudioBoxImpl,
|
AudioBoxImpl,
|
||||||
ObjectRemoved,
|
ObjectRemoved,
|
||||||
>(object_removed_box.clone(), ir)
|
>(object_removed_box.clone(), ir, dummy_name)
|
||||||
});
|
});
|
||||||
if res.is_err() {
|
if res.is_err() {
|
||||||
println!("fail on source remove event");
|
println!("fail on source remove event");
|
||||||
|
|
|
@ -20,7 +20,7 @@ use crate::components::base::error_impl::ReSetErrorImpl;
|
||||||
|
|
||||||
use super::output_stream_entry::OutputStreamEntry;
|
use super::output_stream_entry::OutputStreamEntry;
|
||||||
use super::source_const::{
|
use super::source_const::{
|
||||||
GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME,
|
DUMMY, GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME
|
||||||
};
|
};
|
||||||
use super::source_entry::SourceEntry;
|
use super::source_entry::SourceEntry;
|
||||||
|
|
||||||
|
@ -110,5 +110,5 @@ pub fn start_source_box_listener(conn: Connection, source_box: Arc<SourceBox>) -
|
||||||
OutputStreamAdded,
|
OutputStreamAdded,
|
||||||
OutputStreamChanged,
|
OutputStreamChanged,
|
||||||
OutputStreamRemoved,
|
OutputStreamRemoved,
|
||||||
>(conn, source_box, &GETDEFAULTNAME)
|
>(conn, source_box, &GETDEFAULTNAME, DUMMY)
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,3 +54,5 @@ pub const SETSTREAMOBJECT: DBusFunction = DBusFunction {
|
||||||
function: "SetSourceOfOutputStream",
|
function: "SetSourceOfOutputStream",
|
||||||
error: "Failed to set source of output stream",
|
error: "Failed to set source of output stream",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const DUMMY: &str = "Monitor of Dummy Output";
|
||||||
|
|
|
@ -20,6 +20,7 @@ use crate::components::base::error_impl::ReSetErrorImpl;
|
||||||
|
|
||||||
use super::input_stream_entry::InputStreamEntry;
|
use super::input_stream_entry::InputStreamEntry;
|
||||||
use super::sink_box_impl;
|
use super::sink_box_impl;
|
||||||
|
use super::sink_const::DUMMY;
|
||||||
use super::sink_const::{
|
use super::sink_const::{
|
||||||
GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME,
|
GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME,
|
||||||
};
|
};
|
||||||
|
@ -113,5 +114,5 @@ pub fn start_sink_box_listener(conn: Connection, sink_box: Arc<SinkBox>) -> Conn
|
||||||
InputStreamAdded,
|
InputStreamAdded,
|
||||||
InputStreamChanged,
|
InputStreamChanged,
|
||||||
InputStreamRemoved,
|
InputStreamRemoved,
|
||||||
>(conn, sink_box, &GETDEFAULTNAME)
|
>(conn, sink_box, &GETDEFAULTNAME, DUMMY)
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,3 +54,5 @@ pub const SETSTREAMOBJECT: DBusFunction = DBusFunction {
|
||||||
function: "SetSinkOfInputStream",
|
function: "SetSinkOfInputStream",
|
||||||
error: "Failed to set sink of input stream",
|
error: "Failed to set sink of input stream",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
pub const DUMMY: &str = "Dummy Input";
|
||||||
|
|
Loading…
Reference in a new issue