Pass config from main to the relevant places
This commit is contained in:
@@ -266,7 +266,16 @@ pub enum AudioMessage {
|
||||
|
||||
pub struct AudioBackend {
|
||||
subscribers: Vec<Sender<AudioMessage>>,
|
||||
command_tx: Sender<AudioMessage>,
|
||||
command_tx: Option<Sender<AudioMessage>>,
|
||||
}
|
||||
|
||||
impl AudioBackend {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
subscribers: vec![],
|
||||
command_tx: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl BackendThread<AudioMessage, Sender<AudioMessage>> for AudioBackend {
|
||||
@@ -288,12 +297,10 @@ impl BackendThread<AudioMessage, Sender<AudioMessage>> for AudioBackend {
|
||||
&self.subscribers
|
||||
}
|
||||
|
||||
fn init(registration_rx: Receiver<Sender<AudioMessage>>) {
|
||||
fn init(mut self, registration_rx: Receiver<Sender<AudioMessage>>) {
|
||||
let (command_tx, command_rx) = crossbeam_channel::unbounded::<AudioMessage>();
|
||||
let instance = Arc::new(Mutex::new(Self {
|
||||
subscribers: vec![],
|
||||
command_tx,
|
||||
}));
|
||||
self.command_tx = Some(command_tx);
|
||||
let instance = Arc::new(Mutex::new(self));
|
||||
let (controller_tx, controller_rx) = crossbeam_channel::unbounded::<ControllerMsg>();
|
||||
let notify = Arc::new(EventFD::new(0, EfdFlags::EFD_CLOEXEC).unwrap());
|
||||
thread::spawn({
|
||||
@@ -381,7 +388,8 @@ impl BackendThread<AudioMessage, Sender<AudioMessage>> for AudioBackend {
|
||||
.lock()
|
||||
.expect("Couldn't get lock")
|
||||
.command_tx
|
||||
.clone(),
|
||||
.clone()
|
||||
.unwrap(),
|
||||
))
|
||||
.is_ok()
|
||||
{
|
||||
@@ -460,13 +468,9 @@ impl BackendThread<MediaMessage, Sender<MediaMessage>> for MediaBackend {
|
||||
&self.subscribers
|
||||
}
|
||||
|
||||
fn init(registration_rx: Receiver<Sender<MediaMessage>>) {
|
||||
fn init(self, registration_rx: Receiver<Sender<MediaMessage>>) {
|
||||
let (tx, rx) = crossbeam_channel::unbounded::<MediaMessage>();
|
||||
let instance = Arc::new(Mutex::new(Self {
|
||||
subscribers: vec![],
|
||||
players: HashMap::new(),
|
||||
active_player: None,
|
||||
}));
|
||||
let instance = Arc::new(Mutex::new(self));
|
||||
thread::spawn({
|
||||
let instance = instance.clone();
|
||||
move || {
|
||||
@@ -545,6 +549,13 @@ impl BackendThread<MediaMessage, Sender<MediaMessage>> for MediaBackend {
|
||||
}
|
||||
|
||||
impl MediaBackend {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
subscribers: vec![],
|
||||
players: HashMap::new(),
|
||||
active_player: None,
|
||||
}
|
||||
}
|
||||
async fn find_existing_players(
|
||||
connection: &zbus::Connection,
|
||||
instance: Arc<Mutex<Self>>,
|
||||
|
||||
Reference in New Issue
Block a user