use std::thread::spawn;
use std::sync::mpsc;
use pipewire::get_capturables;
use tracing::{info, warn};
mod pipewire;
mod pipewire_dbus;
fn main() {
tracing_subscriber::fmt()
.with_max_level(tracing::Level::TRACE)
.init();
gstreamer::init().unwrap();
let capturables = get_capturables().unwrap();
let c1 = capturables[0].clone();
let c2 = capturables[1].clone();
let (send, recv) = mpsc::channel::<pipewire::PipeWireCapturable>();
let t = spawn(move || {
let mut r;
for _ in 0..2 {
let c = recv.recv().unwrap();
// uncommenting the following line prevents the deadlock
// r = None;
r = Some(c.recorder().unwrap());
}
});
send.send(c1).unwrap();
send.send(c2).unwrap();
t.join().unwrap();
}