mirror of
https://github.com/Xetibo/ReSet.git
synced 2025-04-08 14:42:02 +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 dbus::arg::{Arg, Get};
|
||||
use glib::{
|
||||
object::{Cast, IsA},
|
||||
object::{Cast, IsA, ObjectExt},
|
||||
property::PropertyGet,
|
||||
ControlFlow, Propagation,
|
||||
};
|
||||
use gtk::{
|
||||
|
@ -264,6 +265,7 @@ pub fn object_added_handler<
|
|||
>(
|
||||
audio_box: Arc<AudioBox>,
|
||||
ir: Event,
|
||||
dummy_name: &'static str,
|
||||
) -> bool {
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
|
@ -305,8 +307,7 @@ pub fn object_added_handler<
|
|||
let mut index = index.write().unwrap();
|
||||
let model_list = source_box_imp.model_list();
|
||||
let model_list = model_list.write().unwrap();
|
||||
// TODO: make this work generic!
|
||||
if model_list.string(*index - 1) == Some("Monitor of Dummy Output".into()) {
|
||||
if model_list.string(*index - 1) == Some(dummy_name.into()) {
|
||||
model_list.append(&alias);
|
||||
model_list.remove(*index - 1);
|
||||
map.insert(alias, (object_index, name));
|
||||
|
@ -314,8 +315,7 @@ pub fn object_added_handler<
|
|||
} else {
|
||||
model_list.append(&alias);
|
||||
map.insert(alias.clone(), (object_index, name));
|
||||
// TODO: make this work generic!
|
||||
if alias == "Monitor of Dummy Output" {
|
||||
if alias == dummy_name {
|
||||
source_box_imp.audio_object_dropdown().set_selected(0);
|
||||
}
|
||||
*index += 1;
|
||||
|
@ -406,6 +406,7 @@ pub fn object_removed_handler<
|
|||
>(
|
||||
audio_box: Arc<AudioBox>,
|
||||
ir: Event,
|
||||
dummy_name: &'static str,
|
||||
) -> bool {
|
||||
glib::spawn_future(async move {
|
||||
glib::idle_add_once(move || {
|
||||
|
@ -431,8 +432,7 @@ pub fn object_removed_handler<
|
|||
let model_list = model_list.write().unwrap();
|
||||
|
||||
if *index == 1 {
|
||||
// TODO: ensure dummy output and input are mentioned
|
||||
model_list.append("Dummy");
|
||||
model_list.append(dummy_name);
|
||||
}
|
||||
for entry in 0..*index {
|
||||
if model_list.string(entry) == Some(alias.clone().into()) {
|
||||
|
|
|
@ -328,6 +328,7 @@ pub fn start_audio_box_listener<
|
|||
conn: Connection,
|
||||
source_box: Arc<AudioBox>,
|
||||
get_default_name_function: &'static DBusFunction,
|
||||
dummy_name: &'static str,
|
||||
) -> Connection {
|
||||
// TODO: make the failed logs generically sound -> deynamic output for both
|
||||
let object_added =
|
||||
|
@ -361,7 +362,7 @@ pub fn start_audio_box_listener<
|
|||
AudioBox,
|
||||
AudioBoxImpl,
|
||||
ObjectAdded,
|
||||
>(object_added_box.clone(), ir)
|
||||
>(object_added_box.clone(), ir, dummy_name)
|
||||
});
|
||||
if res.is_err() {
|
||||
// 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, _, _| {
|
||||
// source_changed_handler(source_changed_box.clone(), ir)
|
||||
object_changed_handler::<
|
||||
AudioObject,
|
||||
StreamObject,
|
||||
|
@ -389,7 +389,6 @@ pub fn start_audio_box_listener<
|
|||
}
|
||||
|
||||
let res = conn.add_match(object_removed, move |ir: ObjectRemoved, _, _| {
|
||||
// source_removed_handler(source_removed_box.clone(), ir)
|
||||
object_removed_handler::<
|
||||
AudioObject,
|
||||
StreamObject,
|
||||
|
@ -400,7 +399,7 @@ pub fn start_audio_box_listener<
|
|||
AudioBox,
|
||||
AudioBoxImpl,
|
||||
ObjectRemoved,
|
||||
>(object_removed_box.clone(), ir)
|
||||
>(object_removed_box.clone(), ir, dummy_name)
|
||||
});
|
||||
if res.is_err() {
|
||||
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::source_const::{
|
||||
GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME,
|
||||
DUMMY, GETDEFAULT, GETDEFAULTNAME, GETOBJECTS, GETSTREAMS, SETDEFAULT, SETMUTE, SETVOLUME
|
||||
};
|
||||
use super::source_entry::SourceEntry;
|
||||
|
||||
|
@ -110,5 +110,5 @@ pub fn start_source_box_listener(conn: Connection, source_box: Arc<SourceBox>) -
|
|||
OutputStreamAdded,
|
||||
OutputStreamChanged,
|
||||
OutputStreamRemoved,
|
||||
>(conn, source_box, &GETDEFAULTNAME)
|
||||
>(conn, source_box, &GETDEFAULTNAME, DUMMY)
|
||||
}
|
||||
|
|
|
@ -54,3 +54,5 @@ pub const SETSTREAMOBJECT: DBusFunction = DBusFunction {
|
|||
function: "SetSourceOfOutputStream",
|
||||
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::sink_box_impl;
|
||||
use super::sink_const::DUMMY;
|
||||
use super::sink_const::{
|
||||
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,
|
||||
InputStreamChanged,
|
||||
InputStreamRemoved,
|
||||
>(conn, sink_box, &GETDEFAULTNAME)
|
||||
>(conn, sink_box, &GETDEFAULTNAME, DUMMY)
|
||||
}
|
||||
|
|
|
@ -54,3 +54,5 @@ pub const SETSTREAMOBJECT: DBusFunction = DBusFunction {
|
|||
function: "SetSinkOfInputStream",
|
||||
error: "Failed to set sink of input stream",
|
||||
};
|
||||
|
||||
pub const DUMMY: &str = "Dummy Input";
|
||||
|
|
Loading…
Reference in a new issue