a lot of attempts to make obs work. the setting never finishes
By setting the log level to tracing, I can find that obs isn't responding to obws or something. Need to figure out why...
This commit is contained in:
parent
62a9058fab
commit
265bd8383c
1 changed files with 24 additions and 11 deletions
|
@ -1,5 +1,6 @@
|
||||||
use core::fmt;
|
use core::fmt;
|
||||||
use std::error::Error;
|
use std::error::Error;
|
||||||
|
use std::thread::sleep;
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use obws::responses::scenes::Scenes;
|
use obws::responses::scenes::Scenes;
|
||||||
|
@ -71,14 +72,25 @@ impl Obs {
|
||||||
debug!("Starting function");
|
debug!("Starting function");
|
||||||
if self.client.is_some() {
|
if self.client.is_some() {
|
||||||
debug!("Starting to set");
|
debug!("Starting to set");
|
||||||
let runtime = tokio::runtime::Runtime::new().unwrap();
|
let runtime =
|
||||||
runtime.block_on(async move {
|
tokio::runtime::Builder::new_current_thread()
|
||||||
|
.thread_keep_alive(Duration::from_secs(1))
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
let client = make_client();
|
||||||
|
let handle = runtime.spawn(async move {
|
||||||
debug!(scene, "working in thread");
|
debug!(scene, "working in thread");
|
||||||
self.client
|
client.scenes()
|
||||||
.unwrap()
|
.set_current_program_scene(&scene)
|
||||||
.scenes()
|
.await
|
||||||
.set_current_program_scene(&scene).await
|
});
|
||||||
})?;
|
loop {
|
||||||
|
sleep(Duration::from_millis(100));
|
||||||
|
if handle.is_finished() {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err("There is no client".to_owned())?
|
Err("There is no client".to_owned())?
|
||||||
|
@ -118,10 +130,11 @@ mod obs_model {
|
||||||
obs: Option<super::Obs>,
|
obs: Option<super::Obs>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
impl qobject::ObsModel {
|
impl qobject::ObsModel {
|
||||||
#[qinvokable]
|
#[qinvokable]
|
||||||
pub fn update_scenes(mut self: Pin<&mut Self>) -> QStringList {
|
pub fn update_scenes(
|
||||||
|
mut self: Pin<&mut Self>,
|
||||||
|
) -> QStringList {
|
||||||
debug!("updating scenes");
|
debug!("updating scenes");
|
||||||
let mut scenes_list = QList_QString::default();
|
let mut scenes_list = QList_QString::default();
|
||||||
if let Some(obs) = self.obs() {
|
if let Some(obs) = self.obs() {
|
||||||
|
@ -150,11 +163,11 @@ mod obs_model {
|
||||||
self.as_mut().set_connected(true);
|
self.as_mut().set_connected(true);
|
||||||
self.as_mut().set_obs(Some(o));
|
self.as_mut().set_obs(Some(o));
|
||||||
self.as_mut().update_scenes();
|
self.as_mut().update_scenes();
|
||||||
},
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!(e);
|
error!(e);
|
||||||
self.as_mut().set_connected(false);
|
self.as_mut().set_connected(false);
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue